Deployments

Tell Kubernetes what you want and let it keep it that way.

A Kubernetes practice simulator runs inside your browser tab. It behaves like the real commands for what the lessons teach, and it is labelled as a simulation.

A deployment keeps pods running

A deployment describes what you want: which image, and how many copies. Kubernetes creates the pods and keeps that number running.

Each copy is called a replica. The pods get generated names that start with the deployment's name.

Example
kubectl create deployment web --image=nginx
kubectl get deployments
kubectl get pods

Deleted pods come back

If a pod that belongs to a deployment stops or is deleted, Kubernetes starts a new one to replace it. This is called self-healing.

To really stop the application you delete the deployment, not its pods.

Run the example and look at the pod list: the three replicas are all there.

Example
kubectl create deployment web --image=nginx --replicas=3
kubectl get pods

Your turn: a deployment

One command creates the deployment and its pods.

Practice task

Create a deployment named shop that runs the nginx image with 2 replicas.

Your answer is run and checked in the lesson. Create a free account to try it.

Your turn: stop an application

A deployment named old is running here with two pods.

Practice task

Stop the application old for good, so that none of its pods remain.

Your answer is run and checked in the lesson. Create a free account to try it.