Question

Gitlab Registry Forbidden with managed Kubernetes Cluster

Hello,

I’m currently trying out the managed Kubernetes Cluster with the Gitlab CI/CD and integrated private Registry. To understand my problem you need to know that I currently have a working Docker Swarm Cluster with that CI/CD and private Registry in use.

However with the managed Kubernetes the Pod Creation is always stuck at “ImagePullBackOff” with following error:

Failed to pull image "registry.gitlab.com/<PROJECT-PATH>/<BRANCH>:<COMMIT HASH>": rpc error: code = Unknown desc = Error response from daemon: Get "registry.gitlab.com/<PROJECT-PATH>/<BRANCH>:<COMMIT HASH>": denied: access forbidden

I tried it with Helm/Tiller and also with a normal Kubernetes Deploy file. The secret is in the same namespace as the deployment and is working on the mentioned Docker Swarm and on my local machine.

Is DO doing something weird here? Maybe someone of you have more information.

Kind regards, Kai

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I have similiar problem each time i create gitlab registry secrets via kubectl create secret. It just wont pull any image, but when i use this script everything works:

#!/bin/bash
#
# Create Docker Image Registry secret in Kubernetes
#
# Usage:
#   REGISTRY=registry.gitlab.com \
#   LOGIN=<your-username> \
#   PASSWORD=<your-pword> \
#   NAMESPACE=<your namespace> \
#   NAME=<secret-name> \
#   ./registry.sh
#
# The same as:
#
# kubectl create \
#         --namespace=<your-namespace> \
#         secret docker-registry <secret-name> \
#         --docker-server=<your-registry-server> \
#         --docker-username=<your-username> \
#         --docker-password=<your-pword> \

set -eo pipefail


if [ "$1" == "delete" ]; then
  kubectl delete secret \
    --namespace="${NAMESPACE}" \
    "${NAME}" || true
fi

AUTH=$(echo -n ${LOGIN}:${PASSWORD} | base64 -w 0)

export TOKEN=$(envsubst <<<'
{
   "auths":{
      "${REGISTRY}":{
         "username":"${LOGIN}",
         "password":"${PASSWORD}",
         "auth":"${AUTH}"
      }
   }
}
' | base64 -w 0)

envsubst <<<'
apiVersion: v1
kind: Secret
metadata:
  name: ${NAME}
  namespace: ${NAMESPACE}
data:
  .dockerconfigjson: ${TOKEN}
type: kubernetes.io/dockerconfigjson
' | kubectl create -f -

I had the same issue but in my case was a typo on the secret namespace. When I fixed that my problem got solved.

Any movement or insight on this?