diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0a366b6f795e90c955897903eeb4746ecedf5db0..711445cd99e41ab2ef18926e8ec3d3c458ba7d80 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,8 @@ default: export PUBLISHED_IMAGE_TAG=$DOCKER_TAG_NAME$CI_COMMIT_SHORT_SHA fi - "[ $DOCKERFILE ] && KANIKO_DOCKERFILE=\"--dockerfile $DOCKERFILE\"" - - /kaniko/executor --context `pwd`/$CONTEXT $KANIKO_DOCKERFILE $KANIKO_D + - "BUILD_ARGS=$(printenv | sed -n 's/BUILD_ARG_/--build-arg=/p')" + - /kaniko/executor --context `pwd`/$CONTEXT $KANIKO_DOCKERFILE $KANIKO_D $BUILD_ARGS - echo "PUBLISHED_IMAGE_TAG=$PUBLISHED_IMAGE_TAG" >> $CI_PROJECT_DIR/build.env artifacts: reports: @@ -135,6 +136,45 @@ lint-helm: - when: manual allow_failure: true +test-helm: + stage: smoketest + extends: .dind + needs: + - lint-helm + # - deploy-theodolite + variables: + KUBECTL: v1.21.3 + CLUSTERNAME: "$CI_PROJECT_NAME-$CI_PIPELINE_ID" + cache: + paths: + - helm/charts + before_script: + - apk add -U wget bash openssl + # install kubectl + - wget -q -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL}/bin/linux/amd64/kubectl + - chmod +x /usr/local/bin/kubectl + # install k3d + - wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash + - wget -q -O - https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash + - k3d help + - k3d version + #- k3d cluster create testgitlabci --agents 1 --wait -p "30000:30000@agent[0]" + - k3d cluster create $CLUSTERNAME --agents 1 --wait -p "30000:30000@agent:0" # k3d 5.0 + # show cluster info + - kubectl cluster-info + - helm version + script: + # Display initial pods, etc. + - cd helm + - helm dependencies update . + - helm install theodolite . -f preconfigs/minimal.yaml --wait + - helm test theodolite + - kubectl get nodes -o wide + - kubectl get pods --all-namespaces -o wide + - kubectl get services --all-namespaces -o wide + after_script: + - k3d cluster delete $CLUSTERNAME + # Theodolite Benchmarks @@ -851,3 +891,23 @@ deploy-buildimage-docker-compose-jq: - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW && $CI_PIPELINE_SOURCE == 'web'" when: manual allow_failure: true + +deploy-buildimage-k3d-helm: + stage: deploy + extends: + - .kaniko-push + needs: [] + variables: + BUILD_ARG_DOCKER_VERSION: 20.10.12 + BUILD_ARG_KUBECTL: v1.21.3 + IMAGE_NAME: theodolite-build-k3d-helm + IMAGE_TAG: $DOCKER_VERSION + before_script: + - cd buildimages/k3d-helm + rules: + - changes: + - buildimages/k3d-helm/Dockerfile + if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW" + - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW && $CI_PIPELINE_SOURCE == 'web'" + when: manual + allow_failure: true diff --git a/buildimages/k3d-helm/Dockerfile b/buildimages/k3d-helm/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..30a1e6b1231cec157311546b8f7e7b0a091c83fe --- /dev/null +++ b/buildimages/k3d-helm/Dockerfile @@ -0,0 +1,15 @@ +ARG DOCKER_VERSION=latest + +FROM docker:${DOCKER_VERSION} + +ARG KUBECTL_VERSION=v1.21.3 + +RUN apk add -U wget bash openssl +# install kubectl +RUN wget -q -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \ + chmod +x /usr/local/bin/kubectl +RUN echo https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION} +# install k3d +RUN wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash +# install Helm +RUN wget -q -O - https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash diff --git a/helm/templates/tests/test-connection.yaml b/helm/templates/tests/test-prometheus-connection.yaml similarity index 73% rename from helm/templates/tests/test-connection.yaml rename to helm/templates/tests/test-prometheus-connection.yaml index 7af87e98920c11bcfaccb27724e6f29fc76771a0..313a0825adf5d654642c6e1d8ff6beb4ee59df97 100644 --- a/helm/templates/tests/test-connection.yaml +++ b/helm/templates/tests/test-prometheus-connection.yaml @@ -1,3 +1,4 @@ +{{- if .Values.prometheus.enabled }} apiVersion: v1 kind: Pod metadata: @@ -5,7 +6,8 @@ metadata: labels: {{- include "theodolite.labels" . | nindent 4 }} annotations: - "helm.sh/hook": test-success + "helm.sh/hook": test + "helm.sh/hook-delete-policy": hook-succeeded spec: containers: - name: wget @@ -13,3 +15,4 @@ spec: command: ['wget'] args: ['http://prometheus-operated:9090'] restartPolicy: Never +{{- end }}