Problem to solve
When attempting to run my deploy CI task, I am seeing the above error message. I have not changed anything in my gitlab-ci.yml
since the last successful deploy, so I’m unsure whats going on here. I am running a local gitlab and used the kubernetes next-click-finish install.
It runs the following stages correctly:
build, package when it tries to deploy to my kubernetes cluster it suddenly fails.
I have changed nothing in my gitlab-ci.yml or on my cluster end. So why it fails baffles me.
It returns the above error almost instantly after starting the job.
Thoughts?
Describe your question in as much detail as possible:
Steps to reproduce
Whenever I run the script it fails. There is no indication what is going wrong.
Configuration
prod-deployment:
# before_script:
# - apt-get install google-cloud-sdk-gke-gcloud-auth-plugin
# - apt-get update && apt-get --only-upgrade install google-cloud-sdk-kpt google-cloud-sdk-anthos-auth google-cloud-sdk-firestore-emulator google-cloud-sdk-spanner-emulator google-cloud-sdk-package-go-module google-cloud-sdk-nomos google-cloud-sdk-skaffold google-cloud-sdk-config-connector google-cloud-sdk-app-engine-java google-cloud-sdk google-cloud-sdk-kubectl-oidc google-cloud-sdk-minikube google-cloud-sdk-local-extract google-cloud-sdk-app-engine-python google-cloud-sdk-cbt google-cloud-sdk-cloud-run-proxy google-cloud-sdk-pubsub-emulator google-cloud-sdk-app-engine-python-extras google-cloud-sdk-cloud-build-local google-cloud-sdk-terraform-tools google-cloud-sdk-harbourbridge google-cloud-sdk-bigtable-emulator google-cloud-sdk-datastore-emulator google-cloud-sdk-datalab kubectl google-cloud-sdk-gke-gcloud-auth-plugin google-cloud-sdk-app-engine-go google-cloud-sdk-app-engine-grpc
stage: deploy
image: gcr.io/google.com/cloudsdktool/google-cloud-cli:latest
script:
- export DOCKER_HOST="tcp://localhost:2375"
- echo "$GCP_SERVICE_KEY" > key.json
- export USE_GKE_GCLOUD_AUTH_PLUGIN=True
- gcloud auth activate-service-account --key-file=key.json
- gcloud config set project bokkz-development-cluster
- gcloud config set container/cluster ****
- gcloud config set compute/zone europe-west4-c
- gcloud container clusters get-credentials **** --zone europe-west4-c
- export OTAP=***.***.***
- export LABEL=prod
- |
if test -f "deployment.yaml"; then
echo "Local Deployment exist"
echo "Using Local configuration"
sed -i "s/__CI_BUILD_REF_SLUG__/${CI_ENVIRONMENT_SLUG}/" deployment.yaml
sed -i "s/__VERSION__/${CI_COMMIT_REF_NAME}/" deployment.yaml
sed -i "s/__CI_PROJECT_NAME__/${CI_PROJECT_NAME}/" deployment.yaml
sed -i "s/__OTAP__/${OTAP}/" deployment.yaml
sed -i "s/__LABEL__/${LABEL}/" deployment.yaml
cat deployment.yaml
if kubectl apply -f deployment.yaml || grep -q unchanged || grep -q configured; then
echo "=> Patching deployment to force image update."
kubectl patch -f deployment.yaml -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"ci-last-updated\":\"$(date +'%s')\"}}}}}"
kubectl rollout status -f deployment.yaml
else
echo "=> Deployment apply has changed the object, no need to force image update."
fi
else
echo "Local Deployment does not exist"
echo "Using global configuration"
sed -i "s/__CI_BUILD_REF_SLUG__/${CI_ENVIRONMENT_SLUG-$CI_PROJECT_NAME}/" $SCRIPTS_DIR/manifest/deployment.yaml
sed -i "s/__VERSION__/${CI_COMMIT_REF_NAME}/" $SCRIPTS_DIR/manifest/deployment.yaml
sed -i "s/__CI_PROJECT_NAME__/${CI_PROJECT_NAME}/" $SCRIPTS_DIR/manifest/deployment.yaml
sed -i "s/__OTAP__/${OTAP}/" $SCRIPTS_DIR/manifest/deployment.yaml
sed -i "s/__LABEL__/${LABEL}/" deployment.yaml
cat $SCRIPTS_DIR/manifest/deployment.yaml
if kubectl apply -f $SCRIPTS_DIR/manifest/deployment.yaml | grep -q unchanged; then
echo "=> Patching deployment to force image update."
kubectl patch -f $SCRIPTS_DIR/manifest/deployment.yaml -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"ci-last-updated\":\"$(date +'%s')\"}}}}}"
else
echo "=> Deployment apply has changed the object, no need to force image update."
fi
kubectl rollout status -f $SCRIPTS_DIR/manifest/deployment.yaml
fi
only:
- master
environment:
name: prod
url: http://prod.***.**
Versions
Please select whether options apply, and add the version information.
- [ X] Self-managed
- GitLab.com SaaS
- [X ] Self-hosted Runners
Versions
- GitLab [14.1.6-ee]
- GitLab Runner: 15.2.1