Skip to content

Kubernetes Deployments

Based around "deployment defintion file"...

Get Deployments

kubectl get deployemnts.apps

Viewing / Describing

kubectl describe deployments.apps frontend-deployment

Deploying with apply

kubectl apply -f deployment-definition-1.yaml

Creating a Deployment Definition file

kubectl create deployment httpd-frontend --image=httpd:2.4-alpine

Note

The kind type in the YAML is case-sensitive and needs to be uppercase (e.g. Deployment vs deployment)

Sample question...

Create a new Deployment with the below attributes using your own deployment definition file

Name: httpd-frontend; Replicas: 3; Image: httpd:2.4-alpine

Answer

> kubectl create deployment httpd-frontend --image=httpd:2.4-alpine
> kubectl scale deployment --replicas=3 httpd-frontend
> kubectl get deployments.apps httpd-frontend

Edit Deployments

With deployment you can easily edit any field / property of the pod template. Since the pod template is a child of the deployment specification, with every chnage the deployment will automatically delete and create a new pod with the new changes. So if you are asked to edit a property of a pod part of the deployment you may do that simply by running the command:

kubectl edit deployment my-deployments