Looking for the entire 7 part guide? Start at the Overview

In Kubernetes, a Deployment is a higher-level abstraction that manages the deployment and scaling of a set of Pods. Deployments provide a declarative way to manage the desired state of your application, making it easy to roll out updates and scale your application over time.

Here are some key features of Deployments in Kubernetes:

  • Deployments manage the desired state of your application: You can specify the desired state of your application (e.g., how many replicas of a Pod should be running, what image to use, etc.) in a Deployment configuration file. The Deployment controller then ensures that the actual state of your application matches the desired state.

  • Deployments provide a declarative way to manage updates: Deployments make it easy to roll out updates to your application in a controlled and automated way. You can specify a new version of your application in the Deployment configuration file, and the controller will automatically create new Pods with the updated version and gradually replace the old Pods.

  • Deployments support rolling updates and rollbacks: Deployments support rolling updates, which allow you to gradually replace old Pods with new ones without downtime. If a problem occurs during the update process, you can easily roll back to the previous version using the Deployment’s rollback feature.

  • Deployments can be scaled up or down: You can easily scale the number of replicas of a Pod up or down using the Deployment controller. This allows you to handle changes in traffic or load by adding or removing replicas as needed.

  • Deployments can be used with services: You can use a Service to provide a stable, load-balanced endpoint for your application. When you update the Deployment, the Service automatically updates to point to the new replicas.

Overall, Deployments are a powerful tool for managing the deployment and scaling of your application in Kubernetes. By providing a declarative way to manage the desired state of your application, and supporting rolling updates and rollbacks, Deployments make it easy to maintain the availability and reliability of your application over time, while providing a scalable and self-healing foundation for running containerized workloads in Kubernetes.

Here are some examples of running a deployment in Kubernetes using the command line interface (CLI):

Create a deployment:

1
$ kubectl create deployment nginx-deployment --image=nginx

This command will create a deployment named nginx-deployment and use the nginx image as the container image.

Get information about the deployment:

1
$ kubectl get deployment nginx-deployment

This command will display information about the nginx-deployment deployment, including the number of replicas, current status, and the image used.

Scale the deployment:

1
$ kubectl scale deployment nginx-deployment --replicas=3

This command will scale the nginx-deployment deployment to three replicas.

Update the deployment:

1
$ kubectl set image deployment/nginx-deployment nginx=nginx:1.19.10

This command will update the nginx-deployment deployment to use the nginx:1.19.10 image.

Rollback the deployment:

1
$ kubectl rollout undo deployment/nginx-deployment

This command will rollback the nginx-deployment deployment to the previous version.