Skip to content

cub k8s appconfig configmap

cub k8s appconfig configmap

Create a Kubernetes/YAML unit holding a ConfigMap rendered from an AppConfig unit

Synopsis

Create a Kubernetes/YAML unit holding a ConfigMap rendered from an AppConfig unit, and keep it rendered whenever the AppConfig unit changes, as an upload does for a ConfigMap annotated with confighub.com/toolchain.

configmap creates, in the AppConfig unit's space:

  1. A render-configmap invocation, -render, that renders the AppConfig unit's file as a ConfigMap holding it under one data key, named by the file's configHub.configName or else by the unit's slug with the toolchain's extension.
  2. An empty Kubernetes/YAML unit, -rendered unless --slug names it, that the ConfigMap is rendered into. This is the unit that is released; the AppConfig unit is never released itself.
  3. An Upsert link from that unit to the AppConfig unit, which runs the invocation on the AppConfig unit's content and writes the ConfigMap it renders. It guards what it writes with Link=Upsert and is cleared for that guard, so another change to the ConfigMap, such as an upgrade from the unit's upstream, has to be cleared for Link=Upsert.

The ConfigMap is immutable by default: its name is the AppConfig unit's slug followed by a hash of the file, so each change to the file renders a ConfigMap under a new name, and the workloads that use it roll onto it. A workload refers to it by the named placeholder confighubplaceholder, its dashes and dots replaced by underscores, which a NeedsProvides link from the workload's unit to the rendered unit fills with the current name (cub link create). An immutable ConfigMap needs the prune-configmaps trigger, which removes old renderings: configmap creates it, labeled Pack: configmaps, in a space that runs its own triggers and runs none with that function already, and warns when the space selects its triggers from elsewhere and none of them runs it.

With --mutable the ConfigMap keeps the AppConfig unit's slug as its name and is updated in place; workloads refer to it by that name, and its confighub.com/Hash annotation changes with the file. --as-key-value renders an AppConfig/Env unit as one data key per variable, for envFrom, rather than as one file.

The ConfigMap's namespace is the placeholder confighubplaceholder. --namespace-unit links the rendered unit to the unit holding the Namespace with a NeedsProvides link, cleared for Link=Upsert, which fills it in; without it, create such a link yourself, or set it with a link from another unit that provides it.

--changeset creates the rendered unit in a ChangeSet, which has to be open, so that the ConfigMap the link renders into it, and the namespace a link fills in, are recorded there. A component that requires change tracking needs it. The invocation, the links and the trigger are not revisions of a unit, and are not in the ChangeSet.

--dry-run checks everything the command would create without creating any of it: the invocation, the rendered unit and the trigger are created by the server and rolled back, with every check their creation makes, and the links, which need the rendered unit to exist, are reported.

An AppConfig unit that an Upsert link renders already is refused.

Examples:

  # Render app-config as an immutable ConfigMap into app-config-rendered, in namespace ns's unit
  cub k8s appconfig configmap --space app app-config --namespace-unit ns

  # Render it as a mutable ConfigMap, into a unit named app-config-cm
  cub k8s appconfig configmap app/app-config --mutable --slug app-config-cm

  # Render an .env file as one data key per variable, for envFrom
  cub k8s appconfig configmap --space app app-env --as-key-value --namespace-unit ns

  # See what rendering app-config in ChangeSet app-config-cm would create
  cub k8s appconfig configmap --space app app-config --changeset app-config-cm --dry-run
cub k8s appconfig configmap <appconfig-unit> [flags]

Options

      --as-key-value            render an AppConfig/Env unit as one data key per variable, for envFrom, rather than as one file
      --changeset string        changeset to create the rendered unit in, as <slug> or <space>/<slug>, which records the ConfigMap rendered into it; it has to be open
      --component string        the Component of --variant, when that names the variant alone; --variant <component>/<variant> says the same in one flag
      --dry-run                 report what the command would write, and write nothing
  -h, --help                    help for configmap
      --mutable                 render a ConfigMap named after the AppConfig unit and updated in place, rather than an immutable one whose name has a hash of its content
      --namespace-unit string   unit holding the Namespace the ConfigMap belongs in, as <slug> or <space>/<slug>, which a NeedsProvides link from the rendered unit fills its namespace from
      --quiet                   No default output.
      --slug string             slug of the Kubernetes/YAML unit the ConfigMap is rendered into; <unit>-rendered by default
      --space string            space to operate in, by slug or UUID. Omitted, a list or bulk operation spans the organization and a single entity is named as <space>/<slug>; "*" means the same as omitting it
      --variant string          variant to operate in, as <component>/<variant>, or as <variant> with --component: the space naming that Component whose Variant label is <variant>. The same scope as --space, named by what it is rather than by the space's slug; the two cannot be combined

Options inherited from parent commands

      --context string   The context to use for this command
      --debug            Debug output

SEE ALSO