#devopsengineer
#devopsmadeeasy
#kubernetes
Assignment
Deploy a simple application in Kubernetes that:
1. Uses ConfigMap for non-sensitive configuration
2. Uses Secret for sensitive configuration
3. Injects both as:
o Environment variables
o Mounted files
4. Demonstrates why Secrets are not encrypted by default
________________________________________
Part 1: ConfigMap (Non-Sensitive Config)
Task 1.1 – Create ConfigMap
Create a ConfigMap named:
app-config
With the following values:
Key Value
APP_ENV Dev
APP_VERSION 1.0
LOG_LEVEL Debug
________________________________________
Task 1.2 – Inject as Environment Variables
Create a Pod using:
• image: nginx
• name: config-demo
Inject all ConfigMap values as environment variables.
Verify
Run:
kubectl exec -it config-demo -- printenv
Confirm that:
• APP_ENV
• APP_VERSION
• LOG_LEVEL
are visible.
________________________________________
Task 1.3 – Mount ConfigMap as Files
Mount the same ConfigMap at:
/etc/config
Verify
kubectl exec -it config-demo -- ls /etc/config
Each key should appear as a file.
________________________________________
Part 2: Secret (Sensitive Data)
Task 2.1 – Create Secret
Create a Secret named:
db-secret
With:
Key Value
DB_USERNAME admin
DB_PASSWORD SuperSecret123
Use base64 encoding.
________________________________________
Task 2.2 – Inject Secret as Environment Variable
Update or create a new Pod:
• Inject DB_USERNAME
• Inject DB_PASSWORD
Verify using:
kubectl exec -it pod-name -- printenv
________________________________________
Task 2.3 – Mount Secret as File
Mount secret at:
/etc/secrets
Verify:
kubectl exec -it pod-name -- ls /etc/secrets
Then:
cat /etc/secrets/DB_PASSWORD