azure - 在 Kubernetes 中获取“未就绪状态的容器:[]”错误
问题描述
我正在尝试在 AKS 中部署 Kubernetes Pod(我是 Kubernetes 新手,所以在这个阶段,我只想创建一个容器,部署到 Kubernetes 并连接到它)。
我的 Yaml 文件如下:
apiVersion: v1
kind: Pod
spec:
containers:
- name: dockertest20190205080020
image: dockertest20190205080020.azurecr.io
ports:
- containerPort: 443
metadata:
name: my-test
我在 Azure Container Registry 中创建了映像,并根据 CLI 成功将其部署到 Kubernetes。
部署后,我使用了以下命令:
kubectl get service
它告诉我没有外部 IP 可以连接。然后我尝试了:
kubectl describe pod my-test
这给出了以下错误:
Events:
Warning Failed 4m (x2221 over 8h) kubelet, aks-nodepool1-27401563-2 Error: ImagePullBackOff
Normal BackOff 0s (x2242 over 8h) kubelet, aks-nodepool1-27401563-2 Back-off pulling image "dockertest20190205080020.azurecr.io"
然后我尝试编辑部署:
kubectl edit pods my-test
哪个游戏我的错误:
message: 'containers with unready status: [dockertest20190205080020]'
我不太确定我的下一个诊断步骤是什么。我的印象是容器或容器注册表存在问题,但我不确定如何确定可能是什么。
解决方案
这里发生了什么(很可能) - 您的 AKS 无权从您的 ACR 中提取图像(这是默认行为)。您需要授予那些(链接):
#!/bin/bash
AKS_RESOURCE_GROUP=myAKSResourceGroup
AKS_CLUSTER_NAME=myAKSCluster
ACR_RESOURCE_GROUP=myACRResourceGroup
ACR_NAME=myACRRegistry
# Get the id of the service principal configured for AKS
CLIENT_ID=$(az aks show --resource-group $AKS_RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query "servicePrincipalProfile.clientId" --output tsv)
# Get the ACR registry resource id
ACR_ID=$(az acr show --name $ACR_NAME --resource-group $ACR_RESOURCE_GROUP --query "id" --output tsv)
# Create role assignment
az role assignment create --assignee $CLIENT_ID --role acrpull --scope $ACR_ID
另一种方法是仅使用 docker login secret(该文章也提到了这一点)。
图像名称将是
clrtacr.azurecr.io/dns:tag (或没有最新标签)
推荐阅读
- javascript - 使用 Openseadragon 在大图像上使用 IE 11/Edge 得到“IndexSizeError”
- python-2.7 - 在 Python 中结束循环时停止 While 循环
- ubuntu - 粉碎(破折号)不在ubuntu上发送事件
- css - Jekyll - 推荐的文件导入方式
- javascript - React Native,Flex Box 有问题
- vba - 优化 VBA 程序
- python - 将标签、文本框和按钮添加到 tkinter 画布
- regex - 使用 PCRE 正则表达式从 LOG 中列出所有 ipv4 地址
- java - 无法读取路径的文件,因为它包含希腊字符
- mysql - 仅显示同时拥有这两种类型的记录且仅显示这些记录的客户