当Kubernetes Pod与CrashLoopBackOff'终止时,流畅捕捉?

时间:2017-07-05 18:06:32

标签: debugging logging kubernetes kibana fluentd

我正在运行一个将简单消息写入' terminationMessagePath'然后pod退出" CrashLoopBackOff"。我希望能够通过Kibana进行调试,而不必登录到每个Kubernetes节点。我询问Kibana获取容器的最后状态值" CrashLoopBackOff"从财产原因&消息,无法找到一个条目。

我可以看到Kibana中pod的字段,但我正在寻找的字段(下面以粗体yaml格式显示)是空的。

从Kubernetes pod获取日志需要哪些配置才能流利?或配置需要从Kubernetes

设置

$ kubectl get pod_name_1 -o = yaml

terminationMessagePath: /var/log/containers/dt.log
volumeMounts:
- mountPath: /var/log/containers
  name: data
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
  name: default-token-s0w2n
  readOnly: true
dnsPolicy: ClusterFirst
nodeName: dev-master-01
restartPolicy: Always
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
  path: /var/log/containers
  name: data
- name: default-token-s0w2n
secret:
  defaultMode: 420
  secretName: default-token-s0w2n
status:
conditions:
 - lastProbeTime: null
   lastTransitionTime: 2017-07-05T14:45:11Z
   status: "True"
   type: Initialized
 - lastProbeTime: null
   lastTransitionTime: 2017-07-05T17:00:22Z
   message: 'containers with unready status: [dt-termination-demo]'
   reason: ContainersNotReady
   status: "False"
   type: Ready
 - lastProbeTime: null
   lastTransitionTime: 2017-07-05T14:45:11Z
   status: "True"
   type: PodScheduled
   containerStatuses:
 - containerID: 
   docker://9649c26527cf0e1cd3bd67ba9c606c0b78e6b4f08bacf96175627ddc7d250772
   image: debian
   imageID: docker pullable://docker.io/debian@sha256:
            7d067f77d2ae5a23fe6920f8fbc2936c4b0d417e9d01b26372561860750815f0
   lastState:
   terminated:
   containerID: docker://
   9649c26527cf0e1cd3bd67ba9c606c0b78e6b4f08bacf96175627ddc7d250772              
   exitCode: 0
   finishedAt: 2017-07-05T17:00:22Z
   **message: |
    Sleep expired**
    reason: Completed
   startedAt: 2017-07-05T17:00:12Z
   name: dt-termination-demo
   ready: false
   restartCount: 30
   state:
     waiting:
     message: Back-off 5m0s restarting failed container=dt-termination-demo 
              pod=dt-termination-demo-2814930607-8kshj_
              default(8c247b15-6190-11e7-acb7-00505691210d)
     **reason: CrashLoopBackOff**
   hostIP: 192.21.19.128
   phase: Running
   podIP: 10.0.0.8
   startTime: 2017-07-05T14:45:11Z

1 个答案:

答案 0 :(得分:0)

当Fluentd部署为DaemonSet时,它的目的是从Node和Pod收集所有日志。作为完成此操作的指南,请检查以下Yaml文件和更多相关的存储库:

如果您需要其他帮助,您也可以加入我们的Slack频道: