참고
- https://bscnote.tistory.com/105
ACCOUNT=0402177XXXXX #사용자 Root 계정의 Account ID 입니다
REGION=ap-northeast-2
SECRET_NAME=${REGION}-ecr-registry #kubernetes Secret 이름입니다. 나중에 확인해봅시다!
EMAIL=spwdlask123@gmail.com #임의 이메일입니다
TOKEN=`aws ecr --region=$REGION get-authorization-token --output text --query authorizationData[].authorizationToken | base64 -d | cut -d: -f2`
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}"
또는 kubectl get secret, kubectl describe secret ap-northeast-2ecr-registry를 사용합니다. Token을 확인하고 싶다면? kubectl get secret ap-northeast-2-ecr-registry --output=yaml을 이용합니다.
결과는 아래 형태일 겁니다!!
{"auths":{"your.private.registry.example.com":{"username":"janedoe","password":"xxxxxxxxxxx","email":"jdoe@example.com","auth":"c3R...zE2"}}}
cat << EOF > deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: front
labels:
app: ecr
spec:
replicas: 2
selector:
matchLabels:
app: ecr
template:
metadata:
labels:
app: ecr
spec:
containers:
- name: ecr-container
image: xxxxxxxxxx23.dkr.ecr.ap-northeast-2.amazonaws.com/wsi-ecr-repo:latest
ports:
- containerPort: 80
imagePullSecrets:
- name: ap-northeast-2-ecr-registry
EOF
kubectl apply -f deployment.yaml