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
csi: option to customize csi driver name prefix #13622
Conversation
a660653
to
75be669
Compare
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.
typo diver
instead of driver
in the commit message and PR description.
failing CI test could be a flake.
75be669
to
56a843f
Compare
pkg/operator/ceph/csi/csi.go
Outdated
@@ -320,5 +320,8 @@ func (r *ReconcileCSI) setParams(ver *version.Info) error { | |||
if strings.EqualFold(k8sutil.GetValue(r.opConfig.Parameters, "CSI_NFS_ATTACH_REQUIRED", "true"), "false") { | |||
CSIParam.NFSAttachRequired = false | |||
} | |||
|
|||
CSIParam.DriverNamePrefix = k8sutil.GetValue(r.opConfig.Parameters, "CSI_DRIVER_NAME_PREFIX", "") |
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.
Can we just default to the operator namespace here?
CSIParam.DriverNamePrefix = k8sutil.GetValue(r.opConfig.Parameters, "CSI_DRIVER_NAME_PREFIX", "") | |
CSIParam.DriverNamePrefix = k8sutil.GetValue(r.opConfig.Parameters, "CSI_DRIVER_NAME_PREFIX", r.opConfig.OperatorNamespace) |
pkg/operator/ceph/csi/spec.go
Outdated
} | ||
|
||
// If the driver name prefix is not set, set it to the operator namespace. | ||
if tp.DriverNamePrefix == "" { |
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.
This is not needed if we set the default as mentioned previously
pkg/operator/ceph/csi/spec.go
Outdated
} | ||
|
||
if EnableRBD { | ||
rbdDriverNamePrefix, err := getCSIDriverNamePrefixFromDeployment(r.opManagerContext, r.context.Clientset, r.opConfig.OperatorNamespace, csiRBDProvisioner, "csi-rbdplugin") |
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.
Instead of checking all three deployments, can we just check one of them? Either they will all succeed, or they will all fail, so we shouldn't need to check all three.
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.
@travisn i added all 3 to ensure that we are good for all the 3 drivers because there are cases where either 1 is a disabled case. please let me know if you still prefer to check for only one, if its it should be rbd
or cephfs
?
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.
I was thinking let's check the first one that is enabled, then we can skip checking the others. If these checks are moved out to a helper method it will be simple to implement by returning after the first enabled one is checked.
Is this a commonly-requested feature? TBH, I think the overall simplicity of using the operator namespace as the prefix is good. It means that we don't need to document any special "if you did this, then this example changes", etc. etc. etc. Being able to provide a simple "this is the way to do this" is a big win for users overall, IMO. Also consider that if any users decide to do this and they use the cluster helm chart, they will probably complain about their storageclasses not being generated right. If users are having a problem with the generated name being too long, would it be sufficient to provide an example for how to change the namespace that Rook is installed in instead? |
56a843f
to
766d7df
Compare
This is not a commonly-requested feature but it is kind of really required if someone doesn't want a dynamic CSI driver name changes based on the namespace where Rook is deployed.
I didn't consider this case because i did search only in the
The problem is not with the namespace name length (but it could also be one reason) but the main problem is with dynamic csi driver names as i mentioned above. |
e7a8833
to
66b9525
Compare
bfaaf3c
to
3bdd341
Compare
`my-prefix.nfs.csi.ceph.com`. | ||
|
||
!!! note | ||
Please be careful when setting the `CSI_DRIVER_NAME_PREFIX` |
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.
May need indentation of 4 spaces for the paragraph to get the rendered docs correctly
... | ||
``` | ||
|
||
Please note that for the RBD driver, the prefix will be |
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.
How about a bullet list?
Please note that for the RBD driver, the prefix will be | |
When the prefix is set, the driver names will be: | |
- RBD: `my-prefix.rbd.csi.ceph.com` | |
- CephFS: ... | |
- NFS: ... |
... | ||
``` | ||
|
||
Same prefix must be set in the volumesnapshotclass as well: |
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.
Same prefix must be set in the volumesnapshotclass as well: | |
The same prefix must be set in the volumesnapshotclass as well: |
@@ -35,6 +35,52 @@ example, if the Rook operator is running in the namespace `my-namespace` the | |||
provisioner value should be `my-namespace.rbd.csi.ceph.com`. The same provisioner | |||
name must be set in both the storageclass and snapshotclass. | |||
|
|||
## Configure custom Driver name prefix for CSI Drivers | |||
|
|||
To use a custom prefix for the CSI drivers, you need to set the |
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.
Let's mention that the namespace is the default prefix
To use a custom prefix for the CSI drivers, you need to set the | |
To use a custom prefix for the CSI drivers instead of the namespace prefix, set the |
|
||
To use a custom prefix for the CSI drivers, you need to set the | ||
`CSI_DRIVER_NAME_PREFIX` environment variable in the operator configmap. For | ||
instance, to use the prefix `my-prefix` for the CSI drivers, you can set the |
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.
Don't say "you" in the documentation, just use the command form to be more direct.
instance, to use the prefix `my-prefix` for the CSI drivers, you can set the | |
instance, to use the prefix `my-prefix` for the CSI drivers, set the |
|
||
Once the configmap is updated, the CSI drivers will be deployed with the | ||
`my-prefix` prefix. You must set the same prefix in both the storageclass and | ||
snapshotclass. For example, if you want to use the prefix `my-prefix` for the |
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.
There are a few other places to change, I won't mention them all
snapshotclass. For example, if you want to use the prefix `my-prefix` for the | |
snapshotclass. For example, to use the prefix `my-prefix` for the |
pkg/operator/ceph/csi/spec.go
Outdated
} | ||
|
||
if EnableRBD { | ||
rbdDriverNamePrefix, err := getCSIDriverNamePrefixFromDeployment(r.opManagerContext, r.context.Clientset, r.opConfig.OperatorNamespace, csiRBDProvisioner, "csi-rbdplugin") |
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.
I was thinking let's check the first one that is enabled, then we can skip checking the others. If these checks are moved out to a helper method it will be simple to implement by returning after the first enabled one is checked.
I still don't understand why dynamic CSI driver names are an issue. If users aren't complaining of this, it seems like an extra amount of complexity to continue maintaining when we don't need to. |
7e3ca99
to
b54c690
Compare
b54c690
to
5deda74
Compare
dynamic csi driver name is an issue because it's not expected to change the csi driver names based on the deployment namespaces just for example kubervirt always expects the csi driver name to be consistent because it provides the best option to the users based on the hardcoded driver names. This option is getting added to ensure that we can be backward compatible and also open an option to allow user(s) always to set the static driver names in their cluster. --- update --- https://github.com/kubevirt/containerized-data-importer/blob/0b4ebe81af353d2611344ac8cfef64cc1c4d58ad/pkg/storagecapabilities/storagecapabilities.go#L43 One example where it's having hardcoded values. after discussing more with the kubevirt team (internally) it's suggested that it's not expected to change the driver names based on the namespace name because the names are the representation of the csi driver it should not get changed dynamically because no one can predict the names in dynamic cases. |
5deda74
to
5bb3ea5
Compare
-e "s/\(.*\): [-_A-Za-z0-9]*\.\(.*\) # driver:namespace:cluster/\1: $ROOK_CLUSTER_NAMESPACE.\2 # driver:namespace:cluster/g" \ | ||
common.yaml operator.yaml cluster.yaml # add other files or change these as desired for your config | ||
|
||
# You need to use `apply` for all Ceph clusters after the first if you have only one Operator | ||
kubectl apply -f common.yaml -f operator.yaml -f cluster.yaml # add other files as desired for yourconfig | ||
``` | ||
|
||
Refer to the CSI driver |
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.
Refer to the CSI driver | |
Also see the CSI driver |
-e "s/\(.*\): [-_A-Za-z0-9]*\.\(.*\) # driver:namespace:cluster/\1: $ROOK_CLUSTER_NAMESPACE.\2 # driver:namespace:cluster/g" \ | ||
common.yaml operator.yaml cluster.yaml # add other files or change these as desired for your config | ||
|
||
# You need to use `apply` for all Ceph clusters after the first if you have only one Operator | ||
kubectl apply -f common.yaml -f operator.yaml -f cluster.yaml # add other files as desired for yourconfig | ||
``` | ||
|
||
Refer to the CSI driver | ||
[documentation](../Ceph-CSI/ceph-csi-drivers.md#Configure-CSI-Drivers-in-non-default-namespace) | ||
to update examples to use a non-default 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.
How about more specific?
to update examples to use a non-default namespace. | |
to update the csi provisioner names in the storage class. |
@@ -35,6 +35,87 @@ example, if the Rook operator is running in the namespace `my-namespace` the | |||
provisioner value should be `my-namespace.rbd.csi.ceph.com`. The same provisioner | |||
name must be set in both the storageclass and snapshotclass. | |||
|
|||
search for `# csi-provisioner-name` in the [csi |
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.
The docs actually cannot use a relative path to the code because the docs are generated to a different site. I'd suggest no need for a link, we can have a simple comment like this:
search for `# csi-provisioner-name` in the [csi | |
To find the provisioner name in the example storage classes, search for: `# csi-provisioner-name` |
example](../deploy/examples/csi/) folder and update the name of the | ||
`provisioner`/`driver` as required. | ||
|
||
The following `sed` command can be used to update the provisioner name in the |
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.
In the interest of simple docs, I'd suggest not even including this example. Maintaining this sed will be difficult too.
Once the configmap is updated, the CSI drivers will be deployed with the | ||
`my-prefix` prefix. The same prefix must be set in both the storageclass and | ||
snapshotclass. For example, to use the prefix `my-prefix` for the | ||
CSI drivers, you can set the following in the storageclass: |
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.
CSI drivers, you can set the following in the storageclass: | |
CSI drivers, update the provisioner in the storageclass: |
environment variable. It should be done only in fresh deployments because | ||
changing the prefix in an existing cluster will result in unexpected behavior. | ||
|
||
search for `# csi-provisioner-name` in the [csi |
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.
Same suggestions as above for this section
# The prefix of the driver name can be configured by updating | ||
# CSI_DRIVER_NAME_PREFIX in the rook-ceph-operator-config configmap by default | ||
# it is namespace name where rook operator is running i.e rook-ceph. | ||
driver: .cephfs.csi.ceph.com # csi-provisioner-name |
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.
We still need to keep the default rook-ceph
prefix there. And actually I'm thinking we don't need lines 6-8 documented in every storage class. It's not going to be a common scenario to update the storage class, so they can just use the documentation topic, and no need to document here. If we just have the # csi-provisioner-name
tag, then they can easily search where to update it.
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.
i think while doing testing the rook-ceph
got removed, brought it back and removed extra text as well
92ca762
to
b1d0192
Compare
b1d0192
to
1ee7f82
Compare
To find the provisioner name in the example storageclasses and | ||
volumesnapshotclass, search for: `# csi-provisioner-name` | ||
|
||
## Configure custom Driver name prefix for CSI Drivers |
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.
This section seems like it needs to be combined with the previous section. How about making it a subsection?
## Configure custom Driver name prefix for CSI Drivers | |
### Configure custom Driver name prefix for CSI Drivers |
pkg/operator/ceph/csi/spec.go
Outdated
if rbdDriverNamePrefix != "" && rbdDriverNamePrefix != driverNamePrefix { | ||
return errors.Errorf("rbd driver already exists with prefix %q, cannot use prefix %q", rbdDriverNamePrefix, driverNamePrefix) | ||
} | ||
return nil |
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.
If the driver was not found, looks like this will return here instead of checking the next driver. If no prefix was found, shall we check the next driver?
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.
i missed that case, move the check as required, this should cover both cases now. Thanks
For now we are using the operator namespace name as the prefix for the csi driver, This PR provides an option for the users if someone wants to have their own prefix for the csi driver, if someone tries to change the prefix for existing csi driver rook operator will fail to reconcile the csi driver. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
1ee7f82
to
c35a853
Compare
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.
CI issues look unrelated
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.
The change looks good and clean now. pylint test is failing but this has to be unrelated since no python code is changed.
csi: option to customize csi driver name prefix (backport #13622)
For now, we are using the operator namespace name as the prefix for the csi driver, This PR provides an option for the users if someone wants to have their prefix for the csi driver, if someone tries to change the prefix for existing csi driver rook operator will fail to reconcile the csi driver. If the option is not set the default behavior will continue as it is where the operator namespace will be used as a prefix for the csi driver name(s).
Checklist: