/
Kubernetes Introductory Exercises

Kubernetes Introductory Exercises

Exercise 1: Simple Deployment and Service

  1. Create a namespace named eks-exercise1.

  2. Deploy the official nginx Docker image with 2 replicas.

  3. Expose the deployment with a Service of type LoadBalancer so you can access the application externally.

  4. Verify that you can reach the nginx welcome page from a browser or curl command (i.e., check the external IP/endpoint).

Key Concepts: Namespaces, Deployments, Services (LoadBalancer).


Exercise 2: Rolling Updates

  1. In the same or a new namespace (e.g., eks-exercise2):

  2. Create a Deployment with nginx:1.21 using 3 replicas.

  3. Update the deployment image from nginx:1.21 to nginx:1.23 in a rolling fashion.

  4. Check how many Pods get updated at once; observe the rollout process.

Key Concepts: Rolling update strategy, zero downtime, checking rollout status.


Exercise 3: Manual Scaling and Horizontal Pod Autoscaler (HPA)

  1. Deploy an application of your choice (e.g., nginx) with 1 replica.

  2. Manually scale the replicas to 5.

  3. Enable Horizontal Pod Autoscaling:

    • Minimum 1 Pod

    • Maximum 10 Pods

    • Target CPU usage of 50%

  4. Generate load (optional, if you have a load testing tool) to observe Pods automatically scaling up.

Key Concepts: Manual scaling, HPA, cluster metrics (Metrics Server).


Exercise 4: Multi-Container Pod (Sidecar Pattern)

  1. Create a Pod manifest that runs two containers:

    • Container A: nginx

    • Container B: A small sidecar (e.g., busybox or a container that periodically logs to stdout).

  2. Verify both containers are running inside one Pod.

  3. Check logs for each container to ensure they work independently.

Key Concepts: Multi-container Pod, sidecar pattern, container logs.


Exercise 5: Resource Quotas and Limits

  1. Create a namespace called quota-namespace.

  2. Define a ResourceQuota that:

    • Limits the total number of Pods to, say, 5

    • Limits total CPU (e.g., 2 cores) and memory (e.g., 2Gi)

  3. Deploy an application requesting some CPU and memory resources to test if it respects the quota.

Key Concepts: Resource Quotas, requests/limits, cluster capacity planning.