Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring cgroup2 path #2919

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/v1/installation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ type InstallationSpec struct {
// +optional
KubeletVolumePluginPath string `json:"kubeletVolumePluginPath,omitempty"`

// CustomCgroupPath is used to provide a custom path for the cgroup2 mount point
// +optional
CustomCgroupPath string `json:"customCgroupPath,omitempty"`

// NodeUpdateStrategy can be used to customize the desired update strategy, such as the MaxUnavailable
// field.
// +optional
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/utils/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func OverrideInstallationSpec(cfg, override operatorv1.InstallationSpec) operato
inst.KubeletVolumePluginPath = override.KubeletVolumePluginPath
}

switch compareFields(inst.CustomCgroupPath, override.CustomCgroupPath) {
case BOnlySet, Different:
inst.CustomCgroupPath = override.CustomCgroupPath
}

switch compareFields(inst.NodeUpdateStrategy, override.NodeUpdateStrategy) {
case BOnlySet, Different:
override.NodeUpdateStrategy.DeepCopyInto(&inst.NodeUpdateStrategy)
Expand Down
8 changes: 8 additions & 0 deletions pkg/crds/operator/operator.tigera.io_installations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6971,6 +6971,10 @@ spec:
type: object
type: object
type: object
customCgroupPath:
description: CustomCgroupPath is used to provide a custom path for
the cgroup2 mount point
type: string
fipsMode:
description: 'FIPSMode uses images and features only that are using
FIPS 140-2 validated cryptographic modules and standards. Default:
Expand Down Expand Up @@ -16496,6 +16500,10 @@ spec:
type: object
type: object
type: object
customCgroupPath:
description: CustomCgroupPath is used to provide a custom path
for the cgroup2 mount point
type: string
fipsMode:
description: 'FIPSMode uses images and features only that are
using FIPS 140-2 validated cryptographic modules and standards.
Expand Down
18 changes: 18 additions & 0 deletions pkg/render/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,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 @@ -1212,11 +1213,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 Expand Up @@ -1513,6 +1528,9 @@ func (c *nodeComponent) nodeEnvVars() []corev1.EnvVar {

if c.bpfDataplaneEnabled() {
nodeEnv = append(nodeEnv, corev1.EnvVar{Name: "FELIX_BPFENABLED", Value: "true"})
if c.cfg.Installation.CustomCgroupPath != "" {
nodeEnv = append(nodeEnv, corev1.EnvVar{Name: "CALICO_CGROUP_PATH", Value: c.cfg.Installation.CustomCgroupPath})
}
}
if c.vppDataplaneEnabled() {
nodeEnv = append(nodeEnv, corev1.EnvVar{
Expand Down