Hands-on Lab

#Lab: Kubernetes Deployment

Deploy an application to Kubernetes.

#🎯 Objectives

  • Create deployment and service
  • Scale and update application
  • Configure health checks

#Setup (minikube)

bash
minikube start

#Task 1: Create Deployment

yaml
1# deployment.yaml
2apiVersion: apps/v1
3kind: Deployment
4metadata:
5  name: myapp
6spec:
7  replicas: 3
8  selector:
9    matchLabels:
10      app: myapp
11  template:
12    metadata:
13      labels:
14        app: myapp
15    spec:
16      containers:
17      - name: myapp
18        image: nginx:1.25
19        ports:
20        - containerPort: 80
bash
kubectl apply -f deployment.yaml

#Task 2: Expose Service

yaml
1# service.yaml
2apiVersion: v1
3kind: Service
4metadata:
5  name: myapp-service
6spec:
7  selector:
8    app: myapp
9  ports:
10  - port: 80
11  type: NodePort
bash
kubectl apply -f service.yaml
minikube service myapp-service

#✅ Success Criteria

  • 3 pods running
  • Service accessible
  • Can scale pods