无法访问azure kubernetes的服务
我正在尝试配置azure kubernetes群集,并在portal.dockerized.net core webapi项目上创建了一个群集,还将映像发布到azure容器注册。在应用清单文件之后,我得到了创建服务的消息以及外部IP。然而,当我得到吊舱时,我总是处于“待定”状态无法访问azure kubernetes的服务,azure,kubernetes,azure-aks,Azure,Kubernetes,Azure Aks,我正在尝试配置azure kubernetes群集,并在portal.dockerized.net core webapi项目上创建了一个群集,还将映像发布到azure容器注册。在应用清单文件之后,我得到了创建服务的消息以及外部IP。然而,当我得到吊舱时,我总是处于“待定”状态 NAME READY STATUS RESTARTS AGE kubdemo1api-6c67bf759f-6slh2 0/1
NAME READY STATUS RESTARTS AGE
kubdemo1api-6c67bf759f-6slh2 0/1 Pending 0 6h
这是我的yaml清单文件,有人能告诉我这里出了什么问题吗
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kubdemo1api
labels:
name: kubdemo1api
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
minReadySeconds: 30
selector:
matchLabels:
app: kubdemo1api
template:
metadata:
labels:
app: kubdemo1api
version: "1.0"
tier: backend
spec:
containers:
- name: kubdemo1api
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 30
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 30
timeoutSeconds: 10
image: my container registry image address
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 30
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 30
timeoutSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: azkubdemoapi1
spec:
ports:
-
port: 80
selector:
app: kubdemo1api
type: LoadBalancer
编辑:
输出kubectl描述吊舱是这样的吗
给你
Normal Scheduled 2m default-scheduler Successfully assigned default/kubdemo1api-697d5655c-64fnj to aks-agentpool-87689508-0
Normal Pulling 37s (x4 over 2m) kubelet, aks-agentpool-87689508-0 pulling image "myacrurl/azkubdemo:v2"
Warning Failed 37s (x4 over 2m) kubelet, aks-agentpool-87689508-0 Failed to pull image "my acr url": [rpc error: code = Unknown desc = Error response from daemon: Get https://myacrurl/v2/azkubdemo/manifests/v2: unauthorized: authentication required, rpc error: code = Unknown desc = Error response from daemon: Get https://myacrurl/v2/azkubdemo/manifests/v2: unauthorized: authentication required]
Warning Failed 37s (x4 over 2m) kubelet, aks-agentpool-87689508-0 Error: ErrImagePull
Normal BackOff 23s (x6 over 2m) kubelet, aks-agentpool-87689508-0 Back-off pulling image "myacrlurl/azkubdemo:v2"
Warning Failed 11s (x7 over 2m) kubelet, aks-agentpool-87689508-0 Error: ImagePullBackOff
这个Yaml是错误的,你能否提供正确的Yaml,意图是错误的。试试下面的YAML
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kubdemo1api
labels:
name: kubdemo1api
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
minReadySeconds: 30
selector:
matchLabels:
app: kubdemo1api
template:
metadata:
labels:
app: kubdemo1api
version: "1.0"
tier: backend
spec:
containers:
- name: kubdemo1api
image: nginx
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /
port: 80
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 30
timeoutSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: azkubdemoapi1
spec:
ports:
- port: 80
selector:
app: kubdemo1api
type: LoadBalancer
这个Yaml是错误的,你能否提供正确的Yaml,意图是错误的。试试下面的YAML
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kubdemo1api
labels:
name: kubdemo1api
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
minReadySeconds: 30
selector:
matchLabels:
app: kubdemo1api
template:
metadata:
labels:
app: kubdemo1api
version: "1.0"
tier: backend
spec:
containers:
- name: kubdemo1api
image: nginx
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /
port: 80
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 30
timeoutSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: azkubdemoapi1
spec:
ports:
- port: 80
selector:
app: kubdemo1api
type: LoadBalancer
对于您提供的错误,它表明您必须进行身份验证才能从Azure容器注册表中提取映像 实际上,您只需要获得拉取图像的权限,
acrplall
角色就足够了。实现这一目标有两种方法
一种是只授予AKS对Azure容器注册表的访问权。这对我来说是最简单的。只需要为AKS使用的服务主体创建角色分配。有关整个步骤,请参见
另一个是使用库伯内特的秘密。它比第一个稍微复杂一点。您需要创建一个不同于AKS使用的服务主体的新服务主体,并授予其访问权限,然后使用该服务主体创建kubernetes机密。有关整个步骤,请参阅。有关您提供的错误,它表明您必须进行身份验证才能从Azure容器注册表中提取映像 实际上,您只需要获得拉取图像的权限,
acrplall
角色就足够了。实现这一目标有两种方法
一种是只授予AKS对Azure容器注册表的访问权。这对我来说是最简单的。只需要为AKS使用的服务主体创建角色分配。有关整个步骤,请参见
另一个是使用库伯内特的秘密。它比第一个稍微复杂一点。您需要创建一个不同于AKS使用的服务主体的新服务主体,并授予其访问权限,然后使用该服务主体创建kubernetes机密。有关整个步骤,请参见。能否共享问题中添加的kubdemo1api-6c67bf759f-6slh2的
kubectl Descripte pod kubdemo1api-6c67bf759f-6slh2的输出错误显示您需要通过注册表验证才能提取图像。您可以使用imagePullSecrets
对注册表进行身份验证。看,还有问题吗?或者,如果这个建议对你有用,我会给其他遇到同样问题的人补充一个答案。请让我知道结果。使用imagePullSecrets进行身份验证为我完成了任务。然而,在此之前,我必须在集群中创建可供节点使用的机密。您能否共享问题中添加的kubectl description pod kubdemo1api-6c67bf759f-6slh2的输出错误显示您需要通过注册表身份验证才能获取映像。您可以使用imagePullSecrets
对注册表进行身份验证。看,还有问题吗?或者,如果这个建议对你有用,我会给其他遇到同样问题的人补充一个答案。请让我知道结果。使用imagePullSecrets进行身份验证为我完成了任务。然而,在此之前,我必须在集群中创建可供节点使用的秘密。