Skip to content

Implement var substitution from ConfigMaps and Secrets#275

Merged
stefanprodan merged 2 commits intomainfrom
substitute-from
Feb 16, 2021
Merged

Implement var substitution from ConfigMaps and Secrets#275
stefanprodan merged 2 commits intomainfrom
substitute-from

Conversation

@stefanprodan
Copy link
Copy Markdown
Member

@stefanprodan stefanprodan commented Feb 16, 2021

This PR adds an array field called substituteFrom to the post build API. SubstituteFrom holds references to ConfigMaps and Secrets containing the variables (data keys) and their values (data values) to be substituted in the YAML manifests.

You can disable the variable substitution for certain resources by either labeling or annotating them with:

kustomize.toolkit.fluxcd.io/substitute: disabled

Example:

apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
  name: apps
spec:
  interval: 5m
  path: "./apps/"
  postBuild:
    substitute:
      cluster_env: "prod"
      cluster_region: "eu-central-1"
    substituteFrom:
      - kind: ConfigMap
        name: cluster-vars
      - kind: Secret
        name: cluster-secret-vars

Fix: #274
Followup: #253

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
@stefanprodan stefanprodan requested a review from hiddeco February 16, 2021 07:27
@stefanprodan stefanprodan added the area/varsub Post-build variable substitution related issues and pull requests label Feb 16, 2021
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Comment thread controllers/kustomization_varsub.go
@stefanprodan stefanprodan merged commit 5f966d0 into main Feb 16, 2021
@stefanprodan stefanprodan deleted the substitute-from branch February 16, 2021 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/varsub Post-build variable substitution related issues and pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add substituteFrom from ConfigMap or Secret

2 participants