Kubernetes Concepts Flashcards
How are Yaml files used in Kubernetes?
- used as inputs for creation of objects such as pods/deployments/replicas/services
What are the always existing top-level fields in a object-definition Yaml file? (top/root-level properties, required)
apiVersion: kind: metadata: spec:
What is the apiVersion?
- Version of the Kubernetes API used for creating objects
Name a few possible kind/version combinations?
Pod / v1
Service / v1
ReplicaSet / apps/v1
Deployment / apps/v1
What describes the kind-property?
What kind of object are we trying to create?
- Pod
- Service
- ReplicaSet
- Service
- Deployment
- etc
What is the metadata property?
Data about the object.
Like name, labels etc
Form of a dictionary
metadata: name: xxx labels: app: myapp
What can be part of the metadata property? What is the difference in that to labels?
- only name or labels or other specifics exptected by Kubernetes
- labels can have any free-chosen key-value pairs
What is part of the spec property?
- specification/additional information of the object to be created
- different for different objects
- Dictionary
spec: containers (list/array): - name: nginx-container image: nginx
How do we trigger the creation of an object from a .yaml file?
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 can the ‘kubectl apply -f’ command be used?
- similiar to ‘kubectl create -f command’
What does the ‘spec’ property of the ‘pod’ kind look like?
spec: containers: - name: nginx image: nginx
Differten look for other kinds
How does one define an environemnt variable for a pod?
spec: containers: - name: postgres image: postgres env: - name: POSTGRES_PASSWORD value: mysecretpassword
What does the READY column in the output of the kubectl get pods command indicate?
Running containers in pod / total containers in pod
What does ‘kubectl run redis –image=redis123 –dry-run=client -o yaml’ do?
-previews a specific image on the cluster and gives the output in a yaml format
What does the suffix ‘> redis.yaml’ do the command ‘kubectl run redis –image=redis123 –dry-run=client -o yaml’?
It pipes the yaml result of the command into its own file, creating the file
What are Controllers?
- brain behind Kubernetes - the processes that monitor Kubernetes objects and respond accordingly
In connection with work loads, why do we need a replication controller/replica set?
- to create multiple pods and share the workload across them
What does the replication controller/replica set do?
- 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 far does a replication controller/replica set span?
- spans across multiple nodes in the cluster
In what connection to replication controller and replica set stand?
- same purpose but are not the same
- replica set replaces replication controller