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-5278/ Add csi addons #320

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
60 changes: 26 additions & 34 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,40 +154,6 @@ rules:
- list
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplicationclasses
verbs:
- get
- list
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications/finalizers
verbs:
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications/status
verbs:
- get
- patch
- update
- apiGroups:
- security.openshift.io
resourceNames:
Expand Down Expand Up @@ -275,3 +241,29 @@ rules:
- volumeattachments/status
verbs:
- patch
- apiGroups:
- csiaddons.openshift.io
resources:
- csiaddonsnodes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- csiaddons.openshift.io
resources:
- csiaddonsnodes/finalizers
verbs:
- update
- apiGroups:
- csiaddons.openshift.io
resources:
- csiaddonsnodes/status
verbs:
- get
- patch
- update
9 changes: 4 additions & 5 deletions controllers/ibmblockcsi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ type IBMBlockCSIReconciler struct {
// +kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshotcontents,verbs=get;watch;list;create;update;delete
// +kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshotcontents/status,verbs=update
// +kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshots,verbs=get;watch;list;update
// +kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumereplicationclasses,verbs=get;list;watch
// +kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumereplications,verbs=create;delete;get;list;patch;update;watch
// +kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumereplications/finalizers,verbs=update
// +kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumereplications/status,verbs=get;patch;update
// +kubebuilder:rbac:groups=csiaddons.openshift.io,resources=csiaddonsnodes,verbs=create;delete;get;list;patch;update;watch
// +kubebuilder:rbac:groups=csiaddons.openshift.io,resources=csiaddonsnodes/finalizers,verbs=update
// +kubebuilder:rbac:groups=csiaddons.openshift.io,resources=csiaddonsnodes/status,verbs=get;patch;update
func (r *IBMBlockCSIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (reconcile.Result, error) {
reqLogger := log.WithValues("Request.Namespace", req.Namespace, "Request.Name", req.Name)
reqLogger.Info("Reconciling IBMBlockCSI")
Expand Down Expand Up @@ -360,7 +359,7 @@ func (r *IBMBlockCSIReconciler) restartControllerPodfromStatefulSet(logger logr.
}

func (r *IBMBlockCSIReconciler) getControllerPod(controllerStatefulset *appsv1.StatefulSet, controllerPod *corev1.Pod) error {
controllerPodName := fmt.Sprintf("%s-0", controllerStatefulset.Name)
controllerPodName := oconfig.GetControllerPodName(controllerStatefulset.Name)
err := r.Get(context.TODO(), types.NamespacedName{
Name: controllerPodName,
Namespace: controllerStatefulset.Namespace,
Expand Down
32 changes: 13 additions & 19 deletions controllers/internal/crutils/static_resource_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
volumeGroupApiGroup string = "csi.ibm.com"
storageApiGroup string = "storage.k8s.io"
rbacAuthorizationApiGroup string = "rbac.authorization.k8s.io"
replicationStorageOpenshiftApiGroup string = "replication.storage.openshift.io"
csiAddonsApiGroup string = "csiaddons.openshift.io"
storageClassesResource string = "storageclasses"
persistentVolumesResource string = "persistentvolumes"
persistentVolumeClaimsResource string = "persistentvolumeclaims"
Expand All @@ -50,10 +50,9 @@ const (
volumeSnapshotsResource string = "volumesnapshots"
volumeSnapshotContentsResource string = "volumesnapshotcontents"
volumeSnapshotContentsStatusResource string = "volumesnapshotcontents/status"
volumeReplicationClassesResource string = "volumereplicationclasses"
volumeReplicationsResource string = "volumereplications"
volumeReplicationsFinalizersResource string = "volumereplications/finalizers"
volumeReplicationsStatusResource string = "volumereplications/status"
csiAddonsNodesResource string = "csiaddonsnodes"
csiAddonsNodesFinalizersResource string = "csiaddonsnodes/finalizers"
csiAddonsNodesStatusResource string = "csiaddonsnodes/status"
eventsResource string = "events"
nodesResource string = "nodes"
csiNodesResource string = "csinodes"
Expand Down Expand Up @@ -357,30 +356,25 @@ func (c *IBMBlockCSI) GenerateCSIAddonsReplicatorClusterRole() *rbacv1.ClusterRo
},
Rules: []rbacv1.PolicyRule{
{
APIGroups: []string{replicationStorageOpenshiftApiGroup},
Resources: []string{volumeReplicationClassesResource},
Verbs: []string{verbGet, verbList, verbWatch},
APIGroups: []string{""},
Resources: []string{secretsResource},
Verbs: []string{verbGet},
},
{
APIGroups: []string{replicationStorageOpenshiftApiGroup},
Resources: []string{volumeReplicationsResource},
APIGroups: []string{csiAddonsApiGroup},
Resources: []string{csiAddonsNodesResource},
Verbs: []string{verbCreate, verbDelete, verbGet, verbList, verbPatch, verbUpdate, verbWatch},
},
{
APIGroups: []string{replicationStorageOpenshiftApiGroup},
Resources: []string{volumeReplicationsFinalizersResource},
APIGroups: []string{csiAddonsApiGroup},
Resources: []string{csiAddonsNodesFinalizersResource},
Verbs: []string{verbUpdate},
},
{
APIGroups: []string{replicationStorageOpenshiftApiGroup},
Resources: []string{volumeReplicationsStatusResource},
APIGroups: []string{csiAddonsApiGroup},
Resources: []string{csiAddonsNodesStatusResource},
Verbs: []string{verbGet, verbPatch, verbUpdate},
},
{
APIGroups: []string{""},
Resources: []string{secretsResource},
Verbs: []string{verbGet},
},
},
}
}
Expand Down
58 changes: 53 additions & 5 deletions controllers/syncer/csi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (s *csiControllerSyncer) ensurePodSpec() corev1.PodSpec {
func (s *csiControllerSyncer) ensureContainersSpec() []corev1.Container {
controllerPlugin := s.ensureContainer(ControllerContainerName,
s.driver.GetCSIControllerImage(),
[]string{"--csi-endpoint=$(CSI_ENDPOINT)"},
[]string{"--csi-endpoint=$(CSI_ENDPOINT)", "--csi-addons-endpoint=$(CSI_ADDONS_ENDPOINT)"},
)

controllerPlugin.Resources = ensureResources("40m", "800m", "40Mi", "400Mi")
Expand Down Expand Up @@ -207,12 +207,17 @@ func (s *csiControllerSyncer) ensureContainersSpec() []corev1.Container {
)
resizer.ImagePullPolicy = s.getCSIResizerPullPolicy()

leaderElectionNamespaceFlag := fmt.Sprintf("--leader-election-namespace=%s", s.driver.Namespace)
driverNameFlag := fmt.Sprintf("--driver-name=%s", config.DriverName)
statfulSetName := config.GetNameForResource(config.CSIController, s.driver.Name)
controllerPodName := fmt.Sprintf("--pod=%s", config.GetControllerPodName(statfulSetName))
controllerPodNamespace := fmt.Sprintf("--namespace=%s", s.driver.Namespace)
controllerPort := fmt.Sprintf("--controller-port=%s", "9087")
replicator := s.ensureContainer(replicatorContainerName,
s.getCSIAddonsReplicatorImage(),
[]string{leaderElectionNamespaceFlag, driverNameFlag,
"--csi-address=$(ADDRESS)", "--zap-log-level=5", "--rpc-timeout=30s"},
[]string{controllerPodName, controllerPodNamespace, controllerPort,
"--csi-addons-address=$(CSI_ADDONS_ENDPOINT)",
"--node-id=$(NODE_ID)", "--pod-uid=$(POD_UID)",
"--controller-ip=$(POD_IP)"},
)
replicator.ImagePullPolicy = s.getCSIAddonsReplicatorPullPolicy()

Expand Down Expand Up @@ -327,6 +332,18 @@ func (s *csiControllerSyncer) getEnvFor(name string) []corev1.EnvVar {
Name: "CSI_ENDPOINT",
Value: config.CSIEndpoint,
},
{
Name: "CSI_ADDONS_ENDPOINT",
Value: config.CSIAddonsEndpoint,
},
{
Name: "NODE_ID",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "spec.nodeName",
},
},
},
{
Name: "CSI_LOGLEVEL",
Value: config.DefaultLogLevel,
Expand All @@ -336,9 +353,40 @@ func (s *csiControllerSyncer) getEnvFor(name string) []corev1.EnvVar {
Value: strconv.FormatBool(s.driver.Spec.EnableCallHome),
},
}
case replicatorContainerName:
return []corev1.EnvVar{
{
Name: "CSI_ADDONS_ENDPOINT",
Value: config.CSIAddonsEndpoint,
},
{
Name: "NODE_ID",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "spec.nodeName",
},
},
},
{
Name: "POD_IP",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "status.podIP",
},
},
},
{
Name: "POD_UID",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.uid",
},
},
},
}

case provisionerContainerName, attacherContainerName, snapshotterContainerName,
resizerContainerName, replicatorContainerName, volumeGroupContainerName:
resizerContainerName, volumeGroupContainerName:
return []corev1.EnvVar{
{
Name: "ADDRESS",
Expand Down
60 changes: 26 additions & 34 deletions deploy/installer/generated/ibm-block-csi-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3224,40 +3224,6 @@ rules:
- list
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplicationclasses
verbs:
- get
- list
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications/finalizers
verbs:
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications/status
verbs:
- get
- patch
- update
- apiGroups:
- security.openshift.io
resourceNames:
Expand Down Expand Up @@ -3345,6 +3311,32 @@ rules:
- volumeattachments/status
verbs:
- patch
- apiGroups:
- csiaddons.openshift.io
resources:
- csiaddonsnodes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- csiaddons.openshift.io
resources:
- csiaddonsnodes/finalizers
verbs:
- update
- apiGroups:
- csiaddons.openshift.io
resources:
- csiaddonsnodes/status
verbs:
- get
- patch
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,17 +488,9 @@ spec:
- update
- watch
- apiGroups:
- replication.storage.openshift.io
- csiaddons.openshift.io
resources:
- volumereplicationclasses
verbs:
- get
- list
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications
- csiaddonsnodes
verbs:
- create
- delete
Expand All @@ -508,15 +500,15 @@ spec:
- update
- watch
- apiGroups:
- replication.storage.openshift.io
- csiaddons.openshift.io
resources:
- volumereplications/finalizers
- csiaddonsnodes/finalizers
verbs:
- update
- apiGroups:
- replication.storage.openshift.io
- csiaddons.openshift.io
resources:
- volumereplications/status
- csiaddonsnodes/status
verbs:
- get
- patch
Expand Down
Loading