Skip to content

Commit

Permalink
use FelixConfiguration.CgroupV2Path to set CALICO_CGROUP_PATH
Browse files Browse the repository at this point in the history
Read the CgroupV2Path value from FelixConfiguration and set it as env
var for the mount-bpffs node's init container.
  • Loading branch information
tomastigera committed Mar 8, 2024
1 parent 18e5d9f commit 9a990c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/controller/installation/core_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
19 changes: 19 additions & 0 deletions pkg/render/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9a990c5

Please sign in to comment.