DevOps Classroom notes 02/Jul/2026

Deployments

  • In Reality we have an application which we containerize
  • we need to deploy this application
  • I.e. when we get a newer version of application we need to delete and recreate replica sets
  • in enterprise cases, we might need the following options
    • Capability to move to next version with minimum or no downtime
    • If the newer version is not working or having issues quickly rolling back to previous version.
  • Refer Here for official docs
  • Deployment strategies
    • recreate: will remove all older versions and recreates a new version
    • rollingUpdate: we can define
      • maxSurge: maximum number or percentage of pods which can be created beyond max number (default => 25%)
      • maxUnavailable: maximum number of pods or percentage that can be unavailable during deployment (default => 25%)

Experiment

  • Lets create a deployment with 3 nginx pods (consider this version 1)
  • Then we will simulate a newer release by changing the image to httpd
  • note: i will use service here, which can be ignored by you for todays
  • First version of yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ex1
  labels:
    app: web
    env: dev
spec:
  replicas: 4
  minReadySeconds: 5
  selector:
    matchLabels:
      app: web
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
  template:
    metadata:
      labels:
        app: web
        version: v1
    spec:
      containers:
        - image: nginx
          name: web
          ports:
            - containerPort: 80
              protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: ex1-nodeport
spec:
  type: NodePort
  selector:
    app: web
  ports:
    - name: http
      protocol: TCP
      port: 80          # Service Port
      targetPort: 80    # Container Port
      nodePort: 30080   # NodePort (must be in the allowed range)   

  • With deployments, daemeonsets and statefulsets we can use kubectl rollout
  • Now execute rollout commands such as history and status
  • Now make changes in the yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ex1
  labels:
    app: web
    env: dev
spec:
  replicas: 4
  minReadySeconds: 5
  selector:
    matchLabels:
      app: web
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
  template:
    metadata:
      labels:
        app: web
        version: v1.1
    spec:
      containers:
        - image: httpd
          name: web
          ports:
            - containerPort: 80
              protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: ex1-nodeport
spec:
  type: NodePort
  selector:
    app: web
  ports:
    - name: http
      protocol: TCP
      port: 80          # Service Port
      targetPort: 80    # Container Port
      nodePort: 30080   # NodePort (must be in the allowed range)  

Phippy goes to zoo

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%