Kubernetes基本Pod日志记录 [英] Kubernetes basic pod logging

查看:170
本文介绍了Kubernetes基本Pod日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置基本日志记录,以便将所有pod日志都放在一个地方.以下是我创建的pod-spec,但在提到的位置找不到日志的踪迹.下面的模板中可能缺少什么?

Hi I'm trying to setup basic logging to get all my pod logs at a single place. Following is the pod-spec I have created but couldn't find the trace of the logs in the location mentioned. What could be missing in the template below?

    apiVersion: v1
    kind: Pod
    metadata:
      name: counter
    spec:
      containers:
    - name: count
        image: busybox
        args: [/bin/sh, -c,
        'i=0; while true; do echo "$i: $(date)" >> /u01/kubernetes_prac/logs/log_output.txt; i=$((i+1)); sleep 1; done']
        volumeMounts:
        - name: varlog
          mountPath: /u01/kubernetes_prac/logs
      volumes:
      - name: varlog
        emptyDir: {}

推荐答案

尝试一下:

volumes:
  - name: varlog
    hostPath:
      path: /tmp/logs

并检查该节点上的节点日志

and check the node logs on that location

这篇关于Kubernetes基本Pod日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆