如何调试minikube错误?

时间:2018-01-18 13:31:17

标签: debugging kubernetes minikube

我正在尝试使用Cassandra数据库运行pod,下面是其部署说明:

- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: cassandra
    namespace: test
  spec:
    progressDeadlineSeconds: 600
    replicas: 1
    revisionHistoryLimit: 2
    selector:
      matchLabels:
        app: cassandra
    template:
      metadata:
        labels:
          app: cassandra
      spec:
        containers:
        - env:
          - name: MAX_HEAP_SIZE
            value: 1024M
          - name: HEAP_NEWSIZE
            value: 1024M
          image: cassandra:3.10
          name: cassandra
          ports:
          - containerPort: 9042
            protocol: TCP

创建pod然后进入CrashLoopBackOff。当我尝试kubectl describe这就是我所看到的:

Name:           cassandra-6b5f5c46cf-zpwlx
Namespace:      test
Node:           minikube/192.168.99.102
Start Time:     Thu, 18 Jan 2018 15:26:05 +0200
Labels:         app=cassandra
                pod-template-hash=2619170279
Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"test","name":"cassandra-6b5f5c46cf","uid":"22f28f45-fc53-11e7-ae64-08002798f...
Status:         Running
IP:             172.17.0.7
Controlled By:  ReplicaSet/cassandra-6b5f5c46cf
Containers:
  cassandra:
    Container ID:   docker://b3477788391622145350e870c00e19561ee662946aa5a307cc8bea28fc874544
    Image:          cassandra:3.10
    Image ID:       docker-pullable://cassandra@sha256:af21476b230507c6869d758e4dec134886210bd89d56deade90bc835a1c0af37
    Port:           9042/TCP
    State:          Terminated
      Reason:       Error
      Exit Code:    137
      Started:      Thu, 18 Jan 2018 15:26:26 +0200
      Finished:     Thu, 18 Jan 2018 15:26:28 +0200
    Last State:     Terminated
      Reason:       Error
      Exit Code:    137
      Started:      Thu, 18 Jan 2018 15:26:11 +0200
      Finished:     Thu, 18 Jan 2018 15:26:14 +0200
    Ready:          False
    Restart Count:  2
    Environment:
      MAX_HEAP_SIZE:  1024M
      HEAP_NEWSIZE:   1024M
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-77lfg (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          False 
  PodScheduled   True 
Volumes:
  default-token-77lfg:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-77lfg
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     <none>
Events:
  Type     Reason                 Age               From               Message
  ----     ------                 ----              ----               -------
  Normal   Scheduled              28s               default-scheduler  Successfully assigned cassandra-6b5f5c46cf-zpwlx to minikube
  Normal   SuccessfulMountVolume  28s               kubelet, minikube  MountVolume.SetUp succeeded for volume "default-token-77lfg"
  Normal   Pulled                 7s (x3 over 27s)  kubelet, minikube  Container image "cassandra:3.10" already present on machine
  Normal   Created                7s (x3 over 27s)  kubelet, minikube  Created container
  Normal   Started                6s (x3 over 27s)  kubelet, minikube  Started container
  Warning  BackOff                4s (x2 over 18s)  kubelet, minikube  Back-off restarting failed container
  Warning  FailedSync             4s (x2 over 18s)  kubelet, minikube  Error syncing pod

错误报告完全没用:它只是一些通用消息,无法解释问题。

pod的描述中有一段可疑的段落:卷。我没有要求为这个容器安装任何卷。然而,经过一些网络搜索,我认为这个容器中安装的任何内容只是Kubernetes如何工作的一些技术方面,并没有实际意义。

无论如何:我怎样才能从minikube获得更多关于它试图做什么以及失败的信息?

1 个答案:

答案 0 :(得分:3)

您的广告单元处于CrashLoopBackoff状态。这意味着你的pod中的容器正在终止它的执行,kubernetes正试图再次运行它,但它再次终止,给你一个Crash Loop

我建议您通过运行来查看容器的输出:

kubectl -n test logs -f cassandra-6b5f5c46cf-zpwlx

这应该是cassandra的输出,应该解释cassandra没有运行的原因。