'docker desktop kubernetes can't pull from private registry

I'm running docker desktop with the built-in kubernetes cluster. I've got an image in an on-prem gitlab instance. I create a project API key and on the local machine I can do a docker push gitlab.myserver.com/group/project:latest and similarly pull the image after doing a docker login gitlab.myserver.com with the project bot username and the API key.

I create a kubernetes secret with kubectl create secret docker-registry myserver --docker-server=gitlab.myserver.com --docker-username=project_42_bot --docker-password=API_KEY

I then create a pod:

apiVersion: v1
kind: Pod
metadata:
  name: foo
spec:
  containers:
  - args:
    - data_generator.py
    image: gitlab.myserver.com/group/project:latest
    imagePullPolicy: Always
    name: foo
  imagePullSecrets:
  - name: myserver 

but I get an access forbidden on the pull.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source