- Caching – enabled only for the premium and self-hosted versions. This requires a Redis database and its associated configurations.
- An external database service (e.g., Postgres) – enabled only for the development and premium versions.

kustomization.yaml file that imports shared configurations from the base folder. The new “components” directory houses two distinct components: one for caching and one for the external database. For instance, the caching component includes all Kubernetes configurations necessary for setting up Redis (deployments, secrets, patches, etc.), while the database component manages all configurations needed for an external Postgres database.

By isolating the configuration logic into components, overlays that require specific features—such as caching or an external database—can simply import the corresponding component. This method minimizes duplicate code and reduces the chance of error.
Implementing a Component
Consider the project structure described above. Thebase directory contains common configurations, including a kustomization.yaml file and an API deployment file. The components directory holds feature-specific folders for caching and the database, while the overlays directory contains environment-specific configurations for dev, premium, and standalone deployments.
Let’s focus on the database component. Within the database component folder, you will find the following files:
- postgres-depl.yaml: Defines the Kubernetes Deployment required for a Postgres instance.
- deployment-patch.yaml: A strategic merge patch that modifies the base API deployment by adding an environment variable for the new database connection.
- kustomization.yaml: Specifies the component metadata, resources, secret generator, and patch references.
Postgres Deployment Configuration
Below is an example of the Postgres Deployment configuration defined inpostgres-depl.yaml:
Component kustomization.yaml
In the component’skustomization.yaml file, notice that the ApiVersion and Kind differ from a typical configuration file. Because this is defined as a component, the ApiVersion is kustomize.config.k8s.io/v1alpha1 and the Kind is Component. This file references the resources for the component, defines a secret for the database password, and applies any necessary patches:
deployment-patch.yaml adjusts the base API deployment to use the newly created secret.
Updating the Base Deployment
Thedeployment-patch.yaml file adds an environment variable to the API deployment so that the application can connect to the new Postgres database. An example patch looks like this:
Importing Components in Overlays
To incorporate the external database settings, overlays that require this feature (for example, the dev overlay) import the database component. The overlay’skustomization.yaml file includes the base configuration and then adds the component:
Using components in your Kubernetes configuration allows you to manage optional features efficiently. It simplifies maintenance, reduces duplicate code, and minimizes the risk of configuration drift across multiple environments.