Alternative Customization Methods

The version of Kustomize packaged with kubectl is not the most recent version, and some new features are not available. To use a more recent version, install Kustomize independent of kubectl or use Kustomize within a Docker image.

The following is an example wrapper script that uses curl to download Kustomize.

#!/bin/sh
 
# Save the STDIN as the chart output
cat <&0 > chartoutput.yaml
 
KUSTOMIZABLE_EXEC_FILE="$(pwd)/kustomize"
 
# Download the kustomize binary if needed
if [ ! -f ${KUSTOMIZABLE_EXEC_FILE} ]; then
    curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
fi
 
# Run the kustomize tool
${KUSTOMIZABLE_EXEC_FILE} build .
 
# Clean up
rm -rf chartoutput.yaml

The following is an example wrapper script that uses the Kustomize tool from within a Docker container.

#!/bin/sh
 
# Save the STDIN as the chart output
cat <&0 > chartoutput.yaml
 
# Set the kustomize version
KUSTOMIZE_VERSION=v3.8.7
 
# Pull the Kustomize Docker image if needed
docker pull --quiet k8s.gcr.io/kustomize/kustomize:${KUSTOMIZE_VERSION}
 
# Run the kustomize tool within docker. Mount the current directory to /patch on which the build will be performed
docker run --rm -v $(pwd):/patch k8s.gcr.io/kustomize/kustomize:${KUSTOMIZE_VERSION} build /patch
 
# Clean up
rm -rf chartoutput.yaml