gabrielgio.me @ c46f9798ffd33434de8bba46d9f597ed5a70caf5

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