Good day,
Please I do not know why I was marked wrong on this question:
Create a ConfigMap named app-config in the namespace
cm-namespace with the following key-value pairs:
ENV=production
LOG_LEVEL=info
Then, modify the existing Deployment named cm-webapp
in the same namespace to use the app-config ConfigMap
by setting the environment variables ENV and LOG_LEVEL in
the container from the ConfigMap.
This is my yaml output for my deployment and it shows that the environment variable is present in the pod, right? See below please:
controlplane ~ ➜ k get deployment -n cm-namespace cm-webapp -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
creationTimestamp: "2025-04-29T20:27:12Z"
generation: 2
labels:
app: cm-webapp
name: cm-webapp
namespace: cm-namespace
resourceVersion: "6468"
uid: 0620795d-a37a-4556-8a09-29007772aa02
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: cm-webapp
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: cm-webapp
spec:
containers:
- envFrom:
- configMapRef:
name: app-config
image: nginx
imagePullPolicy: Always
name: nginx
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status:
availableReplicas: 1
conditions:
- lastTransitionTime: "2025-04-29T20:27:16Z"
lastUpdateTime: "2025-04-29T20:27:16Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
- lastTransitionTime: "2025-04-29T20:27:12Z"
lastUpdateTime: "2025-04-29T20:40:27Z"
message: ReplicaSet "cm-webapp-787f95558b" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
observedGeneration: 2
readyReplicas: 1
replicas: 1
updatedReplicas: 1
controlplane ~ ➜ k exec -it -n cm-namespace cm-webapp-787f95558b-8v989 -- printenv
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=cm-webapp-787f95558b-8v989
NGINX_VERSION=1.27.5
NJS_VERSION=0.8.10
NJS_RELEASE=1~bookworm
PKG_RELEASE=1~bookworm
DYNPKG_RELEASE=1~bookworm
ENV=production
LOG_LEVEL=info
KUBERNETES_PORT_443_TCP=tcp://172.20.0.1:443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_ADDR=172.20.0.1
KUBERNETES_SERVICE_HOST=172.20.0.1
KUBERNETES_SERVICE_PORT=443
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT=tcp://172.20.0.1:443
TERM=xterm
HOME=/root
This were the points where I was marked wrong:
Deployment uses the app-config ConfigMap for variable ENV
Deployment uses the app-config ConfigMap for variable LOG LEVEL