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

时间:2019-07-02 13:08:22

标签: deployment kubectl minikube

我正在尝试部署应用程序的后端组件以测试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

我还尝试通过像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

1 个答案:

答案 0 :(得分:0)

您可以看到三个Pod中有零个处于“就绪”状态:

NAME   READY   AVAILABLE
back   0/3     0 

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

$ kubectl get pods -l app=back

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

$ kubectl describe pod back-...