8 Configuring Applications with ConfigMaps and Secrets
This chapter covers
- Setting the command and arguments for the container's main process
- Setting environment variables
- Storing configuration in ConfigMaps
- Storing sensitive information in Secrets
- Using the Downward API to expose Pod metadata to the application
In the previous chapters you learned how to run an application process in Kubernetes. Now, you’ll learn how to configure the application—either directly in the Pod manifest or through decoupled resources referenced by the Pod manifest. You’ll also learn how to inject Pod metadata into the environment of the containers within the Pod.
Note
You’ll find the code files for this chapter at https://github.com/luksa/kubernetes-in-action-2nd-edition/tree/master/Chapter08
8.1 Setting the command, arguments, and environment variables
Like regular applications, containerized applications can be configured using command-line arguments, environment variables, and files.
You learned that the command that gets executed in the container is typically defined in the container image. You specify the command in the container’s Dockerfile using the ENTRYPOINT directive and the arguments with the CMD directive. Environment variables can also be specified; you do this with the ENV directive. If the application is configured using configuration files, these can be added to the container image using the COPY directive. You’ve seen several examples of this in the previous chapters.