Docker, Kubernetes & CI/CD Complete Notes


1. Overview of Cloud Concepts

1.1 Container

A Container is a lightweight, portable, and self-sufficient software unit that includes:

Key Benefits

Important:
Containers share the Host Operating System Kernel but remain isolated from each other.

Popular Container Runtime

Docker

Example

docker run nginx

Starts an NGINX web server inside a container.


1.2 Docker

Docker is a platform and toolset used to:

How Docker Helps

?? Docker = Standard Tool for Creating and Running Containers

Docker Components

Component Description
Dockerfile Instructions used to build Docker Images
Docker Image Immutable packaged application snapshot
Docker Container Running instance of an Image
Docker Hub Public Registry for Docker Images
Private Registry Enterprise image repository (ACR, ECR, GAR)

2. Kubernetes Container Orchestration

How It All Comes Together

Deployment Flow

Kubernetes Components

Term Meaning Role
Docker Container Platform Containerization Tool
Container Packaged Application Application Runtime
Pod One or More Containers Smallest Deployable Unit
Node Worker Machine Runs Pods
Cluster Group of Nodes Runs Workloads
Kubernetes Orchestration Platform Deployment, Scaling, Recovery

3. Real-World Example: Spring Boot on Kubernetes

Step 1: Develop Application

CustomerService Spring Boot Application

Step 2: Containerize Application

Create Dockerfile

Step 3: Build Docker Image

docker build -t myacr.azurecr.io/customer-service:1.0 .

Step 4: Push Image to Azure Container Registry (ACR)

az acr login --name myacr

docker push myacr.azurecr.io/customer-service:1.0

Step 5: Kubernetes Deployment YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: customer-service

spec:
  replicas: 2

  selector:
    matchLabels:
      app: customer-service

  template:
    metadata:
      labels:
        app: customer-service

    spec:
      containers:
      - name: customer-service
        image: myacr.azurecr.io/customer-service:1.0

        ports:
        - containerPort: 8080

Step 6: Kubernetes Service YAML

apiVersion: v1
kind: Service

metadata:
  name: customer-service

spec:
  type: LoadBalancer

  selector:
    app: customer-service

  ports:
  - port: 80
    targetPort: 8080

Step 7: Deploy to AKS

kubectl apply -f deployment.yaml

kubectl apply -f service.yaml

4. What Kubernetes Does For You

Task Handled By
Run Multiple Containers Pods
Restart Failed Containers ReplicaSet
Load Balance Traffic Service
Zero Downtime Deployments Deployment
Health Monitoring & Scaling Metrics Server + HPA

5. CI/CD Overview

Continuous Integration (CI)

Continuous Deployment (CD)


6. Azure DevOps CI/CD Architecture

Developer
    ?
Azure Repos / GitHub
    ?
Azure Pipeline (CI)
    ?
Maven Build
    ?
JUnit Tests
    ?
Docker Build
    ?
Azure Container Registry (ACR)
    ?
Azure Pipeline (CD)
    ?
Azure Kubernetes Service (AKS)

7. Spring Boot + AKS CI/CD Steps

  1. Prepare Spring Boot Application
  2. Create Dockerfile
  3. Push Code to Repository
  4. Create Azure Container Registry (ACR)
  5. Create Azure Kubernetes Service (AKS)
  6. Connect AKS to ACR
  7. Configure Azure Pipeline
  8. Build & Push Docker Image
  9. Deploy Image to AKS
  10. Verify Deployment

Packaging Module Structure

packager/

 +-- Dockerfile
 +-- docker-entrypoint.sh
 +-- deployment files

Dockerfile and docker-entrypoint.sh are used to package the Spring Boot application and push the image to ACR.


8. Kubernetes Deployment Files

File Purpose
ingress-service.yaml Manages external access to services
deployment-ums-adobe-collection.yaml Deploys and scales Pods
service-ums-adobe-collection.yaml Exposes Pods internally or externally
cloudbuild.yaml CI/CD build configuration

9. Verify Deployment

kubectl get pods

kubectl get services

kubectl get deployments

kubectl get ingress

10. Azure Services Used in CI/CD

Component Purpose
Azure Repos Source Code Repository
Azure Pipelines CI/CD Automation
Azure Container Registry Docker Image Storage
AKS Kubernetes Cluster
Service Connection Authentication to Azure Resources
Helm Kubernetes Package Management

Optional Services

Service Purpose
Azure Key Vault Secrets Management
Azure Monitor Monitoring & Diagnostics
Azure Boards Agile Planning
Azure Artifacts Maven Package Repository

11. Deployment Strategies

Strategy Downtime Rollback Complexity Cost Best Use Case Tools Required
Recreate Yes Easy Low Low Simple Applications Native Kubernetes
Rolling Update No Medium Low Low Most Stateless Applications Native Kubernetes
Blue-Green No Very Easy Medium Medium Production Switchovers Ingress + CI/CD
Canary No Easy High Medium/High Gradual Rollouts Istio, Argo Rollouts
A/B Testing No Medium High Medium/High User Experiments Feature Flags, Istio
Shadow / Mirroring No Not Required High High Performance Testing Service Mesh

12. Quick Interview Summary

Docker ? Packages applications into containers.

Kubernetes ? Manages, scales, and orchestrates containers.

ACR ? Stores Docker images.

AKS ? Runs Kubernetes workloads on Azure.

CI ? Build, Test, Package.

CD ? Deploy and Release.

Most Common Production Flow:
Git ? Azure Pipeline ? Maven Build ? Docker Image ? ACR ? AKS ? Ingress ? Users