Skip to content

gitlab-registry secret overwritten if multiple projects use the same namespace

We are deploying multiple staging & production environments into separated kubernetes namespaces but multiple projects into the same by setting CI_PROJECT_NAMESPACE and scope it to the environment. Sadly we realized that the gitlab-registry is overwritten each time we deploy.

  kubectl create secret -n "$KUBE_NAMESPACE" \
    docker-registry gitlab-registry \

I see multiple ways to solve this, the best ones I can think of:

  1. rename gitlab-registry to gitlab-registry-$CI_PROJECT_PATH_SLUG(or something shorter) and pass the same as helm value
  2. create an own deployment variable (https://docs.gitlab.com/ee/topics/autodevops/#environment-variables) for the registry secret like AUTO_DEVOPS_REGISTRY_SECRET_NAME and pass it as helm value

I personally think that this registry secret is always project specific and should be named with the project in mind but I didn't invent it so ¯_(ツ)_/¯

Guess for now I will have to fork the image, maybe after a decision I can contribute a MR.

EDIT: Just saw that we pass secret_name already as helm value, so the change is even easier.

Edited by Adam Lemanski