This topic is weighed 8% on exam
Understand Deployments and how to perform rolling updates and rollbacks.
- A Deployment is a higher-level resource meant for deploying applications and updating them declaratively, instead of doing it through a ReplicationController or a ReplicaSet, which are both considered lower-level concepts.
- Strategy Types
- Recreate: strategy causes all old pods to be deleted before the new ones are created. Use this strategy when your application doesn’t support running multiple versions in parallel and requires the old version to be stopped completely before the new one is started.
- RollingUpdate: strategy, on the other hand, removes old pods one by one, while adding new ones at the same time, keeping the application available throughout the whole process, and ensuring there’s no drop in its capacity to handle requests.
kubectl rollout status deployment DEPLOYMENT
kubectl rollout undo deployment DEPLOYMENT(undo last rollout)
kubectl rollout history deployment DEPLOYMENT
- Rollout tuning parameters
minReadySeconds- Minimum number of seconds for which a newly created pod should be read without any of its container crashing, for it to be considered available.
Know various ways to configure applications.
- jobs: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
- must set restartPolicy to Never or OnFailure
- CronJobs resource
- job is scheduled
- three ways to use
- filesystem - mount configmap into a pod
- environment variable - used to set env variable
- command-line argument - dynamic command line
- three ways to use
- environment variables in container
Know how to scale applications.
- use replicasets or higher level deployments
kubectl edit(replicas object)
Understand the primitives necessary to create a self-healing application.
- Use deployments (replicasets)
- Instead of using a ReplicaSet to run these types of pods, you create a StatefulSet resource, which is specifically tailored to applications where instances of the application must be treated as non-fungible individuals, with each one having a stable name and state.
- How does one run multiple replicas of a pod and have each pod use its own storage volume? ReplicaSets create exact copies (replicas) of a pod; therefore you can’t use them for these types of pods. What can you use? Stateful Sets
- When a stateful pod instance dies (or the node it’s running on fails), the pod instance needs to be resurrected on another node, but the new instance needs to get the same name, network identity, and state as the one it’s replacing. This is what happens when the pods are managed through a StatefulSet.
- A StatefulSet makes sure pods are rescheduled in such a way that they retain their identity and state.
- Each can have its own set of volumes—in other words, storage (and thus persistent state)—which differentiates it from its peers.