Allow disabling calico CNI logs with calico_cni_log_file_path (#8921)

* Allow disabling calico CNI logs with calico_cni_log_file_path

Calico CNI logs up to 1G if it log a lot with current default settings:
log_file_max_size	100	Max file size in MB log files can reach before they are rotated.
log_file_max_age	30	Max age in days that old log files will be kept on the host before they are removed.
log_file_max_count	10	Max number of rotated log files allowed on the host before they are cleaned up.

See https://projectcalico.docs.tigera.io/reference/cni-plugin/configuration#logging

To save disk space, make the path configurable and allow disabling this log by setting
`calico_cni_log_file_path: false`

* Fix markdown

* Update roles/network_plugin/canal/templates/cni-canal.conflist.j2

Co-authored-by: Kenichi Omichi <ken1ohmichi@gmail.com>

Co-authored-by: Kenichi Omichi <ken1ohmichi@gmail.com>
This commit is contained in:
Ilya Margolin 2022-06-07 18:22:56 +02:00 committed by GitHub
parent 9074bd297b
commit cc6cbfbe71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 2 deletions

View file

@ -315,6 +315,13 @@ calico_ipam_host_local: true
Refer to Project Calico section [Using host-local IPAM](https://docs.projectcalico.org/reference/cni-plugin/configuration#using-host-local-ipam) for further information. Refer to Project Calico section [Using host-local IPAM](https://docs.projectcalico.org/reference/cni-plugin/configuration#using-host-local-ipam) for further information.
### Optional : Disable CNI logging to disk
Calico CNI plugin logs to /var/log/calico/cni/cni.log and to stderr.
stderr of CNI plugins can be found in the logs of container runtime.
You can disable Calico CNI logging to disk by setting `calico_cni_log_file_path: false`.
## eBPF Support ## eBPF Support
Calico supports eBPF for its data plane see [an introduction to the Calico eBPF Dataplane](https://www.projectcalico.org/introducing-the-calico-ebpf-dataplane/) for further information. Calico supports eBPF for its data plane see [an introduction to the Calico eBPF Dataplane](https://www.projectcalico.org/introducing-the-calico-ebpf-dataplane/) for further information.

View file

@ -72,6 +72,9 @@ calico_felix_prometheusprocessmetricsenabled: true
calico_loglevel: info calico_loglevel: info
calico_node_startup_loglevel: error calico_node_startup_loglevel: error
# Set log path for calico CNI plugin. Set to false to disable logging to disk.
calico_cni_log_file_path: /var/log/calico/cni/cni.log
# Enable or disable usage report to 'usage.projectcalico.org' # Enable or disable usage report to 'usage.projectcalico.org'
calico_usage_reporting: false calico_usage_reporting: false

View file

@ -15,7 +15,9 @@
{% endif %} {% endif %}
"type": "calico", "type": "calico",
"log_level": "info", "log_level": "info",
"log_file_path": "/var/log/calico/cni/cni.log", {% if calico_cni_log_file_path %}
"log_file_path": "{{ calico_cni_log_file_path }}",
{% endif %}
{% if calico_datastore == "etcd" %} {% if calico_datastore == "etcd" %}
"etcd_endpoints": "{{ etcd_access_addresses }}", "etcd_endpoints": "{{ etcd_access_addresses }}",
"etcd_cert_file": "{{ calico_cert_dir }}/cert.crt", "etcd_cert_file": "{{ calico_cert_dir }}/cert.crt",

View file

@ -28,3 +28,6 @@ flannel_cpu_requests: 50m
kube_etcd_cacert_file: ca.pem kube_etcd_cacert_file: ca.pem
kube_etcd_cert_file: node-{{ inventory_hostname }}.pem kube_etcd_cert_file: node-{{ inventory_hostname }}.pem
kube_etcd_key_file: node-{{ inventory_hostname }}-key.pem kube_etcd_key_file: node-{{ inventory_hostname }}-key.pem
# Set log path for calico CNI plugin. Set to false to disable logging to disk.
calico_cni_log_file_path: /var/log/calico/cni/cni.log

View file

@ -12,7 +12,9 @@
"etcd_cert_file": "{{ canal_cert_dir }}/cert.crt", "etcd_cert_file": "{{ canal_cert_dir }}/cert.crt",
"etcd_ca_cert_file": "{{ canal_cert_dir }}/ca_cert.crt", "etcd_ca_cert_file": "{{ canal_cert_dir }}/ca_cert.crt",
"log_level": "info", "log_level": "info",
"log_file_path": "/var/log/calico/cni/cni.log", {% if calico_cni_log_file_path %}
"log_file_path": "{{ calico_cni_log_file_path }}",
{% endif %}
"policy": { "policy": {
"type": "k8s" "type": "k8s"
}, },