Skip to content
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: add csi-addon sidecar to the rbd provisioner deployment #84

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/csi/rbddeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func GetRBDDeployment(namespace string) *appsv1.Deployment {
)
snapshotter.Image = sidecarImages.ContainerImages.SnapshotterImageURL

csiAddons := templates.CSIAddonsContainer.DeepCopy()
csiAddons.Args = append(csiAddons.Args,
fmt.Sprintf("--leader-election-namespace=%s", namespace),
)
csiAddons.Image = sidecarImages.ContainerImages.CSIADDONSImageURL

return &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: RBDDeploymentName,
Expand All @@ -84,6 +90,7 @@ func GetRBDDeployment(namespace string) *appsv1.Deployment {
*attacher,
*resizer,
*snapshotter,
*csiAddons,
v1.Container{
Name: "csi-rbdplugin",
Image: sidecarImages.ContainerImages.CephCSIImageURL,
Expand All @@ -95,6 +102,7 @@ func GetRBDDeployment(namespace string) *appsv1.Deployment {
"--pidlimit=-1",
"--type=rbd",
"--controllerserver=true",
fmt.Sprintf("--csi-addons-endpoint=%s", templates.DefaultCSIAddonsSocketPath),
fmt.Sprintf("--drivername=%s", GetRBDDriverName()),
},
Resources: templates.RBDPluginResourceRequirements,
Expand Down
61 changes: 61 additions & 0 deletions pkg/templates/csisidecars.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,67 @@ var SnapshotterContainer = &corev1.Container{
},
}

var CSIAddonsContainer = &corev1.Container{
Name: "csi-addons",
Args: []string{
"--node-id=$(NODE_ID)",
"--v=5",
fmt.Sprintf("--csi-addons-address=%s", DefaultCSIAddonsSocketPath),
fmt.Sprintf("--controller-port=%v", DefaultCSIAddonsContainerPort),
"--pod=$(POD_NAME)",
"--namespace=$(POD_NAMESPACE)",
"--pod-uid=$(POD_UID)",
fmt.Sprintf("--stagingpath=%s", DefaultStagingPath),
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need to add all the leader-election flags?
where can I find the default values for:

            - "--leader-election-lease-duration"
            - "--leader-election-renew-deadline"
            - "--leader-election-retry-period"

Copy link
Member

Choose a reason for hiding this comment

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

the default value exists in other sidecar containers use that one and yes we need to have leader-election when running with provisioner pod

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed Offline and updated the leader-election-namespace for the csi-addons sidecar and opened a issue to set the values for the other flags in all the sidecars using this flag

},
Ports: []corev1.ContainerPort{
{
ContainerPort: DefaultCSIAddonsContainerPort,
},
},
EnvFrom: nil,
Env: []corev1.EnvVar{
{
Name: "NODE_ID",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "spec.nodeName",
},
},
},
{
Name: "POD_UID",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.uid",
},
},
},
{
Name: "POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
},
},
},
{
Name: "POD_NAMESPACE",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
},
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "socket-dir",
MountPath: DefaultSocketDir,
},
},
ImagePullPolicy: corev1.PullIfNotPresent,
}

var DriverRegistrar = &corev1.Container{
Name: "csi-driver-registrar",
ImagePullPolicy: corev1.PullIfNotPresent,
Expand Down
5 changes: 5 additions & 0 deletions pkg/templates/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ const (
DefaultKubeletDirPath = "/var/lib/kubelet"
DefaultProvisionerSocketPath = "unix:///csi/csi-provisioner.sock"
DefaultPluginSocketPath = "unix:///csi/csi.sock"
DefaultCSIAddonsSocketPath = "unix:///csi/csi-addons.sock"
DefaultSocketDir = "/csi"
DefaultStagingPath = "/var/lib/kubelet/plugins/kubernetes.io/csi/"

// configmap names
MonConfigMapName = "ceph-csi-configs"
EncryptionConfigMapName = "ceph-csi-kms-config"

// default port numbers
DefaultCSIAddonsContainerPort = int32(9070)
)
Loading