Sign inSign up free

108. Inject a ConfigMap and a Secret as Env Vars

easy 10 XP ~7 minHands-on lab100% acceptance

The mailer Deployment in the analytics namespace still has its settings baked into the image. The team wants them moved into the cluster: plain settings in a ConfigMap, the database password in a Secret, both delivered to the containers as environment variables.

Task

  • Create a ConfigMap mailer-settings in analytics with exactly these keys: APP_MODE=staging, LOG_LEVEL=debug, REGION=us-east.
  • Create a Secret mailer-db in analytics with the key password set to meadow.
  • The container of Deployment mailer receives every key of mailer-settings as an environment variable of the same name.
  • The same container receives the Secret's password key as the environment variable DATABASE_PASSWORD.
  • All 2 replicas of mailer are available with the new configuration.
  • Leave the ConfigMap mailer-legacy as it is.

A practice cluster is running on this machine: start with kubectl get deploy,configmap,secret -n analytics.

About this machine

Ubuntu 24.04 with a private practice cluster: a real Kubernetes API server, scheduler and controllers, and three nodes (controlplane, node01, node02). Containers run in a lightweight runtime: their commands, kubectl logs, exec and run -it work, and Pods reach Services by name with wget or curl. Images never download, and port-forward isn't available. k is an alias for kubectl, with completion. The grader checks the cluster's final state, not the commands you typed.

Part of Kubernetes Core Concepts. Next step: Fix Pods Stuck in Pending

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh machine with its own Kubernetes cluster starts in about half a minute, with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.