Config - ConfigMaps Flashcards
1.
What are ConfigMaps used for?
- to pass configuration data in the form of key-value pairs in kubernetes
- when a pod is created, inject the config data into the pod, so that the key-value pairs available as environment variables for the hosted application in the pod
Which phases are involved in working with ConfigMaps?
- create the configMap
- Inject into the pod
How do you create configMaps?
Imperative ‘kubectl create configmap …’
Adding the key-value pairs as arguments
‘kubectl create configmap
< config-name> –from-literal=< key>=< value>’
‘kubectl create configmap app-config –from-literal=APP_COLOR=blue’
How do you create a config-map from a file?
‘kubectl create config-map app-config –from-file=app_config.properties’
What is the decision where to create a configMap from based on?
- based on the amount of properties to be configured
- many properties are easier from a file
How does a declarative configMap look?
Yaml file
apiVersion: v1 kind: ConfigMap metadata: name: app-config data: APP_COLOR: blue APP_MODE: prod
How can you view a config map?
kubectl get configmaps
kubectl describe configmaps
How do you use ConfigMaps in pods?
in Yaml
spec: containers: - name: image: ports: - containerPort: 8080 envFrom: - configMapRef: name: app-config
What options exist in regards to defining config maps in pods?
- As a single env:
~~~
env:
- name: APP_COLOR
valueFrom:
configMapKeyRef:
name: app-config
key: APP_COLOR
~~~ - whole env:
~~~
envFrom:
- configMapRef:
name: app-config
~~~ - As data in a file / Volume:
~~~
volumes:
- name: app-config-volume
configMap:
name: app-config
~~~
Wie wird configmap abgekürzt?
cm