티스토리 뷰

Containerd를 사용하는 K3s 환경에서 dockerhub가 아닌 registry 추가를 해야할 경우가 있다.
이러한 경우 다음과 같은 설정을 통해 추가가 가능하다.

참고
/var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl 로 configm.toml 적용도 가능한데
실제 crictl info에서는 적용된 registry를 확인할수 없어 해당 기능은 사용을 권장하지 않는다.

registy 설정 추가

K3s에서는 registry 추가를 다음과 같이 할수 있다.

root@k3s-server:~# cat /etc/rancher/k3s/registries.yaml
mirrors:
  "10.10.10.5:5000":
    endpoint:
      - "http://10.10.10.5:5000"
configs:
  "10.10.10.5:5000":
    auth:
      username: jacobbaek
      password: jacobbaek_password

위와 같이 registries.yaml 파일을 해당 경로에 생성한다.
(k3s-agent 인경우 /etc/rancher/k3s 디렉토리가 미존재할수도 있으니 이는 필요시 생성해준다.)

K3s 서버인 경우 다음과 같이 systemd k3s service를 재시작한다.

root@k3s-server:~# systemctl restart k3s

참고
k3s 서버나 k3s-agent 모두 동일하게 /etc/rancher/k3s/registries.yaml 파일 및 내용을 추가한후 서비스

K3s agent 인경우 다음과 같이 systemd k3s-agent service를 재시작한다.

root@k3s-agent1:~# systemctl restart k3s-agent

서비스 재시작후 다음과 같은 registry가 추가된것을 crictl info 로 확인할 수 있다.

root@k3s-server:~# crictl info | jq -r '.config.registry'
{
  "mirrors": {
    "10.10.10.5:5000": {
      "endpoint": [
        "http://10.10.10.5:5000"
      ],
      "rewrite": null
    },
    "docker.io": {
      "endpoint": [
        "https://registry-1.docker.io"
      ],
      "rewrite": null
    }
  },
  "configs": {
    "10.10.10.5:5000": {
      "auth": {
        "username": "jacobbaek",
        "password": "jacobbaek_password",
        "auth": "",
        "identitytoken": ""
      },
      "tls": null
    }
  },
  "auths": null,
  "headers": null
}

http라고 별다른 설정이 있지는 않고 위와 같이 mirrors 및 configs에 추가되면 되고 인증정보가 필요한 경우 configs."mirror_addr".auth를 추가해주면 된다.

참고사이트

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함