为什么 kubernetes 网络驱动程序编织生成大日志文件

why kubernetes networking driver weave generating big log file

我想问一下为什么 Kubernetes 网络驱动程序 weave 容器会生成大量日志?

两天后日志文件大小为 700MB。

我该如何解决?

登录 kubernetes

正如评论中所说,kubernetes 不负责日志轮换。这是来自 kubernetes 文档:

An important consideration in node-level logging is implementing log rotation, so that logs don't consume all available storage on the node. Kubernetes is not responsible for rotating logs, but rather a deployment tool should set up a solution to address that. For example, in Kubernetes clusters, deployed by the kube-up.sh script, there is a logrotate tool configured to run each hour. You can also set up a container runtime to rotate an application's logs automatically.

作为提议的选项,这可以在容器的运行时级别进行管理。

请参考Logging at the node level

减少 Weave CNI 的日志

每个 pod 中有两个容器。 Weave 本身和 weave-npc(这是一个网络策略控制器)。

默认情况下,weave 的日志级别设置为 INFO。这可以更改为 WARNING 以仅查看异常。这可以通过在编织的 EXTRA_ARGS 环境变量中添加 --log-level 标志来实现:

$ kubectl edit daemonset weave-net -n kube-system

所以 weave container 部分应该如下所示:

spec:
  containers:
  - command:
    - /home/weave/launch.sh
    env:
    - name: HOSTNAME
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: spec.nodeName
    - name: EXTRA_ARGS # this was added with value below!
      value: --log-level=warning
    - name: INIT_CONTAINER
      value: "true"
    image: docker.io/weaveworks/weave-kube:2.8.1
    imagePullPolicy: IfNotPresent
    name: weave 

Weave - logs level.

很多日志来自 Weave NPC,有一个选项允许 disable NPC。但是,根据文档,这是基于其文档的付费选项 - cloud.weave.works

Weave - Changing configuration options