我正在使用 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/ 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 https://www.terraform.io/docs/providers/kubernetes/r/deployment.html
imagePullSecrets 说明:
image_pull_secrets -(可选)ImagePullSecrets 是对同一命名空间中的机密引用的可选列表,用于拉取此 PodSpec 使用的任何图像。如果指定,这些秘密将传递给各个拉取器实现以供他们使用。例如,对于 docker,仅尊重 DockerConfig 类型机密
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)