Skip to content

Commit

Permalink
Split deployment.yaml config sample RBAC roles (#1734)
Browse files Browse the repository at this point in the history
* Split config samples deployment roles to access cluster wide and namespace scoped resources saparatelly

Signed-off-by: Manuel Fontan <[email protected]>

---------

Signed-off-by: Manuel Fontan <[email protected]>
  • Loading branch information
manfontan authored Jul 25, 2023
1 parent e8abd80 commit dd9bfd0
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 17 deletions.
14 changes: 14 additions & 0 deletions config/deployment/rbac_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,18 @@ roleRef:
subjects:
- kind: ServiceAccount
name: fdb-kubernetes-operator-controller-manager
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
creationTimestamp: null
name: manager-clusterrolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: fdb-kubernetes-operator-manager-clusterrole
subjects:
- kind: ServiceAccount
name: fdb-kubernetes-operator-controller-manager
namespace: metadata.namespace

15 changes: 15 additions & 0 deletions config/rbac/cluster_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-clusterrole
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
1 change: 1 addition & 0 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ kind: Kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
resources:
- role.yaml
- cluster_role.yaml
8 changes: 0 additions & 8 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
Expand Down
37 changes: 29 additions & 8 deletions config/samples/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ metadata:
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: fdb-kubernetes-operator-manager-clusterrole
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: fdb-kubernetes-operator-manager-role
Expand All @@ -26,14 +41,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
Expand Down Expand Up @@ -132,6 +139,20 @@ subjects:
- kind: ServiceAccount
name: fdb-kubernetes-operator-controller-manager
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
creationTimestamp: null
name: fdb-kubernetes-operator-manager-clusterrolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: fdb-kubernetes-operator-manager-clusterrole
subjects:
- kind: ServiceAccount
name: fdb-kubernetes-operator-controller-manager
namespace: metadata.namespace
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
1 change: 0 additions & 1 deletion controllers/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func NewFoundationDBClusterReconciler(podLifecycleManager podmanager.PodLifecycl
// +kubebuilder:rbac:groups=apps.foundationdb.org,resources=foundationdbclusters/status,verbs=get;update;patch
// +kubebuilder:rbac:groups="",resources=pods;configmaps;persistentvolumeclaims;events;secrets;services,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups="coordination.k8s.io",resources=leases,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch

// Reconcile runs the reconciliation logic.
func (r *FoundationDBClusterReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
Expand Down

0 comments on commit dd9bfd0

Please sign in to comment.