728x90
반응형
kubernetes 클러스터 container에서 ecr login 인증을 얻기 위해 secret을 생성한 이후 클러스터 service account에 등록하여 ecr 인증이 되도록 해본다.
1. aws cli를 통해 ecr login
aws ecr get-login-password --region ap-southeast-1 | docker login --username AWS --password-stdin {accountId}.dkr.ecr.ap-southeast-1.amazonaws.com
2. ecr login을 위한 secret 생성을 위한 password 얻어오기
$ aws ecr get-login-password --region ap-southeast-1
eyJwYXl....oxNjUyNzQxNjgzfQ==
3. secret 생성
$ kubectl create secret docker-registry regcred --docker-server={accountId}.dkr.ecr.ap-southeast-1.amazonaws.com --docker-username=AWS --docker-password=eyJwYXl....oxNjUyNzQxNjgzfQ==
4. 생성된 secret을 인증이 필요한 namespace service account에 적용 ( default namespace를 기준으로 작성)
$ kubectl edit sa default
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: ServiceAccount
metadata:
creationTimestamp: "2022-05-11T01:30:02Z"
name: default
namespace: default
resourceVersion: "145397"
uid: 7f454e9f-ca96-4f18-b2c2-ee342211fa8b
secrets:
- name: default-token-n5frh
imagePullSecrets: <-- 생성한 secret 적용
- name: regcred
5. Pod 을 재시작 이후 정상적으로 ecr에서 image pull이 되는지 확인
728x90
반응형
'Programming > Kubernetes' 카테고리의 다른 글
[kubernetes][redis] kubernetes에 redis 간단 설치 (0) | 2022.05.23 |
---|---|
[Kubernetes] command terminated with exit code 137 (0) | 2022.05.17 |
[Kubernetes] kubelet error - part of the existing bootstrap client certificate is expired (0) | 2022.03.14 |
[Kubernets] coredns에 multiple consul dns 등록하기 (0) | 2022.02.09 |
[Kubernetes] k8s HA control-plane node 추가하기 (Add control-plane node) (0) | 2022.01.12 |
댓글