Skip to content

Deploy csi-addons sidecar with pod network#253

Closed
black-dragon74 wants to merge 5 commits intoceph:mainfrom
black-dragon74:csi-addons-podnet
Closed

Deploy csi-addons sidecar with pod network#253
black-dragon74 wants to merge 5 commits intoceph:mainfrom
black-dragon74:csi-addons-podnet

Conversation

@black-dragon74
Copy link
Copy Markdown
Member

@black-dragon74 black-dragon74 commented Jun 16, 2025

This patch introduces a set of changes that allows the csi-addons sidecars to run without host networking. Here's a brief of the changes (separated into their own commits):

  • Create a new DaemonSet for csi-addons sidecar that communicates with CSI nodeplugin.
    • The UDS is already on a hostpath which is shared across these two daemon sets.
  • Modify the provisioner deployments to use hostpath for UDS located at:kubelet_dir/plugin/driverid/ctrl-plugin
  • Create a separate deployment for CSI Addons to pair with provisioner deployments
    • The csi-addons to provisioner pairing is ensured using pod affinities.

This patch introduces a new DaemonSet for csi-addons operations that
uses pod network instead of the host networking.

Signed-off-by: Niraj Yadav <niryadav@redhat.com>
This patch modifies the provisioner deployments
to use hostpath for CSI sockets.

This is done to (later) enable CSI Addons
sidecar to run as a separate deployment.

Signed-off-by: Niraj Yadav <niryadav@redhat.com>
This patch deploys csi addons sidecar container into its own
deployment that shares the hostpath for UDS with the CSI provisioner.

This model enables CSI Addons operation without its dependence on
host networking.

Signed-off-by: Niraj Yadav <niryadav@redhat.com>
@black-dragon74 black-dragon74 marked this pull request as ready for review June 17, 2025 10:22
@nixpanic
Copy link
Copy Markdown
Member

Deploying fails because these images can not be pulled:

  • registry.k8s.io/sig-storage/csi-resizer:v1.14.0
  • registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.14.1

These versions come from ceph-csi-operator main branch:

https://github.com/ceph/ceph-csi-operator/blob/main/internal/controller/defaults.go#L30-L38

That was merged with #252 yesterday... Not sure how it passed CI if those images are not available yet, it requires a PR to promote the versions before the image can be pulled.


// Reconcile daemonset and deployment for CSI Addons
if ptr.Deref(r.driver.Spec.DeployCsiAddons, false) {
// CSI Addons deployment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the comment to mention this is only for cephfs and rbd, i would suggest to use isRbDDriver and isCephFSDriver to avoid future problem when we add new csi driver

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
}

func (r *driverReconcile) reconcileCsiAddonsDeployment() error {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i set the flag to false, i dont see the code where we are removing the deployment and deamonset.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread internal/utils/csi.go Outdated
Name: pluginDirHostVolumeName,
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: fmt.Sprintf("%s/plugins/%s/provisioner", kubeletDirPath, driverNamePrefix),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be any problem when both deployment and deamonset runs on the same node, Are we using different socket names?

if not lets use different name and remove provisioner from the path and use csiaddons

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We are using different sockets based on the driver type, e.g:

For RBD:
DS: /var/lib/kubelet/plugins/rook-ceph.rbd.csi.ceph.com/csi.sock
Deploy: /var/lib/kubelet/plugins/rook-ceph.rbd.csi.ceph.com/provisioner/csi.sock

For CephFS:
Deploy: /var/lib/kubelet/plugins/rook-ceph.cephfs.csi.ceph.com/provisioner/csi.sock

CSIAddons doesn't make much sense as a name here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename it to ctrl-plugin we can use this for other future sockets as well. for DS can you please make it node-plugin?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

},
}
// Liveness Sidecar Container
if r.driver.Spec.Liveness != nil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need this container, can we remove it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Collaborator

@Madhu-1 Madhu-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please share the results from multiple testing to ensure we are good?

Spec: corev1.PodSpec{
ServiceAccountName: serviceAccountName,
PriorityClassName: ptr.Deref(pluginSpec.PrioritylClassName, ""),
HostPID: r.isRdbDriver(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is required?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just ported over from existing code as-is. Pretty sure it was there for a reason in cases of RBD.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove it, it was required for RBD as its does many operations like map. we dont required it for simple csi-addons

Comment thread internal/utils/csi.go Outdated
Name: pluginDirHostVolumeName,
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: fmt.Sprintf("%s/plugins/%s/provisioner", kubeletDirPath, driverNamePrefix),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename it to ctrl-plugin we can use this for other future sockets as well. for DS can you please make it node-plugin?

Image: r.images["addons"],
ImagePullPolicy: imagePullPolicy,
SecurityContext: &corev1.SecurityContext{
Privileged: ptr.To(true),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need to be privileged? can you please verify for other containers as well, we need to keep it very minimum permission

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It is required in order to access UDS created by privileged CSI provisioner container. Not having this will cause issues on systems with enforcing selinux.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good :+1 can you please add a comment to it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Niraj Yadav <niryadav@redhat.com>
This patch adds functionality to delete CSI Addons pods
when their matching CSI Ctrlplugin pod is deleted by the user.

This is done so that the kube-scheduler can reevaluate
pod placement which is crucial when host-path is shared
between the two pods.

Signed-off-by: Niraj Yadav <niryadav@redhat.com>
@black-dragon74
Copy link
Copy Markdown
Member Author

Closing this one as #269 is the updated implementation. This PR/branch is kept as is to preserve the work done (if needed down the line).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants