variables: KUBECTL: "quay.io/bitnami/kubectl:1.18" PRIME: "yes" CACHE: "persistent" # one of "no", "in-memory", "persistent" TERMINATE: "yes" stages: - prepare - build - deploy - terminate prepare: stage: prepare only: variables: - $PRIME == "yes" image: name: $KUBECTL entrypoint: [""] script: - kubectl delete secret gitlab-registry-credentials || true - "kubectl create secret docker-registry gitlab-registry-credentials \ --docker-server=$CI_REGISTRY \ --docker-username=image-registry \ --docker-password=$CI_REGISTRY_TOKEN" claim-volume: stage: prepare except: variables: - $TERMINATE == "yes" only: variables: - $CACHE == "persistent" image: name: $KUBECTL entrypoint: [""] script: - kubectl apply -f deploy/storage build-prime: stage: build except: variables: - $TERMINATE == "yes" only: variables: - $PRIME == "yes" services: - docker:dind script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - cd prime - docker build -t $CI_REGISTRY_IMAGE/prime:latest . - docker push $CI_REGISTRY_IMAGE/prime:latest deploy-prime: stage: deploy except: variables: - $TERMINATE == "yes" only: variables: - $PRIME == "yes" image: name: $KUBECTL entrypoint: [""] script: - echo prime-$GITLAB_USER_ID.loki.th-luebeck.dev - wget -q https://github.com/mikefarah/yq/releases/download/3.4.0/yq_linux_amd64 -O ./yq && chmod +x yq - ./yq w -i deploy/prime/prime-ingress.yaml spec.rules[0].host prime-$GITLAB_USER_ID.loki.th-luebeck.dev - ./yq w -i deploy/prime/prime-ingress.yaml spec.tls[0].hosts[0] prime-$GITLAB_USER_ID.loki.th-luebeck.dev - kubectl apply -f deploy/prime deploy-cache: stage: deploy except: variables: - $TERMINATE == "yes" only: variables: - $CACHE == "in-memory" image: name: $KUBECTL entrypoint: [""] script: - kubectl delete -f deploy/persistent-redis || true - kubectl apply -f deploy/redis deploy-persistent-cache: stage: deploy except: variables: - $TERMINATE == "yes" only: variables: - $CACHE == "persistent" image: name: $KUBECTL entrypoint: [""] script: - kubectl delete -f deploy/redis || true - kubectl apply -f deploy/persistent-redis terminate: stage: terminate only: variables: - $TERMINATE == "yes" image: name: $KUBECTL entrypoint: [""] script: - kubectl delete -f deploy/redis || true - kubectl delete -f deploy/redis-persistent || true - kubectl delete -f deploy/prime || true - kubectl delete -f deploy/storage || true