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:
- Application Code
- Runtime Environment
- System Tools
- Libraries
- Dependencies
- Environment Variables
- Configuration Files
Key Benefits
- Fast Startup
- Lightweight
- Isolated from Other Containers
- Easily Replicable
- Portable Across Environments
- Efficient Resource Usage
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:
- Build Containers
- Package Applications
- Distribute Images
- Run Containers
How Docker Helps
- Defines containers using Dockerfile
- Builds Docker Images
- Runs Containers
- Publishes Images to Registries
?? 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
- Create Deployment YAML for NGINX container
- Kubernetes Scheduler assigns Pod to a Node
- Kubelet pulls Docker Image
- Container starts inside Pod
- Service exposes Pod to users
- If Pod crashes, Kubernetes restarts it automatically
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)
- Developer pushes code to GitHub/Azure Repos
- Pipeline triggers automatically
- Compile code
- Run unit tests
- Build Docker image
- Push image to ACR
Continuous Deployment (CD)
- Pull image from ACR
- Deploy to AKS
- Manage deployment via YAML or Helm
- Automate release process
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
- Prepare Spring Boot Application
- Create Dockerfile
- Push Code to Repository
- Create Azure Container Registry (ACR)
- Create Azure Kubernetes Service (AKS)
- Connect AKS to ACR
- Configure Azure Pipeline
- Build & Push Docker Image
- Deploy Image to AKS
- 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