azure - AWS ECR PULL 没有基本的身份验证凭证
问题描述
我正在使用 Terraform 部署 Azure K8s 集群,并且图像托管在 Amazon ECR 中。从 ECR 拉取映像时部署失败,并出现以下错误:
Failed to pull image "tooot.eu-west-1.amazonaws.com/app-t:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://tooot.eu-west-1.amazonaws.com/v2/app-t/manifests/latest: no basic auth credentials
以下是我在 terraform 模板中的 kuberentes 资源
metadata {
name = "terraform-app-deployment-example"
labels {
test = "app-deployment"
}
}
spec {
replicas = 6
selector {
match_labels {
test = "app-deployment"
}
}
template {
metadata {
labels {
test = "app-deployment"
}
}
spec {
container {
image = "toot.eu-west-1.amazonaws.com/app-t:latest"
name = "app"
}
}
}
}
}`
解决方案
基本上,您缺乏从 AWS 提取图像的凭据。
您需要创建一个regcred,其中包含登录凭据:
https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
之后,您需要在 terraform 配置中添加 regcred。我没有使用模板,但在部署规范中,您将添加一个名为 imagePullSecrets 的字段。
https://www.terraform.io/docs/providers/kubernetes/r/deployment.html
imagePullSecrets 描述:
image_pull_secrets - (可选)ImagePullSecrets 是对同一命名空间中秘密的引用的可选列表,用于拉取此 PodSpec 使用的任何图像。如果指定,这些秘密将被传递给各个 puller 实现供他们使用。例如,在 docker 的情况下,只有 DockerConfig 类型的机密被接受
推荐阅读
- python - 在 pandas 的数据框中“展平” JSON 的最有效方法是什么?
- python - 如何将变量与集合进行比较(查看是否有重复项),如果有,我如何删除它们并重复该过程?
- java - 对称树中与遍历有关的问题
- kubernetes - Kubernetes 集群的自定义指标 API 服务安装
- mysql - 在检查行是否已存在时,选择不会从表中获取任何内容
- dns - 如何将 www 和非 www 站点指向 Route53 中的 ALB
- javascript - 运行使用 PouchDB Asyncstorage 适配器的 Jest 测试时出现导入错误
- bios - 如何在 ACPI dsl/asl 源文件中区分 Windows、MacOS (Darwin) 和 Linux?
- python - 如何访问函数内部的列表而不返回它?
- java - 使用 Micronaut 提供静态资源,具有目录层次结构