( https://bscnote.tistory.com/105 글을 참고 했으며 해당 문서에서 에러나는 부분이 있어서 수정 게시합니다. ) 쿠버네티스에서 AWS ECR에 있는 이미지를 배포할 때 아래와 같은 에러가 뜨는 경우
|
( repository-url ) not found: does not exist or no pull access |
아래와 같이 Secret을 생성한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#!/bin/bash ACCOUNT=111222333444 # AWS ECR 이미지 URL 맨 앞에 기재되어있는 12자리 숫자 REGION=ap-northeast-2 # 리전 명 SECRET_NAME=${REGION}-ecr-registry # 생성될 secret의 이름 EMAIL=akasilvernine@gmail.com # 임의의 이메일 #aws-cli 2.0.29 버전에서는 authorizationData #aws-cli 1.15.80 버전에서는 authorizationData[].authorizationToken TOKEN=`aws ecr --region=$REGION get-authorization-token --output text --query authorizationData | base64 -d | cut -d: -f2` # Create or replace registry secret kubectl delete secret --ignore-not-found $SECRET_NAME kubectl create secret docker-registry $SECRET_NAME \ --docker-server=https://${ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com \ --docker-username=AWS \ --docker-password="${TOKEN}" \ --docker-email="${EMAIL}" |
생성한 Secret을 아래와 같이 imagePullSecrets 항목에서 사용한다.
|
apiVersion: apps/v1beta2 kind: Deployment metadata: name: ... namespace: ... spec: containers: - name: ... image: 111222333444.dkr.ecr.ap-northeast-2.amazonaws.com/bar:latest imagePullSecrets: - name: ap-northeast-2-ecr-registry # 생성한 secret명 넣기 |