首页 > 解决方案 > 如何为 EKS 集群刷新 AWS 身份验证令牌

问题描述

我正在通过以下方式进行身份验证

首先,我通过以下方式向 AWS 进行身份验证

aws ecr get-login-password --region cn-north-1 | docker login --username AWS --password-stdin xxxxxxxxxx.dkr.ecr.cn-north-1.amazonaws.com.cn

然后我创建了regcred我在部署配置中引用的文件

kubectl create secret generic regcred --from-file=.dockerconfigjson=/home/noobskie/.docker/config.json --type=kubernetes.io/dockerconfigjson

所以这在前 12 小时内运行良好,但现在 AWS 令牌已过期,我无法弄清楚如何正确刷新它。我重新运行了第一个命令,但它不起作用。

我得到的错误是

Error response from daemon: pull access denied for xxxxxxxxxxx.dkr.ecr.cn-north-1.amazonaws.com.cn/baopals, repository does not exist or may require 'docker login': denied: Your authorization token has expired. Reauthenticate and try again.

编辑

我刚刚发现我可以使用以下命令重新配置,但我很好奇这是否是处理它的正确方法以及是否提供任何其他 AWS 方法。

kubectl create secret generic regcred --from-file=.dockerconfigjson=/home/noobskie/.docker/config.json --dry-run -o yaml | kubectl apply -f -

标签: amazon-web-servicesdockerkubernetes

解决方案


如果安装并配置了 aws-cli 和 aws-iam-authenticator,请使用以下命令生成令牌。

aws-iam-authenticator token -i cluster name

推荐阅读