Deployment - Sandeep-K-Khandelwal/CKAD GitHub Wiki

The deployment provides us with capabilities to upgrade the underlying instances seamlessly using rolling updates, undo changes, and pause and resume changes to deployments.

The contents of the deployment-definition file are exactly similar to the ReplicaSet definition file, except for the kind, which is now going to be Deployment.

Commands

  • kubectl create -f deployment-definition.yml - Create Deployment based on the definition file
  • kubectl get deployments - Get the list of deployments
  • kubectl delete deployment <deployment_name> - Delete the specified deployment. It also deletes the underlying ReplicaSet and Pods
  • kubectl describe deployment <deployment_name> - Get details about the specified deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-deployment
  labels:
    app: myapp
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: nginx-container
        image: nginx