Skip to content

Labs & Challenges β€” Linux, Docker & Kubernetes

Difficulty: Beginner-Intermediate Β· Estimated time: 1.5-2 hrs (all challenges)

Hands-on exercises to practice and reinforce your SRE/DevOps skills.


🐧 Linux Labs

Lab 1 β€” System Investigation

Goal: Identify the most CPU-hungry process and investigate its cause.

Steps: 1. SSH into a test Linux VM. 2. Run:

uptime
top
ps aux --sort=-%cpu | head
3. Find the PID of the top process and run:
strace -p <pid>
4. Write down what the process is doing.


Lab 2 β€” Disk Usage Triage

Goal: Find which directory is filling the disk.

Steps: 1. Simulate filling a disk:

fallocate -l 1G /tmp/filltest
2. Identify the largest directories:
du -sh /* | sort -h
3. Delete the test file and verify space is freed.


Lab 3 β€” Log Filtering

Goal: Extract only ERROR logs from a service.

Steps: 1. Create a sample log file:

echo -e "INFO start\nERROR fail1\nINFO running\nERROR fail2" > app.log
2. Filter ERROR lines:
grep "ERROR" app.log
3. Redirect to a new file error.log.


🐳 Docker Labs

Lab 4 β€” Build & Run a Simple App

Goal: Containerize a Python app and run it.

Steps: 1. Create app.py:

from flask import Flask
app = Flask(__name__)
@app.route("/")
def home():
    return "Hello from Docker!"
if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8080)
2. Create Dockerfile:
FROM python:3.12-slim
WORKDIR /app
COPY app.py .
RUN pip install flask
CMD ["python", "app.py"]
3. Build & run:
docker build -t hello:1.0 .
docker run -p 8080:8080 hello:1.0


Lab 5 β€” Using Volumes

Goal: Persist data between container restarts.

Steps: 1. Create a volume:

docker volume create appdata
2. Run container mounting volume:
docker run -it -v appdata:/data busybox sh
3. Inside container:
echo "persistent data" > /data/test.txt
4. Exit, remove container, start a new one, and verify file exists.


☸️ Kubernetes Labs

Lab 6 β€” Deploy an App

Goal: Deploy the hello Docker image to Kubernetes.

Steps: 1. Push image to registry (GHCR, Docker Hub). 2. Create deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
spec:
  replicas: 2
  selector:
    matchLabels:
      app: hello
  template:
    metadata:
      labels:
        app: hello
    spec:
      containers:
      - name: hello
        image: ghcr.io/<your-org>/hello:1.0
        ports:
        - containerPort: 8080
3. Apply:
kubectl apply -f deployment.yaml
kubectl get pods


Lab 7 β€” Add Probes

Goal: Add readiness & liveness probes.

Steps: 1. Edit container spec:

readinessProbe:
  httpGet:
    path: /
    port: 8080
  initialDelaySeconds: 5
livenessProbe:
  httpGet:
    path: /
    port: 8080
  initialDelaySeconds: 10
2. Re-apply manifest. 3. Check probe status:
kubectl describe pod <pod-name>


Lab 8 β€” Scale & Rollback

Goal: Practice scaling and rolling back a deployment.

Steps: 1. Scale:

kubectl scale deployment hello --replicas=5
kubectl get pods
2. Trigger a bad rollout (change to a broken image tag) and apply. 3. Rollback:
kubectl rollout undo deployment hello


βœ… Completion Checklist

  • [ ] Comfortable using Linux CLI for triage
  • [ ] Built & ran a Docker image
  • [ ] Deployed and managed an app in Kubernetes
  • [ ] Configured probes and scaled pods
  • [ ] Rolled back a bad deploy without downtime