POD Design - Jobs and Cron Jobs Flashcards
What types of workloads do exist for instance?
- application
- web
- database
- reporting
- batch-processing
- analytics
How are types of workloades abstractly different to each other?
- some need to keep on working
- some finish after a certain task / set of tasks
What is the default behavior of Kubernetes in terms of pod lifecycle?
Wants to keep the pods running.
If a pods is in Status Completed it gets restarted, as often till a certain threshold is reached
What specifies the Restart behavior of Kubernetes pods?
restartPolicy - by default set to Always
spec: containers: - image name command restartPolicy: Always
What are valid options for restartPolicy of a pod?
- Always
- Never
- OnFailure
What is special about i.e batch-workloads?
- parallel working through a set of tasks
- we need a manager that makes sure, the work is done successfully
What is the difference between a ReplicaSet and Jobs?
- ReplicaSet wants to keep the pods up running all the time
- Jobs keep pods running till completion
How do we create a job?
job-definition.yaml:
~~~
apiVersion: batch/v1
kind: Job
metadata:
name: math-add-job
spec:
completions: 3
template:
spec:
containers:
- name:
image:
command:
restartPolicy: Never
~~~
Under template has a pod definition spec
kubectl create -f
kubectl get jobs
How can you see the standard output of container?
kubectl logs pod-name pot.container-name
What does the ‘completed’ addition change for a job?
- specified the amount of pods needed to be in Status Completed to see job as completed
How are pods in jobs by default created?
one after the other
How can we specify that a jobs runs pods in parallel?
apiVersion: batch/v1 kind: Job metadata: name: math-add-job spec: completions: 3 parallelism: 3 template: spec: containers: - name: image: command: restartPolicy: Never
What are CronJobs?
- a job that can be scheduled and run periodically
- for instance a job that creates a report and sends an email
How does a cronjob yaml look like?
apiVersion: batch/v1 kind: CronJob metadata: name: reporting-cronjob spec: schedule "*/1 * * * *" jobTemplate: spec: completions: 3 parallelism: 3 template: spec: containers: - image: reporting-tool name: reporting-tool restartingPolicy: Never
How form has the schedule spec of a CronJob?
- minute
- hour
- day of the month
- month
- day of the week