diff --git a/docs/calico.md b/docs/calico.md index 2d10c04e45e1a9f6365eefef26d84bc25f225b15..c733c3c0cc175972174cdfda0dfac7f879f5b891 100644 --- a/docs/calico.md +++ b/docs/calico.md @@ -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. +### 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 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. diff --git a/roles/network_plugin/calico/defaults/main.yml b/roles/network_plugin/calico/defaults/main.yml index 92bf788a61518a98ac3e802fd2944ba2179f6b15..2ba53d362bb08ffdf7c9857c1419724d75aa722a 100644 --- a/roles/network_plugin/calico/defaults/main.yml +++ b/roles/network_plugin/calico/defaults/main.yml @@ -72,6 +72,9 @@ calico_felix_prometheusprocessmetricsenabled: true calico_loglevel: info 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' calico_usage_reporting: false diff --git a/roles/network_plugin/calico/templates/cni-calico.conflist.j2 b/roles/network_plugin/calico/templates/cni-calico.conflist.j2 index 148224cad7533da5e8a2d34b3d9a860e8a7c972b..5cdf1ac86d18b53d0f7c597703ffb17f8b490b82 100644 --- a/roles/network_plugin/calico/templates/cni-calico.conflist.j2 +++ b/roles/network_plugin/calico/templates/cni-calico.conflist.j2 @@ -15,7 +15,9 @@ {% endif %} "type": "calico", "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" %} "etcd_endpoints": "{{ etcd_access_addresses }}", "etcd_cert_file": "{{ calico_cert_dir }}/cert.crt", diff --git a/roles/network_plugin/canal/defaults/main.yml b/roles/network_plugin/canal/defaults/main.yml index 84db19ccda6fa656639d8d8363c6e8cc9373e198..419cc36460e0bb773fbf41533eb47a9c3e0a4428 100644 --- a/roles/network_plugin/canal/defaults/main.yml +++ b/roles/network_plugin/canal/defaults/main.yml @@ -28,3 +28,6 @@ flannel_cpu_requests: 50m kube_etcd_cacert_file: ca.pem kube_etcd_cert_file: node-{{ inventory_hostname }}.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 diff --git a/roles/network_plugin/canal/templates/cni-canal.conflist.j2 b/roles/network_plugin/canal/templates/cni-canal.conflist.j2 index df696e30bed24f9250e2f569c941dec32ca96e7c..e4b351133e3a32da53c8103137fbd2b74fc84128 100644 --- a/roles/network_plugin/canal/templates/cni-canal.conflist.j2 +++ b/roles/network_plugin/canal/templates/cni-canal.conflist.j2 @@ -12,7 +12,9 @@ "etcd_cert_file": "{{ canal_cert_dir }}/cert.crt", "etcd_ca_cert_file": "{{ canal_cert_dir }}/ca_cert.crt", "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": { "type": "k8s" },