Skip to content

Latest commit

 

History

History
69 lines (45 loc) · 1.63 KB

README.md

File metadata and controls

69 lines (45 loc) · 1.63 KB

03-01 Kubernetes ConfigMaps

You will learn about:

  • configurations in Kubernetes
  • read configuration from environment variables in the container

Applications typically read configurations in the form of key/value pairs to prepare their environment of execution.

With Config Maps, we will see how to create configurations that can be shared to one or more pods.

Start

No code provided. You will create Kubernetes YAML definitions for pods that read configurations.

Run cd exercise/ and follow the instructions below to get started!

ConfigMaps

Create a file config-map.yaml containing a config map that has one key/value (debug.level=INFO):

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  debug.level: INFO

Store the configuration map in Kubernetes with:

kubectl apply -f config-map.yaml

Now, create a simple pod that will read it (see provided template config-pod.yaml):

kubectl apply -f config-pod.yaml

Find the newly created pod name with kubectl get pods and confirm that the pod has successfully extracted the value of the configuration identified by the key debug.level:

kubectl logs pod/app

The output should be similar to this:

INFO

Config maps can alternatively be created via the kubectl command kubectl create configmap and passed as files or CLI arguments.

Links:

Cleanup

# Windows only
kubectl delete all --all -n "$env:TEAM_NAME"

# MacOS
kubectl delete all --all -n "${TEAM_NAME}"