YAML in Kubernetes Flashcards

1
Q

4 top level fields

A

apiVersion:

kind:

metadata:

spec:

[all required]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

apiVersion

A

POD, Service: v1

ReplicaSet, Deployment: apps/v1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

kind

A

POD, Service, ReplicaSet, Deployment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

metadata

A

a dictionary form, data about the object

metadata expected by kubernetes

labels - do as you wish

metadata:

name: my-app-pod

labels:

app: my-app
type: front-end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

spec

A

different for different objects

soec:

containers:

  • name: nginx-container
    image: nginx
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

cmd for creating a pod form pod.yml

A

kubectl create -f pod.yml

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

cmd list pods

A

kubectl get pods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

cmd show info about my-pod

A

kubectl describe pod my-pod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

yaml for postgress

A

apiVersion: v1
kind: Pod
metadata:
name: postgres
labels:
tier: db-tier
spec:
containers:
- name: postgres
image: postgres
env:
- name: POSTGRES_PASSWORD
value: mysecretpassword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

create pod my-nginx and look at it

A

kubectl run my-nginx –image=nginx

kubectl get pods

kubectl get pods -o wide

kubectl describe pod my-nginx

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Controllers

A

Processes that monitor kubernetes objects and respond accordingly. Control loops that watch the state of your cluster, then make or request changes where needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Replication Controller

A

It ensures that a specified number of pods run at all times.

Load balancing and scaling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Replication Controller vs Replica Set

A

Older vs newer, recommended technology.

RS can be used to monitor the existing pods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

rc-definition.yml

A

apiVersion:

kind:

metadata:

spec:

template:

pod-definition.yml - (apiVersion+kind)

replicas:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

create replication controller from my-rc.yaml

list replication controllers

list pods created

A

kubectl create -f my-rc.yaml

it creates x replicas based on a template

kubectl get replicationcontroller

kubectl get pods

rc-name..

rc-name..

rc-name..

17
Q

rs-definition.yaml

A

apiVersion: apps/v1

kind: ReplicaSet

metadata:

spec:

template:

replicas:

selector:

18
Q

selector rc vs rs

A

optional, takes labels / must have

selector:

matchLabels:

19
Q

How replica set knows what pods to monitor?

A

Labels used while creating a pod can be used as a filter

selector:

matchLabels:

key: value

20
Q

In replica set, do we need a templete if e.g. we create the rs to monitore existing pods?

A

Yes, in case one of them fails, rs will have a template to create a new one.

21
Q

Ho to scale pods definded in replica set.

A
  1. Update replicas in file and:

kubectl replace -f rs-definition.yaml

  1. kubectl scale –replicas=6 -f rs-definition
  2. kubectl scale –replicas=6 replicaset <kind> <metadata.name> [won't update the rs.yaml]</metadata.name></kind>
  3. scale based on load
22
Q

ReplicaSet spec’s 3 fields

A

spec:

template:

replicas:

selector:

23
Q

ReplicaSet template example

A

template:

metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: nginx
image: nginx

24
Q

ReplicaSet selector example

A

selector:
labels:
app: myapp

25
Q

modify definition for new-replica-set

A

kubectl edit replicaset new-replica-set

26
Q

update instances one aftr another

A

rolling updates

27
Q

What is a deployment?

A

Upgrade underlying instances seamlesly, usuing roling updates.

28
Q

create a deployment from my-deployment.yaml

list deployments

list replicaset

list pods

A

file as replica set, except for

kind: Deployment

kubectl create -f my-deployment.yaml

kubectl get deployments

kubectl get replicaset

(my-deployment-2424)

kubectl get pods

(my-deployment-37584)