Complete the code to create a ConfigMap in Kubernetes.
kubectl create configmap [1] --from-literal=app_mode=production
The command kubectl create configmap my-config --from-literal=app_mode=production creates a ConfigMap named my-config with a key app_mode set to production.
Complete the code to create a Secret with a password in Kubernetes.
kubectl create secret generic [1] --from-literal=password=Pa$$w0rd
The command kubectl create secret generic db-secret --from-literal=password=Pa$$w0rd creates a Secret named db-secret containing the password.
Fix the error in the command to mount a Secret as a volume in a Pod spec.
volumes:
- name: secret-volume
secret:
secretName: [1]The secretName must match the name of an existing Secret. Here, db-secret is the correct Secret name to mount.
Fill both blanks to define environment variables from a ConfigMap and a Secret in a Pod spec.
env:
- name: APP_MODE
valueFrom:
configMapKeyRef:
name: [1]
key: app_mode
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: [2]
key: passwordThe environment variable APP_MODE comes from the ConfigMap named my-config, and DB_PASSWORD comes from the Secret named db-secret.
Fill all three blanks to create a Pod spec snippet that mounts a ConfigMap and a Secret as volumes and uses environment variables from both.
volumes:
- name: config-volume
configMap:
name: [1]
- name: secret-volume
secret:
secretName: [2]
containers:
- name: app-container
image: myapp:latest
volumeMounts:
- name: config-volume
mountPath: /etc/config
- name: secret-volume
mountPath: /etc/secret
env:
- name: APP_MODE
valueFrom:
configMapKeyRef:
name: [3]
key: app_modeThe ConfigMap my-config is mounted as config-volume and used for the APP_MODE environment variable. The Secret db-secret is mounted as secret-volume.