gpt4 book ai didi

kubernetes - kubectl pod无法下拉AWS ECR镜像

转载 作者:行者123 更新时间:2023-12-02 11:29:00 25 4
gpt4 key购买 nike

步骤1 sudo $(aws ecr get-login --no-include-email --region xx-xxxx-x)
步骤2 curl -LSs https://github.com/fermayo/ecr-k8s-secret/raw/master/gen-secret.sh | bash -
步骤3 kubectl describe secret aws-ecr-credentials

Name:         aws-ecr-credentials
Namespace: default
Labels: <none>
Annotations: <none>

Type: kubernetes.io/dockerconfigjson

Data

.dockerconfigjson: 32 bytes

步骤4 kubectl describe pod x

Warning Failed 5s kubelet, ip-10-46-250-151 Failed to pull image "my-account.dkr.ecr.us-east-1.amazonaws.com/my-image:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://my-account.dkr.ecr.us-east-1.amazonaws.com/my-image/latest: no basic auth credentials



pods 为什么不能拉下图像?

最佳答案

创建了一个从AWS-ECR中提取 token 的脚本

ACCOUNT=xxxxxxxxxxxx
REGION=xx-xxxx-x
SECRET_NAME=${REGION}-ecr-registry
EMAIL=email@email.com

#
#

TOKEN=`aws ecr --region=$REGION get-authorization-token --output text \
--query authorizationData[].authorizationToken | 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}"

并创建了一个Linux cronjob以每10小时运行一次

关于kubernetes - kubectl pod无法下拉AWS ECR镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53852007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com