Kubernetes Concepts Flashcards

1
Q

How are Yaml files used in Kubernetes?

A
  • used as inputs for creation of objects such as pods/deployments/replicas/services
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the always existing top-level fields in a object-definition Yaml file? (top/root-level properties, required)

A
apiVersion:
kind:
metadata:

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

What is the apiVersion?

A
  • Version of the Kubernetes API used for creating objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Name a few possible kind/version combinations?

A

Pod / v1
Service / v1
ReplicaSet / apps/v1
Deployment / apps/v1

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

What describes the kind-property?

A

What kind of object are we trying to create?
- Pod
- Service
- ReplicaSet
- Service
- Deployment
- etc

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

What is the metadata property?

A

Data about the object.
Like name, labels etc
Form of a dictionary

metadata:
  name: xxx
	labels: 
	   app: myapp
	
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What can be part of the metadata property? What is the difference in that to labels?

A
  • only name or labels or other specifics exptected by Kubernetes
  • labels can have any free-chosen key-value pairs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is part of the spec property?

A
  • specification/additional information of the object to be created
  • different for different objects
  • Dictionary
spec: 
  containers (list/array):
	   - name: nginx-container
	     image: nginx
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do we trigger the creation of an object from a .yaml file?

A

kubectl create -f pod-definition.yaml

-f references to files
multiple files can be added
-f file1 -f file2

kubectl create -f FILENAME [flags]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can the ‘kubectl apply -f’ command be used?

A
  • similiar to ‘kubectl create -f command’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the ‘spec’ property of the ‘pod’ kind look like?

A
spec:
  containers:
	  - name: nginx
	    image: nginx

Differten look for other kinds

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

How does one define an environemnt variable for a pod?

A
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
13
Q

What does the READY column in the output of the kubectl get pods command indicate?

A

Running containers in pod / total containers in pod

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

What does ‘kubectl run redis –image=redis123 –dry-run=client -o yaml’ do?

A

-previews a specific image on the cluster and gives the output in a yaml format

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

What does the suffix ‘> redis.yaml’ do the command ‘kubectl run redis –image=redis123 –dry-run=client -o yaml’?

A

It pipes the yaml result of the command into its own file, creating the file

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

What are Controllers?

A
  • brain behind Kubernetes - the processes that monitor Kubernetes objects and respond accordingly
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

In connection with work loads, why do we need a replication controller/replica set?

A
  • to create multiple pods and share the workload across them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What does the replication controller/replica set do?

A
  • helps us run multiple instances of a single pot in the Kubernetes Cluster
  • providing high availability
  • even with a single pod the controller helps by automatically bringing up a new container instance if the old one fails
  • ensures that the specified number of pods is running at all times
  • scales with high demand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How far does a replication controller/replica set span?

A
  • spans across multiple nodes in the cluster
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

In what connection to replication controller and replica set stand?

A
  • same purpose but are not the same
  • replica set replaces replication controller
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do we create a replication controller?

A
  • yaml definition file
apiVersion: v1
kind: ReplicationController
metadata: 
  name: myapp-rc
	labels:
	  app: myapp
		type: frontend
spec:
  template:
	  metadata:
		  name: myapp-pod
			labels:
			  app: myapp
				type: frontend
		spec:
		  containers:
			  - name: nginx-container
			    image: nginx
	replicas: 3
22
Q

How is the spec of a replication controller set up?

A
  • nested yaml file
  • includes a template with the spec of the pod to be replicated, without apiVersion and kind
  • includes replicas with the needed number of pod-replicas
23
Q

With what command can we get more information about replication controllers?

A

kubectl get replicationcontroller

24
Q

What hint does a pod give about the replicationController used to create it?

A

name starts with the metadata name of the replicationController used

25
Q

How does the replicaSet Yaml look?

A
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: myapp-replicaset
	labels:
	  app: myapp
		type: front-end
	
	spec:
	  template:
		  metadata:
			...
			spec:
			  containers:
				...
  replicas: 3
	(same column as replicas) selector:
	    matchLabels:
			  type: front-end
26
Q

What are the differences in the yaml file between replicaSet and replicationController?

A

apiVersion: apps/v1 vs. v1
kind: ReplicaSet vs. ReplicationController

+ ReplicaSet has additional ‘selector’

27
Q

Why does the ReplicaSet have a selector-property in the spec?

A
  • because replicaSet can also manage pods that were not creates as part of the replica set creation
  • previously created pods with the label selected under selector will also be taken into consideration when creating replicas
28
Q

Why do we label our objects in Kubernetes?

A

We can use labels to monitor a certain selection of resources.

For instance with the ReplicaSet

29
Q

What is a ReplicaSet gonna do, when even before the replicaSet is created the number of correctly labeled pods is higher then the needed number of pods?

A
  • no new instances of pods are going to be created
30
Q

How do we update a ReplicaSet yaml if we want to increase the number of pods?

A

Multiple ways:
- increasing the number under ‘replicas’ to the needed amount, then run ‘kubectl replace -f filename’
- run the command ‘kubectl scale –replicas=6 -f replicaset-definition.yaml’ OR ‘kubectl scale –replicas=6 TYPE NAME’ (kubectl scale –replicas=6 replicaset myapp-replicaset)
- Using the file name as input will NOT increase the number of replicas in the original yaml file

31
Q

In a ReplicaSet how are the selector and the template metadata connected?

A

The label in the selector and in the pod-definition need to be the same.
The replicaSet selector needs to select the pods, created by the set.

32
Q

What happens, when more pods exist under a label, managed by a replicaSet, then there should be?

A
  • the pod that was supposed to be created is terminated
33
Q

What does the command ‘kubectl edit replicaset myapp-replicaset’ do and what is special about it?

A
  • it opens up the specified yaml file to be changed
  • the shown file is a in-memory copy NOT the original, changes are not persisted but only applied to the current running instance of that file
34
Q

What are rolling updates? What are they used for?

A
  • updating pod-instances one after the other
  • used, so that the user experience is not negatively impacted
35
Q

What does a Deployment enable?

A

Gives the capability to:
- upgrade the underlying instances seamlessly using rolling updates
- pause the environment, so that new commands are not immediately applied
- resume a deployment
- rollback recent updates/changes

36
Q

How does the Deployment.Yaml look like?

A

Looks like the ReplicaSet Yaml, except for ‘kind’ which is ‘Deployment’

37
Q

What does the command ‘kubectl get all’ do?

A

Shows all created Kubernetes objects

38
Q

What does the command ‘kubectl create deployment –help’ do?

A

Shows all possible follow ups and exmpales for commands

39
Q

How does the Deployment rollout process / update go?

A
  • deployment gets created
  • created deployment triggers a new rollout
  • the new rollout creates a new deployment revision (revision 1)
  • when the application is upgraded/container version is updated a new rollout is triggered and a new deployment revision is created (revision 2)
  • enables rollback if necessary
40
Q

With what command can we see the status of the rollout?

A

‘kubectl rollout status deployment/myapp-deployment’

41
Q

With what command can we see the history of a rollout?

A

‘kubectl rollout history deployment/myapp-deployment’

42
Q

What kind of Deployment Strategies exist?

A
  1. Recreate Strategy (Not default): First destroy all instances and then deploy all again, updated (application inaccessible due to downtime)
  2. Rolling Update Strategy (default): Take down the older version and bring up the new one, one by one. Seamless deployment
43
Q

How are the different Deployment strategies visible?

A
  • in details from ‘kubectl describe deployment xxx’
  • Recreate: scales down to 0 and then back up to before value
  • RollingUpdate: scales one replicaset up and another one down at the same time, step by step
43
Q

How do we update a deployment?

A

Several ways,
- changes to file and then ‘kubectl apply -f deployment-definition.yaml’
- kubectl set image deployment/myapp-deployment nginx-containter=nginx:1.9.1 (but then the yaml has a different configuration)

44
Q

How does a Deployment Upgrade work?

A
  • newly created deployment creates a new replicaSet automatically, this then creates the number of pods
  • when upgraded, a new replicaSet is created
  • then is scales up the new replicaSet, while simultaneaosly scaling down the older replicaSet
45
Q

How can we rollback a rollout?

A

‘kubectl rollout undo deployment/myapp-deployment

46
Q

What does the option ‘–record’ do when added to commands like ‘kubectl create -f deployment.yaml’

A
  • instructs Kubernetes to record the cause for change
  • currently deprecated
47
Q

How can you specify the version of an image in the yaml file?

A

image: nginx:1.18

48
Q

With what command do you run a sh-script?

A

sh nameOfFile

49
Q

How does one set an alias in Linux?

A

alias k=’kubernetes’

50
Q
A