2

I want to ask why the Kubernetes networking driver weave container is generating a lot of logs?

The log file size is 700MB after two days.

How can I solve that?

Brijesh Kalkani
  • 789
  • 10
  • 27
karlos
  • 807
  • 1
  • 8
  • 38
  • you cannot rotate/truncate this by native kubernetes. Perhaps,you may need to rotate it via docker. – P.... Jul 26 '21 at 16:57

1 Answers1

1

Logs in kubernetes

As it was said in comment, kubernetes is not responsible for log rotation. This is from kubernetes documentation:

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.

As proposed option, this can be managed on container's runtime level.

Please refer to Logging at the node level.

Reducing logs for Weave CNI

There are two containers in each pod. Weave itself and weave-npc (which is a network policy controller).

By default weave's log level is set to INFO. This can be changed to WARNING to see only exceptions. This can be achieved by adding --log-level flag through the EXTRA_ARGS environment variable for the weave:

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

So weave container part should look like:

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.

A lot of logs go from Weave NPC, there's an option that allows to disable NPC. However based on documentation this is a paid option based on their documentation - cloud.weave.works

Weave - Changing configuration options

moonkotte
  • 3,661
  • 2
  • 10
  • 25
  • thanks, your anwser will be the solution, Can you please tell us how to change log level inside deployment.yaml ? – karlos Jul 29 '21 at 07:44
  • @karlos Sure. Please refer to my answer as I posted this initially. It may depend on how customized your `weave cni` is and how it was installed. General answer is to edit weave\s `daemon-set` by this command `kubectl edit daemonset weave-net -n kube-system` and final result how it should look like is in my answer as well (basically you will need to add 2 lines in `env`: `- name: EXTRA_ARGS` and `value: --log-level=warning` – moonkotte Jul 29 '21 at 07:58