Kubernetes Introductory EXERCISES-2
Exercise 6: Using ConfigMaps to Store Configuration
Create a
ConfigMap
that holds some application configuration (e.g., environment variables or a small config file).Deploy a Pod (or Deployment) that uses this ConfigMap:
As environment variables or mounted as a file.
Verify that the application/container is reading the configuration from the ConfigMap.
Key Concepts: ConfigMaps, environment variables, file mounts, Pod configuration.
Exercise 7: Storing Sensitive Data with Secrets
Create a Kubernetes Secret that contains a username and password (base64 encoded).
Deploy a Pod (or Deployment) that:
Uses the Secret as environment variables or as a mounted file.
Verify you can access the sensitive data inside the container while ensuring it remains encrypted at rest within the cluster.
Key Concepts: Secrets, secure data management, environment variables vs. volume mounts.
Exercise 8: Exposing Apps via Ingress
Install an Ingress Controller (e.g., AWS Load Balancer Controller or NGINX Ingress Controller) on your EKS cluster.
Deploy two different services (e.g., Service A running on path
/app1
, Service B on path/app2
).Create an Ingress resource that routes requests based on the URL path:
/app1
→ Service A/app2
→ Service B
Confirm external traffic is correctly routed to each service based on the path.
Key Concepts: Ingress, path-based routing, single external endpoint for multiple services.
Exercise 9: Taints and Tolerations
Taint one of your worker nodes so that only Pods with a matching toleration can be scheduled on it.
Deploy a Pod (or Deployment) with the proper toleration to run on the tainted node.
Verify that Pods without the toleration cannot schedule onto the tainted node.
Key Concepts: Node isolation, workload scheduling, cluster node customization.
Exercise 10: Scheduled Tasks with CronJobs
Create a CronJob that runs a simple script/container on a schedule (e.g., every 1–2 minutes) which prints a message.
Check the Jobs created by the CronJob to ensure they complete successfully.
Observe how the Jobs appear and terminate on schedule.
Key Concepts: CronJobs, scheduled containers, ephemeral workloads.