Deployment
Imperative commands for deployment
Tips and Tricks
For simulated Practice problems visit KillerCoda.
-
create a deployment with
nginx:1.18.0
image with2
replicas, in the default namespace, expose port80
on the containers.Solution
#generate yaml file k create deploy nginx --image=nginx:1.18.0 --replicas=2 --dry-run=client -o yaml > deploy.yaml #update pod.yaml apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: nginx name: nginx spec: replicas: 2 selector: matchLabels: app: nginx strategy: {} template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: nginx:1.18.0 name: nginx ports: - containerPort: 80 resources: {} status: {} # create deployment k create -f deploy.yaml
-
Solution
#update the deployment k edit deploy nginx # then edit the container image OR # set new image on the deployment k set image deploy nginx nginx=nginx:1.19.8
-
Solution
#update the deployment k rollout undo deploy nginx # then edit the container image OR # set new image on the deployment k set image deploy nginx nginx=nginx:1.18.0
-
Solution
#update the replicas k scale deploy nginx --replicas=5 OR # edit the deploy & set the replicas k edit deploy nginx
-
Solution
#update the replicas k autoscale deploy nginx --min=5 --max=10 # check the horizontal auto scaler k get hpa nginx