What are Deployments in Kubernetes?

  • What Deployments are in Kubernetes
  • How we can create Deployment Objects in Kubernetes
  • How can we use kubectl to manage our Deployments?
  • Deployment Strategies

What Deployments are in Kubernetes

A Deployment in Kubernetes provides a layer of functionality around Pods and allows you to describe a desired state. They are a high-level abstraction that controls how we deploy and maintain a set of Pods.

How we can create Deployment Objects in Kubernetes

We can define our Kubernetes Deployment Objects using YAML. Let’s take a look at an example Deployment YAML file:

apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment
labels:
tier: frontend
app: nginx
spec:
selector:
matchLabels:
app: myapp
replicas: 3
template:
metadata:
name: nginx
labels:
app: myapp
spec:
containers:
- name: nginx
image: nginx

How can we use kubectl to manage our Deployments?

We can use kubectl to perform a variety of different operations on our Kubernetes Deployment Objects. Let’s start with creating a Deployment. We can do so by using the following command:

kubectl apply -f ourdeployment.yaml
kubectl create -f ourdeployment.yaml
kubectl get deployments
NAME              READY     UP-TO-DATE   AVAILABLE   AGE
myapp-deployment 0/3 0 0 1s
kubectl rollout status <name-of-deployment>
kubectl rollout history <name-of-deployment>
kubectl rollout undo <name-of-deployment>
kubectl scale deployment <name-of-deployment> --replicas=10
kubectl autoscale deployment --min=3 --max=10 --cpu-percent=70

Deployment Strategies

In our Kubernetes Deployments, we can choose the following strategies to replace our old Pods with the new ones that we define as part of our Deployment. This can be one of two types:

Conclusion

Hopefully this article has helped you understand the basics of Deployments in Kubernetes!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Will Velida

Will Velida

Customer Engineer at Microsoft working in the Fast Track for Azure team. GitHub: https://github.com/willvelida