Kubernetes: Deployments Workload

Resource type alias deploy = deployment = deployments

Create deployments workload with command line:

kubectl create deploy <deployment_name> --image=<image1_name>,<image2_name>
kubectl create deployment <deployment_name> --image=<image1_name>,<image2_name>
kubectl create deployments <deployment_name> --image=<image1_name>,<image2_name>

Create deployments workload using YAML file:

apiVersion: apps/v1
kind: Deployment
metadata:
  # Unique key of the Deployment instance
  name: deployment-example
spec:
  # 3 Pods should exist at all times.
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        # Apply this label to pods and default
        # the Deployment label selector to this value
        app: nginx
    spec:
      containers:
      - name: nginx
        # Run this image
        image: nginx:1.14

Edit deployments workload:

kubectl edit deploy/<deployment_name>
kubectl edit deployment/<deployment_name>
kubectl edit deployments/<deployment_name>

Delete deployments workload:

kubectl delete deploy/<deployment_name>
kubectl delete deployment/<deployment_name>
kubectl delete deployments/<deployment_name>

Scale deployments workload:

kubectl scale --replicas=<target_replica_number> deployments/<deployment_name>

Update container image:

kubectl set image deployments/<deployment_name> \
	<container_name>=<new_image_name>:<new_image_tag> \
    --record

Check update status

kubectl rollout status deployments/<deployment_name>

Check update history

kubectl rollout history deployments/<deployment_name>

Check update history based on revision

kubectl rollout history deployments/<deployment_name> --revision=<revision_id>

Undo the updates

kubectl rollout undo deployments/<deployment_name>

References:


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *