I am trying to deploy an image from a private gitlab registry to a self-hosted kubernets cluster that is connected and managed by gitlab. As far as I understood it, I need a ImagePullSecret created and referenced in my Deployment-Config for this to work. Gitlab is creating a namespace per project so I am trying to create a secret at the start of my CI-Job. Strangely I always get the error, that an argument is missing, despite all of the required arguments being present. What am I doing wrong?
Here is the CI-Job out of my gitlab-ci.yml
deploy-app:
stage: deploy
image:
name: bitnami/kubectl:latest
entrypoint: [""]
script:
- kubectl create secret docker-registry gitlab-registry --docker-username=$CI_DEPLOY_USER --docker-password=$CI_DEPLOY_PASSWORD --docker-server=$CI_REGISTRY --dry-run=client -o yaml | kubectl apply -f -
- kubectl apply -f k8s/configmap.yaml
- kubectl apply -f k8s/deployment.yaml
- kubectl apply -f k8s/service.yaml
- kubectl apply -f k8s/ingress.yaml
environment:
name: production
url: <my-url>
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
The CI-Job always runs into the following error:
error: either --from-file or the combination of --docker-username, --docker-password and --docker-server is required
I tried to run the command directly on the server without an error, so this has something to do with this specific environment. Has someone an idea for another approach? I am a bit lost right now.