Workloads Flashcards
What are workloads, what are they used for?
A Workload is a resource manages pods automatically, without a worload if a Node fails, all Pods on that Node without a workload will stop working until a new Pod is created manually.
What types of Workloads are there?
DeploymentSet, ReplicaSet, StatefulSet, DaemonSet, Job, CronJob
What is a Deployment?
Deployment is good for stateless application workload and initiate ReplicaSets to ensure there is always a number of pods running and also allows for the easy update of thoose pods. They also manage deployments and are able to rollback as well.
What is a ReplicaSet?
ReplicaSets ensure a workload keeps running with the desired number of pods. It also has the capability of scaling the replicas up or down.
What is a StatefulSet?
StatefulSet are good for applications that do require a record of state this is done bby using a PersistentVolume resource
What is a DaemonSet?
DaemonSet defines pods that provide node facilities a pod will be set per node that matches the specification on the DaemonSet
What is a Job and CronJob?
A Job defines tasks that run to completion, CronJobs will recurr on a schedule.
What are the issues with Pods, what resources help solving these issues?
Running an application in a single pod has 2 issues, first it represents a single point of failure and second pods lack failure tolerance, they won’t restart by themselves, to solve this ReplicaSets and DeploymentSets are used.
Will this manifest for a Deployment work?
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-cache
labels:
app: app-cache
spec:
replicas: 4
selector:
matchLabels:
app: app-cache
template:
metadata:
labels:
app: app-data
spec:
containers:
- name: memcached
image: memcached:1.6.8
No it will not, labels on Delpoyment manifests need to be the same both on the selector as well as on the template. So the app label under spec.selector.matchLabels needs to match the label under spec.template.metadata.labels
How would you update the image of a deployment running an nginx image “nginx:1.16.0” to image “nginx:1.17.0”?
kubectl set image deployment a-deploy nginx=nginx:1.17.0 –record
How would you check the updates that have been done for a particular deployment “a-deploy”?
kubectl rollout history deployment a-deploy
How would you check for the status of a rollout for deployment a-deploy?
kubectl rollout status deployment a-deploy
How would you scale deployment “a-deploy” to have 5 replicas
kubectl scale deployment a-deploy –replicas 5
How would you set a hpa to autoscale a-deploy between 3 and 5 replicas with a target cpu percentage of 80
kubectl autoscale deployment a-deploy –cpu-percent 80 –min 3 –max 5
Whould a deployment with this container template be able to use hpa?
template:
spec:
containers:
- name: memcached
image: nginx
No it wouldn’t, the container must define resource requests for hpa to be appliable