Logo

dev-resources.site

for different kinds of informations.

CKA Recap -- Deployment

Published at
1/5/2025
Categories
kubernetes
cka
deployment
rollout
Author
cheedge_lee
Categories
4 categories in total
kubernetes
open
cka
open
deployment
open
rollout
open
Author
11 person written this
cheedge_lee
open
CKA Recap -- Deployment

Deployment

Basic CMD

# Create
kubectl create deploy NAME --image=IMAGE --replica NUM
# Scale (or use kubectl edit)
kubectl scale deploy NAME --replicas NUM
# Change image of deploy
kubectl set image deployments/DP_NAME ContainerName=IMAGE
k set image deployments/apache httpd=httpd:alpine
Enter fullscreen mode Exit fullscreen mode

When using kubectl create cmd create the deployment, it will automatically add the same labels for both deployment and pods. So if you want to customize the label, it's better to print out --dry-run=client -oyaml the yaml file and have a check.

And if not clear the container name, can use following to find it

k get pod NAME -oyaml | grep -3 -i container
Enter fullscreen mode Exit fullscreen mode

Rollout

k rollout history deployment/DP_NAME
k rollout history deployment/DP_NAME --revision REV_NUM
k rollout undo deployment/DP_NAME --to-revision REV_NUM
k rollout status deployment DP_NAME
Enter fullscreen mode Exit fullscreen mode
controlplane $ k rollout history deployment video-app
deployment.apps/video-app 
REVISION  CHANGE-CAUSE
1         <none>
2         <none>
3         <none>
controlplane $ k rollout history deployment/video-app --revision 3
deployment.apps/video-app with revision #3
Pod Template:
  Labels:       app=video-app
        pod-template-hash=69648db755
  Containers:
   redis:
    Image:      redis:7.0.13
    Port:       <none>
    Host Port:  <none>
    Environment:        <none>
    Mounts:     <none>
  Volumes:      <none>
  Node-Selectors:       <none>
  Tolerations:  <none>
controlplane $ k rollout undo deployment/video-app --to-revision 3
deployment.apps/video-app skipped rollback (current template already matches revision 3)
Enter fullscreen mode Exit fullscreen mode

Rolling Strategy

.spec.strategy.rollingUpdate.Unavailable and .spec.strategy.rollingUpdate.maxSurge

  • Max Unavailable
    • unavailable during the update process.
  • Max Surge
    • specifies the maximum number of Pods that can be created over the desired number of Pods
 strategy:
   type: RollingUpdate
   rollingUpdate:
     maxSurge: 30%
     maxUnavailable: 45%
Enter fullscreen mode Exit fullscreen mode

.spec.strategy.type==Recreate, and we can also destroy all existing pods first then create the new pods.

 strategy:
   type: Recreate
Enter fullscreen mode Exit fullscreen mode
cka Article's
30 articles in total
Favicon
Turning Markdown into Learning: publishing a challenge on labs.iximiuz.com
Favicon
CKA Quick Check Points -- RBAC
Favicon
CKA Quick Check Points -- Network
Favicon
CKA Quick Check Points -- Logs & Configs
Favicon
CKA Recap -- Deployment
Favicon
ClusterIP vs. NodePort
Favicon
CKA Recap -- Ingress & NetworkPolicy
Favicon
Kubernets Storage Demos
Favicon
3. CKA Storage
Favicon
Why must a Kubernetes cluster have an odd number of nodes
Favicon
Understanding Pod Topology Spread Constraints in Kubernetes
Favicon
Deployments and Replica Sets in Kubernetes
Favicon
40 days of Kubernetes: Docker Fundamentals
Favicon
Understanding Kubernetes Pods and YAML Fundamentals
Favicon
Creating a Kubernetes Cluster with Kubeadm and Containerd: A Comprehensive Step-by-Step Guide
Favicon
Mastering Multi-Stage Builds in Docker 🚀
Favicon
Mastering Docker Fundamentals: The First Step in Becoming a Certified Kubernetes Administrator
Favicon
How I Passed the Certified Kubernetes Administrator (CKA) Exam and How You Can Too
Favicon
AWS EKS Ingress - Canary
Favicon
Certified Kubernetes Administrator (CKA) Prep.
Favicon
Certified Kubernetes Administrator (CKA) - Several Successful Story
Favicon
YouTube 13k Subscriber crossed! Exciting Giveaway
Favicon
How to Pass the Certified Kubernetes Administrator Examination
Favicon
'Kubernetes Complete Course In 10 Hours' – your ultimate beginner's guide to Kubernetes FREE!
Favicon
Kubernetes CKA Exam Question Bank .. 17 Questions with Complete Lab .. In 3 hours .. FREE!
Favicon
ROAD TO CKA [Certified Kubernetes Administrator ]-Core Concept- Pod(Day-7)
Favicon
ROAD TO CKA [Certified Kubernetes Administrator ]-Kubernetes Architecture(Day-4)
Favicon
Installing Kubernetes-1.27.0 in Ubuntu 22.04
Favicon
ROAD TO CKA [Certified Kubernetes Administrator ]-What Kubernetes is & is not?(Day-3)
Favicon
ROAD TO CKA [Certified Kubernetes Administrator ]-Core Concept- Control Plane/Master Node (Day-5)

Featured ones: