Skip to content

Commit

Permalink
fix csi rbac in kustomize
Browse files Browse the repository at this point in the history
Moving the csi RBAC to a new folder
which can be build and applied differently
and we dont need to have same namePrefix
and namespacePrefix for these files as this
is not required to be deployed in the same
namespace as the operator.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Aug 8, 2024
1 parent deb792a commit 2e3d5d7
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 81 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ REGISTRY_NAMESPACE ?= cephcsi
IMAGE_TAG ?= latest
IMAGE_NAME ?= ceph-csi-operator

# Use different name prefix and namespace prefix for csi rbac kustomize
CSI_RBAC_NAME_PREFIX ?= ceph-csi-operator-
CSI_RBAC_NAMESPACE ?= $(CSI_RBAC_NAME_PREFIX)system

IMG ?= $(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/$(IMAGE_NAME):$(IMAGE_TAG)

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
Expand Down Expand Up @@ -126,6 +130,11 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > dist/install.yaml

.PHONY: build-csi-rbac
build-csi-rbac:
cd config/csi-rbac && $(KUSTOMIZE) edit set nameprefix $(CSI_RBAC_NAME_PREFIX)
cd config/csi-rbac && $(KUSTOMIZE) edit set namespace $(CSI_RBAC_NAMESPACE)
$(KUSTOMIZE) build config/csi-rbac > dist/csi-rbac.yaml
##@ Deployment

ifndef ignore-not-found
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-cephfs-ctrlplugin-cr
name: cephfs-ctrlplugin-cr
rules:
- apiGroups: [""]
resources: ["secrets"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-rbd-nodeplugin-crb
name: cephfs-ctrlplugin-crb
subjects:
- kind: ServiceAccount
name: csi-rbd-nodeplugin-sa
name: cephfs-ctrlplugin-sa
namespace: system
roleRef:
kind: ClusterRole
name: csi-rbd-nodeplugin-cr
name: cephfs-ctrlplugin-cr
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-cephfs-ctrlplugin-r
name: cephfs-ctrlplugin-r
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-rbd-ctrlplugin-rb
name: cephfs-ctrlplugin-rb
subjects:
- kind: ServiceAccount
name: csi-rbd-ctrlplugin-sa
name: cephfs-ctrlplugin-sa
namespace: system
roleRef:
kind: Role
name: csi-rbd-ctrlplugin-r
name: cephfs-ctrlplugin-r
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-rbd-ctrlplugin-sa
name: cephfs-ctrlplugin-sa
namespace: system
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-cephfs-nodeplugin-cr
name: cephfs-nodeplugin-cr
rules:
- apiGroups: [""]
resources: ["nodes"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-rbd-ctrlplugin-crb
name: cephfs-nodeplugin-crb
subjects:
- kind: ServiceAccount
name: csi-rbd-ctrlplugin-sa
name: cephfs-nodeplugin-sa
namespace: system
roleRef:
kind: ClusterRole
name: csi-rbd-ctrlplugin-cr
name: cephfs-nodeplugin-cr
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-rbd-nodeplugin-sa
name: cephfs-nodeplugin-sa
namespace: system
21 changes: 21 additions & 0 deletions config/csi-rbac/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resources:
# CSI operands have their own set of RBAC that need to be installed
# on the cluster.
- cephfs_ctrlplugin_service_account.yaml
- cephfs_ctrlplugin_cluster_role.yaml
- cephfs_ctrlplugin_cluster_role_binding.yaml
- cephfs_ctrlplugin_role.yaml
- cephfs_ctrlplugin_role_binding.yaml
- cephfs_nodeplugin_service_account.yaml
- cephfs_nodeplugin_cluster_role.yaml
- cephfs_nodeplugin_cluster_role_binding.yaml
- rbd_ctrlplugin_service_account.yaml
- rbd_ctrlplugin_cluster_role.yaml
- rbd_ctrlplugin_cluster_role_binding.yaml
- rbd_ctrlplugin_role.yaml
- rbd_ctrlplugin_role_binding.yaml
- rbd_nodeplugin_service_account.yaml
- rbd_nodeplugin_cluster_role.yaml
- rbd_nodeplugin_cluster_role_binding.yaml
- rbd_nodeplugin_role.yaml
- rbd_nodeplugin_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-nfs-ctrlplugin-cr
name: nfs-ctrlplugin-cr
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-cephfs-nodeplugin-crb
name: nfs-ctrlplugin-crb
subjects:
- kind: ServiceAccount
name: csi-cephfs-nodeplugin-sa
name: nfs-ctrlplugin-sa
namespace: system
roleRef:
kind: ClusterRole
name: csi-cephfs-nodeplugin-cr
name: nfs-ctrlplugin-cr
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-nfs-ctrlplugin-sa
name: nfs-ctrlplugin-sa
namespace: system
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-nfs-nodeplugin-cr
name: nfs-nodeplugin-cr
rules:
- apiGroups: [""]
resources: ["nodes"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-nfs-nodeplugin-crb
name: nfs-nodeplugin-crb
subjects:
- kind: ServiceAccount
name: csi-nfs-nodeplugin-sa
name: nfs-nodeplugin-sa
namespace: system
roleRef:
kind: ClusterRole
name: csi-nfs-nodeplugin-cr

name: nfs-nodeplugin-cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-nfs-nodeplugin-sa
name: nfs-nodeplugin-sa
namespace: system
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-rbd-ctrlplugin-cr
name: rbd-ctrlplugin-cr
rules:
- apiGroups: [""]
resources: ["secrets"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-cephfs-ctrlplugin-crb
name: rbd-ctrlplugin-crb
subjects:
- kind: ServiceAccount
name: csi-cephfs-ctrlplugin-sa
name: rbd-ctrlplugin-sa
namespace: system
roleRef:
kind: ClusterRole
name: csi-cephfs-ctrlplugin-cr
name: rbd-ctrlplugin-cr
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-rbd-ctrlplugin-r
name: rbd-ctrlplugin-r
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-rbd-nodeplugin-rb
name: rbd-ctrlplugin-rb
subjects:
- kind: ServiceAccount
name: csi-rbd-nodeplugin-sa
name: rbd-ctrlplugin-sa
namespace: system
roleRef:
kind: Role
name: csi-rbd-nodeplugin-r
name: rbd-ctrlplugin-r
apiGroup: rbac.authorization.k8s.io
5 changes: 5 additions & 0 deletions config/csi-rbac/rbd_ctrlplugin_service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: rbd-ctrlplugin-sa
namespace: system
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-rbd-nodeplugin-cr
name: rbd-nodeplugin-cr
rules:
- apiGroups: [""]
resources: ["secrets"]
Expand Down
12 changes: 12 additions & 0 deletions config/csi-rbac/rbd_nodeplugin_cluster_role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: rbd-nodeplugin-crb
subjects:
- kind: ServiceAccount
name: rbd-nodeplugin-sa
namespace: system
roleRef:
kind: ClusterRole
name: rbd-nodeplugin-cr
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-rbd-nodeplugin-r
name: rbd-nodeplugin-r
rules:
- apiGroups: ["csiaddons.openshift.io"]
resources: ["csiaddonsnodes"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-cephfs-ctrlplugin-rb
name: rbd-nodeplugin-rb
subjects:
- kind: ServiceAccount
name: csi-cephfs-ctrlplugin-sa
name: rbd-nodeplugin-sa
namespace: system
roleRef:
kind: Role
name: csi-cephfs-ctrlplugin-r
name: rbd-nodeplugin-r
apiGroup: rbac.authorization.k8s.io
5 changes: 5 additions & 0 deletions config/csi-rbac/rbd_nodeplugin_service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: rbd-nodeplugin-sa
namespace: system
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namePrefix: ceph-csi-operator-
resources:
- ../crd
- ../rbac
- ../csi-rbac
- ../manager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
Expand Down
5 changes: 0 additions & 5 deletions config/rbac/csi_cephfs_ctrlplugin_service_account.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions config/rbac/csi_cephfs_nodeplugin_service_account.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions config/rbac/csi_nfs_ctrlplugin_cluster_role_binding.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,3 @@ resources:
- operatorconfig_viewer_role.yaml
- driver_editor_role.yaml
- driver_viewer_role.yaml
# CSI operands have their own set of RBAC that need to be installed
# on the cluster.
- csi_cephfs_ctrlplugin_service_account.yaml
- csi_cephfs_ctrlplugin_cluster_role.yaml
- csi_cephfs_ctrlplugin_cluster_role_binding.yaml
- csi_cephfs_ctrlplugin_role.yaml
- csi_cephfs_ctrlplugin_role_binding.yaml
- csi_cephfs_nodeplugin_service_account.yaml
- csi_cephfs_nodeplugin_cluster_role.yaml
- csi_cephfs_nodeplugin_cluster_role_binding.yaml
- csi_rbd_ctrlplugin_service_account.yaml
- csi_rbd_ctrlplugin_cluster_role.yaml
- csi_rbd_ctrlplugin_cluster_role_binding.yaml
- csi_rbd_ctrlplugin_role.yaml
- csi_rbd_ctrlplugin_role_binding.yaml
- csi_rbd_nodeplugin_service_account.yaml
- csi_rbd_nodeplugin_cluster_role.yaml
- csi_rbd_nodeplugin_cluster_role_binding.yaml
- csi_rbd_nodeplugin_role.yaml
- csi_rbd_nodeplugin_role_binding.yaml

0 comments on commit 2e3d5d7

Please sign in to comment.