This example exercises namespace transformation on resources generated from a local Helm chart.
The example kustomization sets a namespace for Helm-generated resources that do not already declare one, while preserving any namespace explicitly emitted by the chart.
This example defines the helm command as:
helmCommand=${MYGOBIN:-~/go/bin}/helmV3Use the checked-in example:
EXAMPLE_HOME=examples/helmNamespaceBuild the example with Helm enabled:
output=$(kustomize build \
--enable-helm \
--helm-command "$helmCommand" \
"$EXAMPLE_HOME")
printf '%s\n' "$output"The Service is emitted by the chart without a namespace, so the example namespace should be applied:
printf '%s\n' "$output" | grep -A4 'name: chart-service' | grep 'namespace: top-level-ns'The ConfigMap is emitted by the chart with an explicit namespace, so that value should be preserved:
printf '%s\n' "$output" | grep -A4 'name: chart-config' | grep 'namespace: chart-owned-ns'The Secret is emitted by the chart with an release namespace, so that value should be preserved:
printf '%s\n' "$output" | grep -A4 'name: chart-secret' | grep 'namespace: chart-ns'