gabrielgio.me @ 4f75d3996ca3f455150c790e26ebd334d67b24f7

 1---
 2title:  "K8S private gitlab registry using podman"
 3date:   2021-12-28
 4tags: ['kubernetes', 'linux', 'podman', 'gitlab', 'k3s']
 5---
 6
 7This is based on [[https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/][Log in to Docker Hub]].
 8It is just a bit different to use podman
 9
10First we should take a look at podman-login man page:
11
12#+BEGIN_SRC bash
13man podman login
14#+END_SRC
15
16It will give some valueable information like the location of auth.json file.
17Now we can login using podman:
18
19#+BEGIN_SRC bash
20podman login registry.gitlab.com
21#+END_SRC
22
23Then check the ~auth.json~ file located at 
24~${XDG_RUNTIME_DIR}/containers/auth.json~ (as described by the manual).
25
26#+BEGIN_SRC bash
27cat "${XDG_RUNTIME_DIR}/containers/auth.json"
28#+END_SRC
29
30It will print your auth config:
31
32#+BEGIN_SRC json
33{
34	"auths": {
35		"registry.gitlab.com": {
36			"auth": "..."
37		}
38	}
39}
40#+END_SRC
41
42Now copy that file over to the server and register it in k8s with the following command:
43
44#+BEGIN_SRC bash
45kubectl create secret generic regcred \
46    --from-file=.dockerconfigjson=auth.json \
47    --type=kubernetes.io/dockerconfigjson
48#+END_SRC
49
50Once you have created you can list by ~kubectl get secret~:
51
52#+BEGIN_SRC
53NAME                                                    TYPE                                  DATA   AGE
54regcred                                                 kubernetes.io/dockerconfigjson        1      53s
55#+END_SRC
56
57