diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a8f2d480c56e642ee31a11aaba912ab1a9a0b275..910debd3b363c1830389e83ea2dacc9b20852226 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,45 +30,10 @@ stages: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/k3d-builder:0.0.1 .deploy_bigbang: &deploy_bigbang - # Deploy flux and wait for it to be ready - - flux --version - - flux install - - kubectl get namespaces,pods,gitrepositories,helmrelease -A + - for script in /scripts/*.sh; do $script; done - # Deploy 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 - - - # Wait for components to be ready - # NOTE: Wait for each package individually so they show up nicely in ci logs - - kubectl wait --for=condition=Ready --timeout 180s helmrelease -n bigbang gatekeeper - - kubectl wait --for=condition=Ready --timeout 180s helmrelease -n bigbang istio-operator - - kubectl wait --for=condition=Ready --timeout 240s helmrelease -n bigbang istio - - kubectl wait --for=condition=Ready --timeout 600s helmrelease -n bigbang monitoring - - kubectl wait --for=condition=Ready --timeout 300s helmrelease -n bigbang eck-operator - - kubectl wait --for=condition=Ready --timeout 420s helmrelease -n bigbang ek - - kubectl wait --for=condition=Ready --timeout 360s helmrelease -n bigbang fluent-bit - - kubectl wait --for=condition=Ready --timeout 360s helmrelease -n bigbang twistlock - - kubectl wait --for=condition=Ready --timeout 360s helmrelease -n bigbang cluster-auditor - - kubectl wait --for=condition=Ready --timeout 60s kustomizations.kustomize.toolkit.fluxcd.io -n bigbang secrets - - # Wait for addons (only if they exist since they might not yet for upgrades) - # TODO: This is kinda messy - - kubectl get helmrelease -n bigbang argocd && kubectl wait --for=condition=Ready --timeout 300s helmrelease -n bigbang argocd - - kubectl get helmrelease -n bigbang authservice && kubectl wait --for=condition=Ready --timeout 300s helmrelease -n bigbang authservice - - # Quick check for non iron bank images - - echo "Showing images not from ironbank:" - # Ignore rancher images since those are from k3d - - kubectl get pods -A -o jsonpath="{..image}" | tr -s '[[:space:]]' '\n' | sort | uniq -c | grep -v "registry1" | grep -v "rancher" - - # Basic smoke test BigBang -# - echo "Package tests go here" -# - bash ./tests/virtualservices.sh -# - kubectl get helmrelease -A +.test_bigbang: &test_bigbang + - for test in /tests/bash/*.sh; do $test; done clean install: stage: smoke tests @@ -83,6 +48,10 @@ clean install: CLUSTER_NAME: "clean-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" script: - *deploy_bigbang + - *test_bigbang + after_script: + - kubectl get all -A + - kubectl get helmrelease -A upgrade: stage: smoke tests @@ -96,10 +65,12 @@ upgrade: - echo "Install Big Bang from ${CI_DEFAULT_BRANCH}" - git fetch && git checkout ${CI_DEFAULT_BRANCH} - *deploy_bigbang + - *test_bigbang - echo "Upgrade Big Bang from ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" - git checkout ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} - *deploy_bigbang + - *test_bigbang #----------------------------------------------------------------------------------------------------------------------- diff --git a/scripts/01_deploy_bigbang.sh b/scripts/01_deploy_bigbang.sh new file mode 100644 index 0000000000000000000000000000000000000000..8cf37de9919224c2a6d37cc2b0be953047349760 --- /dev/null +++ b/scripts/01_deploy_bigbang.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +# Deploy flux and wait for it to be ready +flux --version +flux install +kubectl get namespaces,pods,gitrepositories,helmrelease -A + +# Deploy 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 - diff --git a/scripts/02_wait_for_helmrealeases.sh b/scripts/02_wait_for_helmrealeases.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd1e2348b01de2bc984169bbb4d4e1c0e5c727f1 --- /dev/null +++ b/scripts/02_wait_for_helmrealeases.sh @@ -0,0 +1,8 @@ + +#!/bin/bash +set -e +# Wait for components to be ready +for package in $(kubectl get helmrelease -n bigbang | awk '{print $1}' | grep -v NAME); +do kubectl wait --for=condition=Ready --timeout 600s helmrelease -n bigbang $package; +done +kubectl wait --for=condition=Ready --timeout 30s kustomizations.kustomize.toolkit.fluxcd.io -n bigbang secrets diff --git a/tests/virtualservices.sh b/tests/bash/01_virtualservices.sh similarity index 66% rename from tests/virtualservices.sh rename to tests/bash/01_virtualservices.sh index 8ce5e4474a8cf5145d00033f6ec49180ec0a151b..e452aa33acaba3f7405979f10176357890a7c5ad 100755 --- a/tests/virtualservices.sh +++ b/tests/bash/01_virtualservices.sh @@ -1,9 +1,10 @@ #!/bin/bash +# exit on error set -e +echo "Checking " hosts=`kubectl get vs -A -o jsonpath="{ .items[*].spec.hosts[*] }"` - for host in $hosts; do - curl -vI https://$host + curl -vI http://$host done \ No newline at end of file diff --git a/tests/bash/02_non_ironbank.sh b/tests/bash/02_non_ironbank.sh new file mode 100644 index 0000000000000000000000000000000000000000..496759812671259f2407c196a0cae9fec7c92d17 --- /dev/null +++ b/tests/bash/02_non_ironbank.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# exit on error +set -e + +# Quick check for non iron bank images +echo "Showing images not from ironbank:" +# Ignore rancher images since those are from k3d +kubectl get pods -A -o jsonpath="{..image}" | tr -s '[[:space:]]' '\n' | sort | uniq -c | grep -v "registry1" | grep -v "rancher"