Kubernetes Introductory Exercises
Exercise 1: Simple Deployment and Service
Create a namespace named
eks-exercise1
.Deploy the official
nginx
Docker image with 2 replicas.Expose the deployment with a Service of type
LoadBalancer
so you can access the application externally.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
In the same or a new namespace (e.g.,
eks-exercise2
):Create a Deployment with
nginx:1.21
using 3 replicas.Update the deployment image from
nginx:1.21
tonginx:1.23
in a rolling fashion.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)
Deploy an application of your choice (e.g.,
nginx
) with 1 replica.Manually scale the replicas to 5.
Enable Horizontal Pod Autoscaling:
Minimum 1 Pod
Maximum 10 Pods
Target CPU usage of 50%
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)
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).
Verify both containers are running inside one Pod.
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
Create a namespace called
quota-namespace
.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)
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.