ConfigMaps and Secrets Flashcards

1
Q

What problem do ConfigMaps and Secrets both solve?

A

ConfigMaps and Secrets allow for the use of the same environment variables or credentials accross different container definitions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can ConfigMaps or Secrets be injected into a container?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you create a config map or a secret from a file?

A

kubectl create configmap –from-file=file_name.json
kubectl create secret generic –from-file=file_name.json

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you inject a secret into a pod, show both ways?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly