Chapter 20. Immutable Configuration

The Immutable Configuration pattern packages configuration data into an immutable container image and links the configuration container to the application at runtime. With this pattern, we are able to not only use immutable and versioned configuration data, but also overcome the size limitation of configuration data stored in environment variables or ConfigMaps.

Problem

As you saw in Chapter 18, EnvVar Configuration, environment variables provide a simple way to configure container-based applications. And although they are easy to use and universally supported, as soon as the number of environment variables exceeds a certain threshold, managing them becomes hard.

This complexity can be handled to some degree by using Configuration Resources. However, all of these patterns do not enforce immutability of the configuration data itself. Immutability here means that we can’t change the configuration after the application has started, in order to ensure that we always have a well-defined state for our configuration data. In addition, Immutable Configuration can be put under version control, and follow a change control process.

Solution

To address the preceding concerns, we can put all environment-specific configuration data into a single, passive data image that we can distribute as a regular container image. During runtime, the application and the data image are linked together so that the application can extract the configuration from the ...

Get Kubernetes Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.