Kubernetes: configuration and storage

Namespaces, ConfigMap and Secret as variables or mounted files, a pod's volumes, PersistentVolume, PersistentVolumeClaim and StorageClass, access modes, and what a StatefulSet adds.

  • 28 cards
  • 4 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios

A few cards from the deck

  • Namespace: what is it?

    Show the answer

    A logical partition of the cluster that separates object names and to which permissions and quotas are applied.

    It does not cut the network: without a NetworkPolicy, a pod in one namespace reaches those of another.

  • Which value goes in a Secret's data field for the password s3cret?

    ```bash
    echo -n 's3cret' | base64
    `

    • czNjcmV0
    • s3cret
    • UzNjcmV0
    • czNjcmV0Cg==
    Show the answer

    czNjcmV0

    The command prints czNjcmV0. Without the -n option, echo adds a newline that would be encoded too (czNjcmV0Cg==) and make the password wrong. The plain value would go in stringData.

  • A ConfigMap value injected as an … is only read when the container starts; mounted as a …, it eventually gets updated in the pod.

    Show the answer

    A ConfigMap value injected as an environment variable is only read when the container starts; mounted as a file, it eventually gets updated in the pod.

    A process's variables are frozen when it launches. For an application to reread a changed file, it must also watch it or be restarted.

  • ConfigMap: what is it?

    Show the answer

    An object holding non-secret configuration, as key-value pairs or files, injected into pods without touching the image.

    The same image serves in development and in production: only the ConfigMap changes, so the image does not need rebuilding.

  • A ConfigMap is corrected but the application keeps the old value, read through an environment variable. What are the cause and the fix?

    • The API server did not record the ConfigMap; recreate it in another namespace
    • The ConfigMap is cached in the image; rebuild the image with the new value
    • Variables update on their own after an hour; wait
    • Variables are only read at startup; restart the deployment with kubectl rollout restart
    Show the answer

    Variables are only read at startup; restart the deployment with kubectl rollout restart

    A process's environment is copied when it launches. A mounted file can update, a variable cannot: the pods have to be replaced so that they reread the ConfigMap.