Pod Design Flashcards
What is the purpose of a label?
Labels can be used to organize and to select subsets of objects. Labels are key/value pairs that are attached to objects, such as pods.
What is the purpose of a selector?
Via a label selector, the client/user can identify a set of objects. They allow kubernetes objects to be filtered by their label.
In a Pod definition, how are labels applied?
metadata: labels: key1: value1 key2: value2
What is the imperative command to select a pod with a label? (e.g. label foo with value bar)
kubectl get po --selector foo=bar
In a ReplicaSet definition, how are the pods to be managed by the ReplicaSet selected? (e.g. pods with label foo with value bar)
spec: selector: matchLabels: foo: bar
In a Service definition, how are the pods to be exposed by the Service selected? (e.g. pods with label foo and value bar)
spec: selector: foo: bar
What is the purpose of annotations?
You can use Kubernetes annotations to attach arbitrary non-identifying metadata to objects
In definition files, how are annotations applied to Kubernetes objects? (e.g. an annotation with key foo and value bar)
metadata: annotations: foo: bar
What is the imperative command for determining the status of a rollout? (e.g. for deployment named dep1)
kubectl rollout status deployment/dep1
What is the imperative command for finding the history of a rollout? (e.g. for a deployment named dep1)
kubectl rollout history deployment/dep1
What are the types of deployment strategy?
- recreate (all are destroyed before new are created)
- rolling (objects are destroyed and created one at a time)
What is the default deployment strategy?
rolling
What is the imperative command for changing the image of a single container deployment? (e.g. deployment named dep1 with an nginx image being updated to nginx:1.9.1)
kubectl set image deployment/dep1 nginx=nginx:1.9.1
What is the imperative command for rolling back a deployment? (e.g. deployment named dep1)
kubectl rollout undo deployment/dep1
What is the imperative command for getting the history of a particular rollout revision? (e.g. for the second revision of a deployment named dep1)
kubectl rollout history deployment/dep1 --revision=2
What is the purpose of a job?
A Job creates one or more Pods and ensures that a specified number of them successfully terminate. They typically carry out a specific task and then finish.
Why is a Pod (with default restart policy value) not suitable for a one-off task?
A one-off task will eventually exit and the Pod will move into a completed state. Kubernetes will attempt to restart a pod once it has completed. Restarting, and re-undertaking the task, is not desired.
In the Pod definition, how is a OnFailure restart policy applied?
spec: restartPolicy: OnFailure
What are different types of restart policy?
- Always
- Never
- OnFailure
What is the apiVersion of a Job?
batch/v1
What is the imperative command to get a list of jobs
kubectl get jobs
How do you retrieve the output of a job? (e.g. for a job named job1)
kubectl logs job1
In the Job definition, how are multiple pods run? (e.g. run the pod 3 times successfully)
spec: completions: 3
In the Job definition, how can jobs be run in parallel? (e.g. run 3 pods in parallel)
spec: parallelism: 3
What is the purpose of a CronJob?
A CronJob creates Jobs on a repeating schedule.
What is the apiVersion of a CronJob?
batch/v1beta
What are the two required spec properties of a CronJob?
spec: schedule: "" jobTemplate: {}
What are the five properties of the CronJob schedule (in order)?
- minute (0 - 59)
- hour (0 - 23)
- day of the month (1 - 31)
- month (1 - 12)
- day of the week (0 - 6). Sunday to Saturday
What is the imperative command to list all the CronJobs?
kubectl get cronjobs