csi: run csi controller plugin on host network
When CSI_ENABLE_HOST_NETWORK is set run the
csi controller plugin pods on the host network
closes: #16960
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 4416b5ce9d)
This commit is contained in:
1 parent
1fc09fb0be
commit
5dd7efeec4
4 files changed
+17
-12
No files matched your search
@@ -18,6 +18,7 @@ package csi
|
||||
|
||||
import (
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
|
||||
csiopv1 "github.com/ceph/ceph-csi-operator/api/v1"
|
||||
"github.com/pkg/errors"
|
||||
@@ -30,8 +31,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
opConfigCRName = "ceph-csi-operator-config"
|
||||
imageSetConfigMap = "rook-csi-operator-image-set-configmap"
|
||||
opConfigCRName = "ceph-csi-operator-config"
|
||||
)
|
||||
|
||||
func (r *ReconcileCSI) createOrUpdateOperatorConfig(cluster cephv1.CephCluster) error {
|
||||
@@ -74,6 +74,8 @@ func (r *ReconcileCSI) createOrUpdateOperatorConfig(cluster cephv1.CephCluster)
|
||||
}
|
||||
|
||||
func (r *ReconcileCSI) generateCSIOpConfigSpec(cluster cephv1.CephCluster, opConfig *csiopv1.OperatorConfig, imageSetCmName string) csiopv1.OperatorConfigSpec {
|
||||
controllerPluginHostNetwork := opcontroller.EnforceHostNetwork() || CSIParam.EnableCSIHostNetwork
|
||||
|
||||
cephfsClientType := csiopv1.KernelCephFsClient
|
||||
if CSIParam.ForceCephFSKernelClient == "false" {
|
||||
cephfsClientType = csiopv1.AutoDetectCephFsClient
|
||||
@@ -107,6 +109,7 @@ func (r *ReconcileCSI) generateCSIOpConfigSpec(cluster cephv1.CephCluster, opCon
|
||||
DeploymentStrategy: &appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
HostNetwork: &controllerPluginHostNetwork,
|
||||
PodCommonSpec: csiopv1.PodCommonSpec{
|
||||
PrioritylClassName: &CSIParam.PluginPriorityClassName,
|
||||
Affinity: &v1.Affinity{
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
testop "github.com/rook/rook/pkg/operator/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apifake "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@@ -37,10 +38,13 @@ import (
|
||||
|
||||
func TestReconcileCSI_createOrUpdateOperatorConfig(t *testing.T) {
|
||||
ns := "test"
|
||||
cephv1.SetEnforceHostNetwork(true)
|
||||
defer cephv1.SetEnforceHostNetwork(false)
|
||||
r := &ReconcileCSI{
|
||||
context: &clusterd.Context{
|
||||
Clientset: testop.New(t, 1),
|
||||
RookClientset: rookclient.NewSimpleClientset(),
|
||||
Clientset: testop.New(t, 1),
|
||||
RookClientset: rookclient.NewSimpleClientset(),
|
||||
ApiExtensionsClient: apifake.NewClientset(),
|
||||
},
|
||||
opManagerContext: context.TODO(),
|
||||
opConfig: opcontroller.OperatorConfig{
|
||||
@@ -82,10 +86,14 @@ func TestReconcileCSI_createOrUpdateOperatorConfig(t *testing.T) {
|
||||
cl := fake.NewClientBuilder().WithScheme(s).WithRuntimeObjects(object...).Build()
|
||||
r.client = cl
|
||||
|
||||
err := r.createOrUpdateOperatorConfig(*cluster)
|
||||
err := r.setParams()
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = r.createOrUpdateOperatorConfig(*cluster)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = cl.Get(context.TODO(), types.NamespacedName{Name: opConfigCRName, Namespace: r.opConfig.OperatorNamespace}, opConfig)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, *opConfig.Spec.DriverSpecDefaults.EnableMetadata, true)
|
||||
assert.True(t, *opConfig.Spec.DriverSpecDefaults.EnableMetadata)
|
||||
assert.True(t, *opConfig.Spec.DriverSpecDefaults.ControllerPlugin.HostNetwork)
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
||||
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@@ -261,7 +260,6 @@ func (r *ReconcileCSI) generateDriverSpec(cluster cephv1.CephCluster) (csiopv1.D
|
||||
return csiopv1.DriverSpec{}, errors.Wrapf(err, "failed to create ceph-CSI operator config ImageSetConfigmap for CR %s", opConfigCRName)
|
||||
}
|
||||
|
||||
controllerPluginHostNetwork := opcontroller.EnforceHostNetwork()
|
||||
driverSpec := csiopv1.DriverSpec{
|
||||
Log: &csiopv1.LogSpec{
|
||||
Verbosity: int(CSIParam.LogLevel),
|
||||
@@ -286,7 +284,6 @@ func (r *ReconcileCSI) generateDriverSpec(cluster cephv1.CephCluster) (csiopv1.D
|
||||
EnableSeLinuxHostMount: &CSIParam.EnablePluginSelinuxHostMount,
|
||||
},
|
||||
ControllerPlugin: &csiopv1.ControllerPluginSpec{
|
||||
HostNetwork: &controllerPluginHostNetwork,
|
||||
PodCommonSpec: csiopv1.PodCommonSpec{
|
||||
PrioritylClassName: &CSIParam.PluginPriorityClassName,
|
||||
Affinity: &corev1.Affinity{
|
||||
|
||||
@@ -122,15 +122,12 @@ func TestReconcileCSI_createOrUpdateDriverResources(t *testing.T) {
|
||||
c.SetName("testcluster")
|
||||
c.NamespacedName()
|
||||
|
||||
cephv1.SetEnforceHostNetwork(true)
|
||||
defer cephv1.SetEnforceHostNetwork(false)
|
||||
err := r.createOrUpdateDriverResources(*cluster, c)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Test RBD driver
|
||||
err = cl.Get(context.TODO(), types.NamespacedName{Name: fmt.Sprintf("%s.rbd.csi.ceph.com", c.Namespace), Namespace: ns}, driver)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, *driver.Spec.ControllerPlugin.HostNetwork)
|
||||
if tt.expectMultusAnnots {
|
||||
// Verify that both NodePlugin and ControllerPlugin have Multus annotations
|
||||
assert.Nil(t, driver.Spec.NodePlugin.PodCommonSpec.Annotations)
|
||||
|
||||
Reference in new issue
Block a user