Shared ConfigMaps (K8s Config)

Several of your applications need the same configuration file, or one
application needs a config block too large to sit comfortably inside its own
values. The K8s Config Component type creates Kubernetes ConfigMaps that any
of your applications can mount as files.

When to use this

Use a K8s Config Component when the content is a file — a config file, a shell
script, a certificate bundle — that one or more applications read from disk,
and especially when more than one application needs the same copy. For single
values reused across Components, use Variables instead. For anything
sensitive, use Secrets Manager — a ConfigMap is not a secret store.

Creating a shared ConfigMap

Provision a K8s Config Component with your configuration data:

configMaps:
  app-config:
    # Optionally copy the ConfigMap into additional namespaces:
    # namespaces:
    #   - ns1
    #   - ns2
    data:
      key1: value1
      key2: value2
      hello-world.sh: |
        #!/bin/sh
        echo "Hello world"
KeyRequiredDescription
configMaps.<name>YesEach entry defines one ConfigMap
<name>.dataYesKey/value pairs. Values can be plain strings or multiline content such as scripts and config files
<name>.namespacesNoAdditional namespaces to copy the ConfigMap into

Mounting it in an application

In your application Component — the generic application types — reference the
ConfigMap under volumes:

volumes:
  configMaps:
    app-config:
      mountPath: /app/config

There is no data key here. You are mounting the ConfigMap you already
created, not defining a new one inline.

Each key in the ConfigMap's data appears as a file under the mount path — for
example /app/config/hello-world.sh.

Related articles


Did this page help you?