From 9a990c592aea6a73c5a828df6129ecbdf0724490 Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Fri, 8 Mar 2024 14:30:58 -0800 Subject: [PATCH] use FelixConfiguration.CgroupV2Path to set CALICO_CGROUP_PATH Read the CgroupV2Path value from FelixConfiguration and set it as env var for the mount-bpffs node's init container. --- .../installation/core_controller.go | 1 + pkg/render/node.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pkg/controller/installation/core_controller.go b/pkg/controller/installation/core_controller.go index 535201f065..7011c40ee9 100644 --- a/pkg/controller/installation/core_controller.go +++ b/pkg/controller/installation/core_controller.go @@ -1359,6 +1359,7 @@ func (r *ReconcileInstallation) Reconcile(ctx context.Context, request reconcile Terminating: nodeTerminating, PrometheusServerTLS: nodePrometheusTLS, FelixHealthPort: *felixConfiguration.Spec.HealthPort, + NodeCgroupV2Path: felixConfiguration.Spec.CgroupV2Path, BindMode: bgpConfiguration.Spec.BindMode, UsePSP: r.usePSP, } diff --git a/pkg/render/node.go b/pkg/render/node.go index 953b1bb7a4..edf3d57862 100644 --- a/pkg/render/node.go +++ b/pkg/render/node.go @@ -119,6 +119,10 @@ type NodeConfiguration struct { // and sets this. FelixHealthPort int + // Node's BPFFsMountDir override. The controller reads FelixConfiguration + // and sets this. + NodeBPFFsMountDir string + // The bindMode read from the default BGPConfiguration. Used to trigger rolling updates // should this value change. BindMode string @@ -1193,6 +1197,7 @@ func (c *nodeComponent) flexVolumeContainer() corev1.Container { // mounted on the host itself, otherwise, a restart of the node container would tear down the mount and destroy // the BPF dataplane's BPF maps. func (c *nodeComponent) bpffsInitContainer() corev1.Container { + bpffsEnv := c.bpffsEnvVars() bidirectional := corev1.MountPropagationBidirectional mounts := []corev1.VolumeMount{ { @@ -1221,11 +1226,25 @@ func (c *nodeComponent) bpffsInitContainer() corev1.Container { Image: c.nodeImage, ImagePullPolicy: ImagePullPolicy(), Command: []string{CalicoNodeObjectName, "-init"}, + Env: bpffsEnv, SecurityContext: securitycontext.NewRootContext(true), VolumeMounts: mounts, } } +// bpffsEnvVars creates the mount-bpffs container's envvars. +func (c *nodeComponent) bpffsEnvVars() []corev1.EnvVar { + envVars := []corev1.EnvVar{} + + if c.bpfDataplaneEnabled() { + if c.cfg.Installation.CustomCgroupPath != "" { + envVars = append(envVars, corev1.EnvVar{Name: "CALICO_CGROUP_PATH", Value: c.cfg.Installation.CustomCgroupPath}) + } + } + + return envVars +} + // cniEnvvars creates the CNI container's envvars. func (c *nodeComponent) cniEnvvars() []corev1.EnvVar { if c.cfg.Installation.CNI.Type != operatorv1.PluginCalico {