ConfigMaps and Secrets Flashcards
What problem do ConfigMaps and Secrets both solve?
ConfigMaps and Secrets allow for the use of the same environment variables or credentials accross different container definitions.
How can ConfigMaps or Secrets be injected into a container?
They can be injected either directly under spec.containers[].envFrom[].configMapRef or spec.containers[].envFrom[].secretRef for Secrets and they can also be injected through a container by adding a volume under spec.volumes and the mount path on spec.containers.volumeMounts.mountPath
How can you create a config map or a secret from a file?
kubectl create configmap –from-file=file_name.json
kubectl create secret generic –from-file=file_name.json
How would you inject a secret into a pod, show both ways?
By volume:
spec:
volumes:
- name: a-secret-vol
secret:
secretName: a-secret-resource
containers:
- name: container
image: nginx
volumeMounts:
- name: a-secret-vol
mountPath: /path
By env file
spec:
containers:
- name: container
image: nginx
envFrom:
secretRef:
name: secret-resource