Pull images from Gitlab Container Registry

Page content

Set up in GitLab

Create user token at your GitLab. (https://{{ your_GitLab_server_domain }}/profile/personal_access_tokens) The token expire in around 14 days as default.

Enable Container Regository also.

Here is my note.

Create a Secret

Create a Secret to access GitLab Container Registry.

kubectl create secret docker-registry my-reg --docker-server={{ your_GitLab_server_domain }}:5050 --docker-username={{ your-GitLab-name }} --docker-password={{ token_you_issued_at_your_GitLab_or_your_password }}

Docker login

In the worker nodes, add a GitLaB’s SSL to the chain.

Copy CA cert under /etc/ssl/certs/. There are a lot of CA certificates. sudo update-ca-certificates sudo service docker restart

In the worker nodes, login to the docker.

docker start
docker login {{ your_GitLab_server_domain }}:5050

Please note that, docker login uses port 443 and 80 between your GitLab server, you should open the port if they are closed.

Deploy

kubectl create deployment gitlabrepositories --image={{ your_GitLab_server_domain }}:5050/groupname/reponame
kubectl edit deployment gitlabrepositories
# dnsPolicy: ClusterFirst
#        imagePullSecrets:
#        - name: docker-registry

References

https://gitlab.com/gitlab-org/gitlab-foss/-/issues/41265