簡體   English   中英

無法使用Azure Kubernetes獲得服務

[英]Services with azure kubernetes not reachable

我正在嘗試配置azure kubernetes集群,並在portal.dockerized .net核心webapi項目上創建了一個集群,還將映像發布到了Azure容器注冊器上。 應用清單文件后,我得到創建服務的消息以及外部IP。 但是,當我得到豆莢時,我一直都處於“待處理”狀態

  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

對於您提供的錯誤,它表明您必須進行身份驗證才能從Azure容器注冊表中提取圖像。

實際上,您只需要獲得拉取圖像的權限, acrpull角色就足夠了。 有兩種方法可以實現它。

一種是只授予AKS訪問Azure容器注冊表的權限。 在我這邊最簡單。 只需為AKS使用的服務主體創建角色分配。 有關整個步驟,請參閱授予AKS訪問ACR的權限

另一個是使用Kubernetes機密。 它比第一個復雜一些。 您需要創建一個與使用的AKS不同的新服務主體並授予對其的訪問權限,然后使用該服務主體創建kubernetes機密。 有關整個步驟,請參閱使用Kubernetes機密進行訪問

這個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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM