温馨提示:本文翻译自stackoverflow.com,查看原文请点击:kubectl - Why an application deployment status is "Available:0" when service is deployed properly in minikube?

kubectl - 在minikube中正确部署服务后,为什么应用程序部署状态为“可用:0”?

发布于 2020-03-27 10:23:47

我正在尝试部署应用程序的后端组件以测试REST API。我已经泊坞窗化了组件并在minikube中创建了映像。我创建了yaml用于部署和创建服务文件。现在,当我尝试通过sudo kubectl create -f frontend-deployment.yaml进行部署时,它的部署没有任何错误,但是当我检查部署状态时,将显示以下内容:

NAME   READY   UP-TO-DATE   AVAILABLE   AGE
back   0/3     3            0           2m57s

有趣的是,可以使用与此部署相对应的服务。

NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
back         ClusterIP   10.98.73.249   <none>        8080/TCP         3m9s

我还尝试通过像单独运行deplyment statemnts来创建部署,sudo kubectl run back --image=back --port=8080 --image-pull-policy Never但是结果是相同的。

这是我的`deployment.yaml文件的样子:

kind: Service
apiVersion: v1
metadata:
  name: back
spec:
  selector:
    app: back
  ports:
  - protocol: TCP
    port: 8080
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: back
spec:
  selector:
      matchLabels:
        app: back
  replicas: 3
  template:
    metadata:
      labels:
        app: back
    spec:
      containers:
        - name: back
          image: back
          imagePullPolicy: Never
          ports:
            - containerPort: 8080

我该如何启动并运行此部署,因为这会导致应用程序前端出现内部服务器错误?

吊舱的描述

Name:           back-7fd9995747-nlqhq
Namespace:      default
Priority:       0
Node:           minikube/10.0.2.15
Start Time:     Mon, 15 Jul 2019 12:49:52 +0200
Labels:         pod-template-hash=7fd9995747
                run=back
Annotations:    <none>
Status:         Running
IP:             172.17.0.7
Controlled By:  ReplicaSet/back-7fd9995747
Containers:
  back:
    Container ID:   docker://8a46e16c52be24b12831bb38d2088b8059947d099299d15755d77094b9cb5a8b
    Image:          back:latest
    Image ID:       docker://sha256:69218763696932578e199b9ab5fc2c3e9087f9482ac7e767db2f5939be98a534
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Mon, 15 Jul 2019 12:49:54 +0200
      Finished:     Mon, 15 Jul 2019 12:49:54 +0200
    Ready:          False
    Restart Count:  1
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-c247f (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-c247f:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-c247f
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason     Age              From               Message
  ----     ------     ----             ----               -------
  Normal   Scheduled  6s               default-scheduler  Successfully assigned default/back-7fd9995747-nlqhq to minikube
  Normal   Pulled     4s (x2 over 5s)  kubelet, minikube  Container image "back:latest" already present on machine
  Normal   Created    4s (x2 over 5s)  kubelet, minikube  Created container back
  Normal   Started    4s (x2 over 5s)  kubelet, minikube  Started container back
  Warning  BackOff    2s (x2 over 3s)  kubelet, minikube  Back-off restarting failed container

查看更多

查看更多

提问者
rehan
被浏览
89
mebius99 2019-07-03 21:19

如您所见,三个Pod中有零个处于“就绪”状态:

NAME   READY   AVAILABLE
back   0/3     0 

要了解发生了什么,您应该检查基础Pod:

$ kubectl get pods -l app=back

然后在事件描述中查看事件:

$ kubectl describe pod back-...

发布
问题

分享
好友

手机
浏览

扫码手机浏览