Challenge, Medium,  on  Kubernetes

Setup ConfigMap-Based Configuration Files with Validated Probes

Scenario

Create a ConfigMap named app-config in the apps namespace with the following data:

  • APP_MODE=production
  • APP_PORT=8080

Mark the ConfigMap as immutable so that its data cannot be changed after creation.

Verify the ConfigMap contains the exact values before proceeding.

Create a Deployment named app-workload in the apps namespace with 2 replicas using the nginx image. The Pod label should be app: app-workload.

Mount the ConfigMap app-config into the Deployment at /etc/appconfig so that each key becomes a separate file.

Add a readiness probe to the container that runs the following command to check exact values of the ConfigMap:

grep -qx "production" /etc/appconfig/APP_MODE && grep -qx "8080" /etc/appconfig/APP_PORT

Ensure the Deployment is running successfully with all Pods ready.


Hint 1

When mounting a ConfigMap as a volume, each key in the ConfigMap becomes a separate file inside the mount path. So APP_MODE becomes the file /etc/appconfig/APP_MODE and APP_PORT becomes /etc/appconfig/APP_PORT.

Hint 2

The grep -qx command checks for an exact full-line match inside a file. The -q flag keeps it silent and -x matches the whole line. The probe passes only if both grep commands exit with code 0, which is why they are joined with &&.


Test Cases