Skip to content

Instantly share code, notes, and snippets.

@leoh0
Last active April 14, 2022 08:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoh0/e804a74b832671bd522dc4ca3390b7ce to your computer and use it in GitHub Desktop.
Save leoh0/e804a74b832671bd522dc4ca3390b7ce to your computer and use it in GitHub Desktop.
k8s에서의 docker rate limit 문제 정리

k8s에서의 docker rate limit 문제 정리

docker rate limit 일반적인 해결 방법

Mirror registry build

Registry as a pull through cache | Docker Documentation

그래도 다수의 다양한 이미지를 풀하면 mirror registry가 rate limit에 걸릴 가능성이 존재

docker 계정을 paid 계정으로 업그레이드

paid 계정 업그레이드 만으로 문제가 해결이 되는지 너무 궁금해서 미칠거 같아서 7딸라를 지불해서 개인 docker 계정(5$는 annuary만..)을 가입해서 실험해 봄

적용 가능한 옵션

  • 익명 유저(docker login 안함)인 경우 IP 기반으로 필터링 되며 6시간동안 100번 request 가능
  • 로그인 유저(docker login 함)인 경우 계정 기반으로 필터링 되며 6시간동안 200번 request 가능
  • 지불 계정 유저(docker login 함)인 경우 아무 제한 없음

k8s node 개수 와 상관 관계

  • 익명 유저인 경우 node가 많고 각각이 외부에 직접연결되어 pub ip를 갖는경우 node * 100이라 오히려 로그인하는거보다 나을 수 있음
  • 로그인 유저일 경우 node가 많아도 로그인 계정이 1개이기 때문에 모든 node 가 다 200 번을 공유하기때문에 node가 많으면 불리
  • 지불 계정 유저는 상관 없음

테스트 방법

  • 익명 유저 테스트

RateLimit-Limit RateLimit-Remaining 참고

$ # TOKEN 발급
$ TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/alpine:pull" \
  | sed 's/.*"token":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')

$ # 이후 아래 처럼 테스트
$ curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/library/alpine/manifests/latest
HTTP/1.1 200 OK
Content-Length: 2743
Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
Docker-Content-Digest: sha256:77593302d30498d9b13d69c2fa68d22fd0e8223a19b51846cbf9c11644958adb
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:77593302d30498d9b13d69c2fa68d22fd0e8223a19b51846cbf9c11644958adb"
Date: Sun, 27 Dec 2020 02:45:51 GMT
Strict-Transport-Security: max-age=31536000
RateLimit-Limit: 100;w=21600
RateLimit-Remaining: 100;w=21600
  • 지불 계정 테스트

RateLimit-Limit RateLimit-Remaining 가 없음

$ # paid 계정 TOKEN 발급
$ # 아래 paid 계정을 넣고 테스트
$ DOCKER_USER=
$ DOCKER_PASS=
$ TOKEN=$(curl --user "${DOCKER_USER}:${DOCKER_PASS}" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/alpine:pull" \
  | sed 's/.*"token":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')

$ # 이후 아래 처럼 테스트
$ curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/library/alpine/manifests/latest
HTTP/1.1 200 OK
Content-Length: 2743
Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
Docker-Content-Digest: sha256:77593302d30498d9b13d69c2fa68d22fd0e8223a19b51846cbf9c11644958adb
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:77593302d30498d9b13d69c2fa68d22fd0e8223a19b51846cbf9c11644958adb"
Date: Sun, 27 Dec 2020 02:46:39 GMT
Strict-Transport-Security: max-age=31536000

k8s에서 paid 계정을 사용하는 방법

결론

mirror registry를 구축해서 해결 가능하나 mirror registry도 rate limit가 걸릴 수 있음

docker paid 계정이 간단한 옵션이나 cluster wide 하게 사용하려면 별도의 방법들을 적용이 필요 and 가격이 언제든 오를 수 있음

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment