The deployment runs multiple copies, or replicas, of your applications and replaces any that are unhealthy or have failed. This is how deployments ensure that at least one instance, if not more, of your application, is available to respond to requests.
How does a Kubernetes Deployment Work?
When you launch a deployment on a running Kubernetes cluster, you will use a tool known as the Kubernetes deployment controller to manage the process. The controller monitors the state of your cluster and can make or request changes as needed to move that cluster’s workloads to your desired state.
Each Kubernetes deployment uses what’s called a “pod template.” This template provides a specification that determines what the pods should look like, what application runs inside of the pod’s containers, and more.
A Kubernetes deployment ensures your clusters are running the desired number of pods and that these pods are available at all times. It also automatically replaces pods that fail or are evicted from their nodes.
You can update any deployment by making changes to the pod template specs. These changes will automatically trigger an update to the current state and create the new desired state, as outlined by the edited template specification.
An update works like this:
- The deployment triggers the update.
- New pods that match the desired state are started.
- Old pods are terminated as new pods become healthy.
- This process repeats until all outdated pods have been replaced. By default, Kubernetes ensures that at least 75% and no more than 125% of the desired number of pods are up at any given time.
In this scenario, old pods aren’t removed until the deployment has a sufficient number of new pods up and running. If you run into problems, deployment updates can be rolled back. You also can temporarily halt a deployment.
Deployments have a three-phase lifecycle. The progressing state means the deployment is at work, doing such tasks as bringing up pods or scaling them back. The completed state speaks for itself; all pods are running to the latest specification and old pods have been removed.
The third phase is known as the failed state. If your deployment is in this phase, it means it has run into issues that have prevented it from completing its specified tasks. These issues can include limit ranges, runtime errors or insufficient quotas or permissions, among other things.
There are various commands you can use to check the state of your Kubernetes deployment or to troubleshoot the cause of a failed state. You also can monitor a deployment’s ongoing progress.
The need for Kubernetes is essential in today’s digital world. You have apps. Users want to use them. You want to be sure they’re healthy and accessible. Using Kubernetes to deploy and manage your containerized workloads ensures resiliency and uptime for your digital assets.
We want to be sure you understand all that Kubernetes has to offer, so be sure to check out other blogs in our Kubernetes 101 series. Thanks for reading!