-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
ceph: added support for multus for csi #5740
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import ( | |
"strings" | ||
"time" | ||
|
||
rookclient "github.com/rook/rook/pkg/client/clientset/versioned" | ||
controllerutil "github.com/rook/rook/pkg/operator/ceph/controller" | ||
"github.com/rook/rook/pkg/operator/k8sutil" | ||
"github.com/rook/rook/pkg/operator/k8sutil/cmdreporter" | ||
|
@@ -198,7 +199,7 @@ func ValidateCSIParam() error { | |
return nil | ||
} | ||
|
||
func startDrivers(clientset kubernetes.Interface, namespace string, ver *version.Info, ownerRef *metav1.OwnerReference) error { | ||
func startDrivers(clientset kubernetes.Interface, rookclientset rookclient.Interface, namespace string, ver *version.Info, ownerRef *metav1.OwnerReference) error { | ||
var ( | ||
err error | ||
rbdPlugin, cephfsPlugin *apps.DaemonSet | ||
|
@@ -361,6 +362,13 @@ func startDrivers(clientset kubernetes.Interface, namespace string, ver *version | |
// apply resource request and limit to rbdplugin containers | ||
applyResourcesToContainers(clientset, rbdPluginResource, &rbdPlugin.Spec.Template.Spec) | ||
k8sutil.SetOwnerRef(&rbdPlugin.ObjectMeta, ownerRef) | ||
multusApplied, err := applyCephClusterNetworkConfig(&rbdPlugin.Spec.Template.ObjectMeta, rookclientset) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to apply network config to rbd plugin daemonset: %+v", rbdPlugin) | ||
} | ||
if multusApplied { | ||
rbdPlugin.Spec.Template.Spec.HostNetwork = false | ||
} | ||
err = k8sutil.CreateDaemonSet(csiRBDPlugin, namespace, clientset, rbdPlugin) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to start rbdplugin daemonset: %+v", rbdPlugin) | ||
|
@@ -379,6 +387,10 @@ func startDrivers(clientset kubernetes.Interface, namespace string, ver *version | |
Type: apps.RecreateDeploymentStrategyType, | ||
} | ||
|
||
_, err = applyCephClusterNetworkConfig(&rbdProvisionerDeployment.Spec.Template.ObjectMeta, rookclientset) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to apply network config to rbd plugin provisioner deployment: %+v", rbdProvisionerDeployment) | ||
} | ||
err = k8sutil.CreateDeployment(clientset, csiRBDProvisioner, namespace, rbdProvisionerDeployment) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to start rbd provisioner deployment: %+v", rbdProvisionerDeployment) | ||
|
@@ -399,6 +411,13 @@ func startDrivers(clientset kubernetes.Interface, namespace string, ver *version | |
// apply resource request and limit to cephfs plugin containers | ||
applyResourcesToContainers(clientset, cephFSPluginResource, &cephfsPlugin.Spec.Template.Spec) | ||
k8sutil.SetOwnerRef(&cephfsPlugin.ObjectMeta, ownerRef) | ||
multusApplied, err := applyCephClusterNetworkConfig(&cephfsPlugin.Spec.Template.ObjectMeta, rookclientset) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to apply network config to cephfs plugin daemonset: %+v", cephfsPlugin) | ||
} | ||
if multusApplied { | ||
cephfsPlugin.Spec.Template.Spec.HostNetwork = false | ||
} | ||
err = k8sutil.CreateDaemonSet(csiCephFSPlugin, namespace, clientset, cephfsPlugin) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to start cephfs plugin daemonset: %+v", cephfsPlugin) | ||
|
@@ -417,6 +436,11 @@ func startDrivers(clientset kubernetes.Interface, namespace string, ver *version | |
cephfsProvisionerDeployment.Spec.Strategy = apps.DeploymentStrategy{ | ||
Type: apps.RecreateDeploymentStrategyType, | ||
} | ||
|
||
_, err = applyCephClusterNetworkConfig(&cephfsProvisionerDeployment.Spec.Template.ObjectMeta, rookclientset) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to apply network config to cephfs plugin provisioner deployment: %+v", cephfsProvisionerDeployment) | ||
} | ||
err = k8sutil.CreateDeployment(clientset, csiCephFSProvisioner, namespace, cephfsProvisionerDeployment) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to start cephfs provisioner deployment: %+v", cephfsProvisionerDeployment) | ||
|
@@ -498,6 +522,23 @@ func deleteCSIDriverResources( | |
return succeeded | ||
} | ||
|
||
func applyCephClusterNetworkConfig(objectMeta *metav1.ObjectMeta, rookclientset rookclient.Interface) (bool, error) { | ||
cephClusters, err := rookclientset.CephV1().CephClusters(objectMeta.Namespace).List(metav1.ListOptions{}) | ||
if err != nil { | ||
return false, errors.Errorf("failed to find CephClusters in namespace %q", objectMeta.Namespace) | ||
} | ||
rohan47 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for _, cephCluster := range cephClusters.Items { | ||
if cephCluster.Spec.Network.IsMultus() { | ||
err = k8sutil.ApplyMultus(cephCluster.Spec.Network.NetworkSpec, objectMeta) | ||
if err != nil { | ||
return false, errors.Wrapf(err, "failed to apply multus configuration to CephCluster %q", cephCluster.Name) | ||
} | ||
} | ||
} | ||
|
||
return true, nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even if the ceph cluster is not using multus it's returning true? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, we should only return if multus got configured, I'm sending a PR to fix this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
// createCSIDriverInfo Registers CSI driver by creating a CSIDriver object | ||
func createCSIDriverInfo(clientset kubernetes.Interface, name string, ownerRef *metav1.OwnerReference) error { | ||
attach := true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: won't this fail if the ceph cluster and CSI is in a different namespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
The namespace we have here is actually the Rook Ceph operators namespace, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes its rook ceph operator namespace