From ddca2c368f8d646d8a06607e52ae6bec245b0ae9 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 14 Nov 2024 10:44:40 +0100 Subject: [PATCH] dd a hostNetwork setting to the Driver and ControllerPlugin Specs This bool setting can be added to the controllerPlugin section of the Driver Spec. It will be propagated to all controller plugin pods. This implements the following design: https://github.com/ceph/ceph-csi-operator/blob/main/docs/design/hostNetwork.md Signed-off-by: Michael Adam --- api/v1alpha1/driver_types.go | 3 +++ api/v1alpha1/zz_generated.deepcopy.go | 5 +++++ config/crd/bases/csi.ceph.io_drivers.yaml | 4 ++++ config/crd/bases/csi.ceph.io_operatorconfigs.yaml | 4 ++++ internal/controller/driver_controller.go | 2 ++ .../ceph/ceph-csi-operator/api/v1alpha1/driver_types.go | 3 +++ .../ceph-csi-operator/api/v1alpha1/zz_generated.deepcopy.go | 5 +++++ 7 files changed, 26 insertions(+) diff --git a/api/v1alpha1/driver_types.go b/api/v1alpha1/driver_types.go index b562eeaa..af2c0607 100644 --- a/api/v1alpha1/driver_types.go +++ b/api/v1alpha1/driver_types.go @@ -210,6 +210,8 @@ type ControllerPluginResourcesSpec struct { } type ControllerPluginSpec struct { + // hostNetwork setting to be propagated to CSI controller plugin pods + HostNetwork *bool `json:"hostNetwork,omitempty"` // Embedded common pods spec PodCommonSpec `json:",inline"` @@ -274,6 +276,7 @@ const ( // DriverSpec defines the desired state of Driver type DriverSpec struct { + // Logging configuration for driver's pods //+kubebuilder:validation:Optional Log *LogSpec `json:"log,omitempty"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index a8542df9..bb617807 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -437,6 +437,11 @@ func (in *ControllerPluginResourcesSpec) DeepCopy() *ControllerPluginResourcesSp // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ControllerPluginSpec) DeepCopyInto(out *ControllerPluginSpec) { *out = *in + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } in.PodCommonSpec.DeepCopyInto(&out.PodCommonSpec) if in.DeploymentStrategy != nil { in, out := &in.DeploymentStrategy, &out.DeploymentStrategy diff --git a/config/crd/bases/csi.ceph.io_drivers.yaml b/config/crd/bases/csi.ceph.io_drivers.yaml index 7fe11209..6816ab66 100644 --- a/config/crd/bases/csi.ceph.io_drivers.yaml +++ b/config/crd/bases/csi.ceph.io_drivers.yaml @@ -1051,6 +1051,10 @@ spec: Default is RollingUpdate. type: string type: object + hostNetwork: + description: hostNetwork setting to be propagated to CSI controller + plugin pods + type: boolean imagePullPolicy: description: To indicate the image pull policy to be applied to all the containers in the csi driver pods. diff --git a/config/crd/bases/csi.ceph.io_operatorconfigs.yaml b/config/crd/bases/csi.ceph.io_operatorconfigs.yaml index 9e4884a3..fde8ebcc 100644 --- a/config/crd/bases/csi.ceph.io_operatorconfigs.yaml +++ b/config/crd/bases/csi.ceph.io_operatorconfigs.yaml @@ -1060,6 +1060,10 @@ spec: "RollingUpdate". Default is RollingUpdate. type: string type: object + hostNetwork: + description: hostNetwork setting to be propagated to CSI controller + plugin pods + type: boolean imagePullPolicy: description: To indicate the image pull policy to be applied to all the containers in the csi driver pods. diff --git a/internal/controller/driver_controller.go b/internal/controller/driver_controller.go index e5a1ac1e..82d62402 100644 --- a/internal/controller/driver_controller.go +++ b/internal/controller/driver_controller.go @@ -564,6 +564,7 @@ func (r *driverReconcile) reconcileControllerPluginDeployment() error { Strategy: ptr.Deref(pluginSpec.DeploymentStrategy, defaultDeploymentStrategy), Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ + Labels: utils.Call(func() map[string]string { podLabels := map[string]string{} maps.Copy(podLabels, pluginSpec.Labels) @@ -575,6 +576,7 @@ func (r *driverReconcile) reconcileControllerPluginDeployment() error { Spec: corev1.PodSpec{ ServiceAccountName: serviceAccountName, PriorityClassName: ptr.Deref(pluginSpec.PrioritylClassName, ""), + HostNetwork: ptr.Deref(pluginSpec.HostNetwork, false), Affinity: getControllerPluginPodAffinity(pluginSpec, &appSelector), Tolerations: pluginSpec.Tolerations, Containers: utils.Call(func() []corev1.Container { diff --git a/vendor/github.com/ceph/ceph-csi-operator/api/v1alpha1/driver_types.go b/vendor/github.com/ceph/ceph-csi-operator/api/v1alpha1/driver_types.go index b562eeaa..af2c0607 100644 --- a/vendor/github.com/ceph/ceph-csi-operator/api/v1alpha1/driver_types.go +++ b/vendor/github.com/ceph/ceph-csi-operator/api/v1alpha1/driver_types.go @@ -210,6 +210,8 @@ type ControllerPluginResourcesSpec struct { } type ControllerPluginSpec struct { + // hostNetwork setting to be propagated to CSI controller plugin pods + HostNetwork *bool `json:"hostNetwork,omitempty"` // Embedded common pods spec PodCommonSpec `json:",inline"` @@ -274,6 +276,7 @@ const ( // DriverSpec defines the desired state of Driver type DriverSpec struct { + // Logging configuration for driver's pods //+kubebuilder:validation:Optional Log *LogSpec `json:"log,omitempty"` diff --git a/vendor/github.com/ceph/ceph-csi-operator/api/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/ceph/ceph-csi-operator/api/v1alpha1/zz_generated.deepcopy.go index a8542df9..bb617807 100644 --- a/vendor/github.com/ceph/ceph-csi-operator/api/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/ceph/ceph-csi-operator/api/v1alpha1/zz_generated.deepcopy.go @@ -437,6 +437,11 @@ func (in *ControllerPluginResourcesSpec) DeepCopy() *ControllerPluginResourcesSp // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ControllerPluginSpec) DeepCopyInto(out *ControllerPluginSpec) { *out = *in + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } in.PodCommonSpec.DeepCopyInto(&out.PodCommonSpec) if in.DeploymentStrategy != nil { in, out := &in.DeploymentStrategy, &out.DeploymentStrategy