diff --git a/scripts/deploy/01_deploy_bigbang.sh b/scripts/deploy/01_deploy_bigbang.sh new file mode 100644 index 0000000000000000000000000000000000000000..68d4efb508eed4039631f84290c8745a55263f2f --- /dev/null +++ b/scripts/deploy/01_deploy_bigbang.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Deploy flux and wait for it to be ready +echo "Installing Flux" +flux --version +flux install + +# Deploy BigBang +echo "Installing BigBang" +helm upgrade -i bigbang chart -n bigbang --create-namespace --set registryCredentials.username='robot$bigbang' --set registryCredentials.password=${REGISTRY1_PASSWORD} --set addons.argocd.enabled=true --set addons.authservice.enabled=true + +# Apply secrets kustomization pointing to current branch +echo "Deploying secrets from the ${CI_COMMIT_REF_NAME} branch" +cat examples/complete/envs/dev/source-secrets.yaml | sed 's|master|'$CI_COMMIT_REF_NAME'|g' | kubectl apply -f - \ No newline at end of file diff --git a/scripts/deploy/02_wait_for_helmrealeases.sh b/scripts/deploy/02_wait_for_helmrealeases.sh new file mode 100644 index 0000000000000000000000000000000000000000..b87bfa53f65c49cdce3befa65c9c194e1f90bc2a --- /dev/null +++ b/scripts/deploy/02_wait_for_helmrealeases.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +set -e + +## This is an array to instantiate the order of wait conditions +ORDERED_HELMRELEASES="gatekeeper istio-operator istio monitoring eck-operator ek fluent-bit twistlock cluster-auditor" + + +## This the actual deployed helmrelease objects in the cluster +DEPLOYED_HELMRELEASES=$(kubectl get hr --no-headers -n bigbang | awk '{ print $1}') + +## Function to test an array contains an element +## Args: +## $1: array to search +## $2: element to search for +function array_contains() { + local array="$1[@]" + local seeking=$2 + local in=1 + for element in ${!array}; do + if [[ $element == "$seeking" ]]; then + in=0 + break + fi + done + return $in +} + +## Function to wait on helmrelease +## Args: +## $1: package name +function wait_on() { + echo "Waiting on package $1" + kubectl wait --for=condition=Ready --timeout 500s helmrelease -n bigbang $1; +} + +for package in $ORDERED_HELMRELEASES; +do + if array_contains DEPLOYED_HELMRELEASES "$package"; + then wait_on "$package" + else echo "Expected package: $package, but not found in release. Update the array in this script if this package is no longer needed" + fi +done + +for package in $DEPLOYED_HELMRELEASES; +do + if array_contains ORDERED_HELMRELEASES "$package"; + then echo "" + else + echo "Found package: $package, but not found in this script array. Update the array in this script if this package is always needed" + wait_on "$package" + fi +done + +echo "Waiting on Secrets Kustomization" +kubectl wait --for=condition=Ready --timeout 30s kustomizations.kustomize.toolkit.fluxcd.io -n bigbang secrets \ No newline at end of file