Kubernetes basics - ConfigMap
Page content
Intro : overried ENTRYPOINT of a DOcker image in k8s
We can overried ENTRYPOINT value in a Docker image with command argumanet.
CMD can’t be overwrrided by command argument. We have to use args argument instead.
https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/
Here is an official sample.
pods/commands.yaml
apiVersion: v1
kind: Pod
metadata:
name: command-demo
labels:
purpose: demonstrate-command
spec:
containers:
- name: command-demo-container
image: debian
command: ["printenv"]
args: ["HOSTNAME", "KUBERNETES_PORT"]
restartPolicy: OnFailure
Inject environment variable
In container section, add env.
env:
- name: ...
value: ...
name is key, and value is value.
ConfigMap
ConfigMap is a smart way to configure environment value in the container. ConfigMap is an object as same as Pods and Developments. ConfigMap can define key-value pair.
Here is an example.
apiVersion: v1
kind: ConfigMap
metadata:
name: my-config
data:
key_1: 3
key2: "this value"
Apply ConfigMap to objects
In container argument, add like the following.
envFrom:
- configMapRef:
name: my-config