How to create a deployment
Kubernetes Deployment Guide: Learn How Deployments Work
Discover how to create a deployment and what operations can be performed such as setting up an image and scaling a deployment.
In this video, we'll be creating a deployment and going through some of the operations we can perform. Let's start by creating a deployment using the
kubectl create deployment demo --image=nginx --replicas=3 --port=80 command. Our deployment is created, and we can verify it through
kubectl get deploy. We can see it's rolling out, and we can check the status using the
kubectl rollout status deployment demo command. We can see that it has successfully rolled out; as a result, we should have three pods running. With the
kubectl get pods command, we can see the three pods with the nginx image running.
Scaling a kubernetes deployment
Another thing that can be done is we can scale the deployment. For that, use the
kubectl scale deployment demo --replicas=5. We can see that it has been scaled. Now, if we see, we should have five pods, two of which are in ContainerCreating, which is perfectly fine. So we have five pods, and our desired state has been changed to 5, and if we use the
kubectl get rs command, we can see it has been changed to 5.
That's pretty much about the deployment and what you can do. You can scale the deployment, edit the deployment, and edit the deployment using kubectl edit deploy and the demo command. It'll open the YAML. You can insert and change the image. That also can be done. You can also delete the deployment using the
kubectl delete deployment demo command, and if you now use
kubectl get pods, you can see that they all are in a terminating state. There'll be a grace period if it's serving traffic. There will be a 30 seconds grace period. If they are serving traffic, they'll be in terminating states, and after that, they'll be removed. That's all about deployment and how you can create and do some operations on it. Thank you for watching, see you in the next lecture.