# Kustomize based apply workflow. Requires jq, yq, kubectl, kustomize, mustache. # # Expected variables # - namespace Namespace for all resources. # - release A unique name to give to this collection of manifests. # - revision Release revision. # - images Image replacements. # - variables Variable replacements. # # Example inputs: # namespace=pr123 # release=app-pr123 # target=review # revision=ab331a # images='[{ "name": "nginx", "newTag": "latest" }]' # variables='{"host": "pr123.example.com"}' set -e echo "deploying $release into namespace $namespace using overlay overlays/$target" mkdir -p build cd build cat > kustomization.yaml < namespace.yaml < variables.yaml yq --yaml-output -s add ../overlays/$target/variables.yaml variables.yaml > merged.yaml kustomize build | mustache merged.yaml - > build.yaml kubectl apply -f namespace.yaml kubectl apply -f build.yaml --prune --selector deliverybot.io/release=$release --prune-whitelist=core/v1/Namespace