Kubernetes Deployments
Deployments represent a group of multiple, identical Pods with no distinctive identities. A preparation runs multiple replicas of your application and mechanically replaces any instances that fail or become unresponsive. During this method, Deployments facilitate make sure that one or a lot of instances of your application are offered to serve user requests. Preparations are managed by the Kubernetes Deployment controller.
Changing the Deployment
Updating a deployment − The user can update the ongoing deployment before it is completed.
Deleting a deployment − The user can delete the deployment by deleting it before it is completed.
Rollback a deployment − We can roll back the deployment or the deployment in progress.
Creating a Deployment
Find following Deployment example. It creates a ReplicaSet to bring up three nginx Pods:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Run below command to update the deployment
kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml
Run kubectl get deployments command to check if the Deployment was created or not. If the Deployment is still in process then the output is similar to the following:
NAME READY UP-TO-DATE AVAILABLE AGE nginx-deployment 0/3 0 0 1s
To see the Deployment rollout status, run.
kubectl rollout status deployment.v1.apps/nginx-deployment.
The output is similar to this:
Waiting for rollout to finish: 2 out of 3 new replicas have been updated... deployment.apps/nginx-deployment successfully rolled out
Run the kubectl deployments again a few seconds later. The output is similar to this:
NAME READY UP-TO-DATE AVAILABLE AGE nginx-deployment 3/3 3 3 18s