Bitpath

Lesson 1 · Unit 03

ConfigMaps and Secrets

Settings as env vars or files, and why base64 is not encryption.

12 exercisesabout 3 min

What you practise

  • Settings as environment variables or files, why base64 is not encryption, changing config without rebuilding

Try a question from this lesson

Pick one

The image shop/api:2.1 has the staging database host written into its code. It now has to run in production against another database. What is the better design?

Hint

Which option means the artefact you tested in staging is the very thing that runs in production?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

ConfigMap: settings as an object

A ConfigMap is an object holding plain key-value settings. It lives apart from the Pods that read it, so the same Deployment can run with different settings in different places.

A container can take a ConfigMap in two ways: as environment variables, or as files in a mounted volume, one file per key.

It is for settings that are not secret. Anyone who can read the object can read the values.

YAML
apiVersion: v1
kind: ConfigMap
metadata:
  name: api-config
data:
  DB_HOST: db.data
  LOG_LEVEL: info

Concept

Secret: the same shape, for sensitive values

A Secret holds passwords, tokens and keys. Pods use it like a ConfigMap: as environment variables (through secretKeyRef) or as mounted files.

Values under data are base64-encoded, so that any bytes fit in YAML. Under stringData you write plain text and the API encodes it for you.

Base64 is an encoding, not encryption. No key is involved, and anyone can reverse it. What protects a Secret is who is allowed to read it.

YAML
apiVersion: v1
kind: Secret
metadata:
  name: api-secret
type: Opaque
stringData:
  DB_PASS: example-only

9 more exercises in the app

  • 1× fill the blanks
  • 4× multiple choice
  • 2× true or false
  • 1× match the pairs
  • 1× order the lines

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy