Plugin for kustomize to allow to expand placeholders with values. The initial use case is to make domain names in ingresses configurable.
host: sub.${DOMAIN}
replace with valueDOMAIN
or fail if value is missinghost: sub.${DOMAIN:-fallback.com}
replace with valueDOMAIN
or fall back to "fallback.com" if missingport: ${REDIS_PORT:number:-6379}
replace with valueREDIS_PORT
, inject as number (not as string) and fall back to 6379 if missing
# ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
spec:
rules:
- host: "sub.${DOMAIN:-domain.com}"
# variable-injector.yaml
apiVersion: airfocusio.github.com/v1alpha1
kind: VariableReplacer
metadata:
name: variable-injector
annotations:
config.kubernetes.io/function: |
container:
image: ghcr.io/airfocusio/kustomize-variable-injector:latest
replacements:
- targets:
- group: networking.k8s.io
version: v1
kind: Ingress
name: ingress
variables:
DOMAIN: mydomain.com
# kustomization.yaml
resources:
- secret.yaml
transformers:
- variable-injector.yaml
Plugins are still in alpha. For this to work, you need to provide the --enable-alpha-plugins
flag (i.e. kustomize build --enable-alpha-plugins
).