stages: - run - build - deploy run_flask_app: stage: run image: python:3.11 before_script: - pip install -r requirements.txt script: - python app.py & - sleep 5 - curl http://127.0.0.1:5000 build_docker_image: stage: build image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] script: - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - /kaniko/executor --context "$CI_PROJECT_DIR" --dockerfile "$CI_PROJECT_DIR/Dockerfile" --destination "$CI_REGISTRY_IMAGE:latest" --destination "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" deploy_stage: stage: deploy image: name: bitnami/kubectl:latest entrypoint: [""] before_script: - mkdir -p ~/.kube - echo "$KUBECONFIGCONTENT" > ~/.kube/config - chmod 600 ~/.kube/config script: - kubectl apply -f manifests/stage/ - kubectl set image deployment/flask-app flask-app=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA -n stage - kubectl rollout status deployment/flask-app -n stage environment: name: stage rules: - if: '$CI_COMMIT_BRANCH == "main"' when: manual debug_runner_to_cluster: stage: deploy image: alpine:latest before_script: - apk add --no-cache curl busybox-extras iproute2 bind-tools script: - echo "=== Runner host/container info ===" - hostname - whoami - echo "=== Network interfaces ===" - ip addr - echo "=== Routing table ===" - ip route - echo "=== DNS config ===" - cat /etc/resolv.conf - echo "=== Internal DNS tests ===" - nslookup gitlab.internal.uia.no || true - nslookup registry.internal.uia.no || true - echo "=== GitLab/Registry connectivity ===" - nc -vz -w 10 gitlab.internal.uia.no 443 || true - nc -vz -w 10 registry.internal.uia.no 443 || true - echo "=== Kubernetes API connectivity ===" - nc -vz -w 10 10.225.210.169 6443 || true - curl -k --connect-timeout 10 https://10.225.210.169:6443/version || true rules: - if: '$CI_COMMIT_BRANCH == "main"'