>_ IzzyLab

Hands-on task

This task is step 2 of the course “Kubernetes: manifests from Namespace to RBAC”

ConfigMap with settings

easy~5 min

Prepare in /root/cm.yaml a ConfigMap app-config with two keys in data: LOG_LEVEL=info and MAX_CONN=100. Rather than writing YAML by hand, it's easier to generate the manifest with a kubectl command using --dry-run=client -o yaml. Open the resulting file in the Editor tab and see where kubectl put the keys.

What you'll practise:
  • kubernetes
  • configmap
  • kubectl
  • dry-run
  • manifests

Topic breakdown

A ConfigMap stores non-secret configuration as key-value pairs in the data field; the values are always strings, even if they look like numbers (kubectl quotes them itself). The kubectl create configmap generator can assemble these pairs straight from command-line arguments — each key as a separate literal flag. The --dry-run=client -o yaml combination prints the ready manifest instead of creating the object in the cluster, and redirection saves it to a file.

What's checked

  1. Manifest is valid
  2. Key LOG_LEVEL=info
  3. Key MAX_CONN=100
  4. The ConfigMap is named app-config

What it looks like