liveBook · Manning

Chapter 8: Configuring applications with ConfigMaps and Secrets

What you will learn in chapter 8 of Kubernetes in Action, Second Edition

This chapter introduction previews configuring applications through pod manifests or referenced resources and exposing pod metadata to containers.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduction previews configuring applications through pod manifests or referenced resources and exposing pod metadata to containers.

8.1 Setting the command, arguments, and environment variables

The section shows how a container image supplies application configuration defaults and explains that a Kubernetes pod manifest can override them.

Key terms: ENTRYPOINT, CMD, ENV, COPY, Dockerfile, defaults, pod manifest, --listen-port, INITIAL_STATUS_MESSAGE

8.1.1 Setting the command and arguments

This section explains how a pod manifest sets a container’s command and arguments, and how those settings relate to Dockerfile defaults.

Key terms: ENTRYPOINT, CMD, command, args, --cpu-prof, --heap-prof, YAML parser, command array, quotes

8.1.2 Setting environment variables in a container

This subsection shows how to set environment variables for individual containers, reference them in a pod manifest or shell command, and configure a pod’s internal hostname and FQDN.

Key terms: env field, environment variable, pod manifest, $(VAR_NAME), $$(VAR_NAME), command, args, $VAR_NAME, ${VAR_NAME}, hostname

8.2 Using a ConfigMap to decouple configuration from the pod manifest

This section explains why moving environment-specific configuration from a pod manifest into a ConfigMap makes the pod definition reusable.

Key terms: pod manifest, ConfigMap object, decouple the configuration

8.2.1 Introducing ConfigMaps

Introduces ConfigMaps as reusable configuration objects that pods can consume without embedding environment-specific settings in their manifests.

Key terms: ConfigMap, key–value pairs, Kubernetes REST API, environment variables, configMap volume, command-line argument, ConfigMap manifests, pod manifest, ConfigMap name

8.2.2 Creating a ConfigMap object

This section shows how to create ConfigMaps from literals, manifests, and files, then inspect how their entries are represented.

Key terms: ConfigMap, kubectl create configmap, --from-literal, --from-file, --from-env-file, kubectl apply, --dry-run, -o yaml, ConfigMap manifest, version control system

8.2.3 Injecting ConfigMap values into environment variables

This section shows how to inject individual or entire ConfigMap entries into a container’s environment and explains naming, missing-reference, and precedence behavior.

Key terms: env, valueFrom, ConfigMap, name, key, optional, configMapKeyRef, configMapRef, envFrom, prefix

8.2.4 Updating and deleting ConfigMaps

This section explains how to edit and delete ConfigMaps, why updates can leave pods with different configurations, and how immutable ConfigMaps prevent changes.

Key terms: ConfigMap, kubectl apply, kubectl edit, environment variables, containers, immutable ConfigMap, data, binaryData, API server, kubectl delete

8.3 Using Secrets to pass sensitive data to containers

The section explains why sensitive application data should use Secrets rather than ConfigMaps.

Key terms: ConfigMaps, Secrets, sensitive data

8.3.1 Introducing Secrets

Introduces Secrets by comparing their fields with ConfigMaps and explaining why Kubernetes treats Secret data differently.

Key terms: Secret, ConfigMap, data, binaryData, stringData, Base64-encoded, Secrets, ConfigMaps, worker nodes, sensitive data

8.3.2 Creating a Secret

This section shows how to create several types of Kubernetes Secrets, enter their values, and reference a registry pull Secret from a pod.

Key terms: generic secret, kubectl create secret, YAML manifest, stringData, data, Base64-encoded values, tls Secret, certificate, private key, kiada-tls

8.3.3 Using Secrets in containers

This section shows how to expose Secret values as container environment variables and explains why doing so can risk exposing sensitive data.

Key terms: Secret, valueFrom.secretKeyRef, envFrom, secretRef, environment variables, error reports, application log, child processes, secret volume

8.3.4 Understanding why Secrets aren’t always secure

This section explains why Kubernetes Secrets can still expose sensitive data and what protections they do not provide on their own.

Key terms: Secret, Base64-encoded, encryption, etcd, Secrets, RBAC, Kubernetes API, environment variable, file, logs

8.4 Exposing metadata to containers via the Downward API

This section contrasts static configuration with pod-specific information and explains why repeating values already in a pod manifest is undesirable.

Key terms: configuration data, pod, cluster node, pod manifest, CPU, memory

8.4.1 Introducing the Downward API

Introduces the Downward API as a way to pass selected Pod and container information into containers without repeating it in application configuration.

Key terms: Downward API, pod metadata, environment variables, valueFrom, fieldRef, resourceFieldRef, downwardAPI volume

8.4.2 Injecting pod metadata into environment variables

Shows how the Downward API supplies pod metadata and container resource limits to an application through environment variables.

Key terms: Downward API, POD_NAME, POD_IP, NODE_NAME, NODE_IP, CPU and memory resource limits, valueFrom.resourceFieldRef, divisor, containerName

8.5 Summary

Summarizes how pod manifests, ConfigMaps, Secrets, and the Downward API supply settings and data to containers.

Where this is used later

Concepts explained in this chapter

← Chapter 7: Organizing pods and other resources using namespaces and labels Chapter 9: Adding volumes for storage, configuration, and metadata →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.