我想从AWS ECR部署镜像到Kubernetes。我使用这个命令来获取token:
TOKEN=`aws ecr get-login-password --region us-east-1 | cut -d' ' -f6`
kubectl delete secret -n default --ignore-not-found awsecr-cred
kubectl create secret -n default docker-registry awsecr-cred --docker-server=123456789.dkr.ecr.us-east-1.amazonaws.com/test-gateway --docker-username=AWS --docker-password=$TOKEN --namespace=default
在pod日志中,我得到错误:
Failed to pull image "123456789.dkr.ecr.us-east-1.amazonaws.com/test-gateway:0.0.1": rpc error: code = Unknown desc = failed to pull and unpack image "123456789.dkr.ecr.us-east-1.amazonaws.com/test-gateway:0.0.1": failed to resolve reference "123456789.dkr.ecr.us-east-1.amazonaws.com/test-gateway:0.0.1": pulling from host 123456789.dkr.ecr.us-east-1.amazonaws.com failed with status code [manifests 0.0.1]: 401 Unauthorized
当我运行aws ecr get-login-password --region us-east-1 | cut -d' ' -f6
时,我得到token。你知道我哪里错了吗?
1条答案
按热度按时间dfuffjeb1#
你的部署yaml是什么样子的?您需要为pod指定
imagePullSecrets
。它应该看起来像这样:你可以在这里找到一个完整的例子。