Skip to content

Commit

Permalink
rbac changes
Browse files Browse the repository at this point in the history
Signed-off-by: ashnamehrotra <[email protected]>
  • Loading branch information
ashnamehrotra committed Jan 31, 2024
1 parent aff6d40 commit 1d3f27d
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 140 deletions.
12 changes: 12 additions & 0 deletions config/rbac/cluster_role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: manager-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: manager-role
subjects:
- kind: ServiceAccount
name: controller-manager
namespace: system
31 changes: 0 additions & 31 deletions config/rbac/eraserconfig_editor_role.yaml

This file was deleted.

27 changes: 0 additions & 27 deletions config/rbac/eraserconfig_viewer_role.yaml

This file was deleted.

1 change: 1 addition & 0 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ resources:
- imagejob_pods_cluster_role.yaml
- imagejob_pods_service.yaml
- imagejob_pods_cluster_role_binding.yaml
- cluster_role_binding.yaml
# Comment the following 4 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
Expand Down
59 changes: 33 additions & 26 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand All @@ -25,32 +13,29 @@ rules:
- list
- watch
- apiGroups:
- ""
- eraser.sh
resources:
- pods
- imagejobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
- eraser.sh
resources:
- podtemplates
- imagejobs/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- eraser.sh
resources:
- imagejobs
- imagelists
verbs:
- create
- delete
Expand All @@ -62,15 +47,22 @@ rules:
- apiGroups:
- eraser.sh
resources:
- imagejobs/status
- imagelists/status
verbs:
- get
- patch
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: manager-role
namespace: system
rules:
- apiGroups:
- eraser.sh
- ""
resources:
- imagelists
- configmaps
verbs:
- create
- delete
Expand All @@ -80,10 +72,25 @@ rules:
- update
- watch
- apiGroups:
- eraser.sh
- ""
resources:
- imagelists/status
- pods
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- ""
resources:
- podtemplates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
5 changes: 3 additions & 2 deletions config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
kind: RoleBinding
metadata:
name: manager-rolebinding
namespace: system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
kind: Role
name: manager-role
subjects:
- kind: ServiceAccount
Expand Down
6 changes: 5 additions & 1 deletion controllers/imagecollector/imagecollector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ func add(mgr manager.Manager, r *Reconciler) error {
return nil
}

//+kubebuilder:rbac:groups="",resources=podtemplates,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=eraser.sh,resources=imagelists,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="",namespace="system",resources=podtemplates,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=eraser.sh,resources=imagelists/status,verbs=get;update;patch
//+kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch
//+kubebuilder:rbac:groups="",namespace="system",resources=pods,verbs=get;list;watch;update;create;delete

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
4 changes: 2 additions & 2 deletions controllers/imagejob/imagejob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ func checkNodeFitness(pod *corev1.Pod, node *corev1.Node) bool {
}

//+kubebuilder:rbac:groups=eraser.sh,resources=imagejobs,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="",resources=podtemplates,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="",namespace="system",resources=podtemplates,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=eraser.sh,resources=imagejobs/status,verbs=get;update;patch
//+kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="",namespace="system",resources=configmaps,verbs=get;list;watch;create;update;patch;delete

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
4 changes: 2 additions & 2 deletions controllers/imagelist/imagelist_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ type Reconciler struct {
}

//+kubebuilder:rbac:groups=eraser.sh,resources=imagelists,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="",resources=podtemplates,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups="",namespace="system",resources=podtemplates,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=eraser.sh,resources=imagelists/status,verbs=get;update;patch
//+kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch
//+kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch;update;create;delete
//+kubebuilder:rbac:groups="",namespace="system",resources=pods,verbs=get;list;watch;update;create;delete

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ metadata:
helm.sh/chart: '{{ template "eraser.name" . }}'
name: eraser-manager-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand All @@ -28,29 +16,6 @@ rules:
- get
- list
- watch
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- ""
resources:
- podtemplates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- eraser.sh
resources:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
app.kubernetes.io/instance: '{{ .Release.Name }}'
app.kubernetes.io/managed-by: '{{ .Release.Service }}'
app.kubernetes.io/name: '{{ template "eraser.name" . }}'
helm.sh/chart: '{{ template "eraser.name" . }}'
name: eraser-manager-role
namespace: '{{ .Release.Namespace }}'
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- ""
resources:
- podtemplates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
app.kubernetes.io/instance: '{{ .Release.Name }}'
app.kubernetes.io/managed-by: '{{ .Release.Service }}'
app.kubernetes.io/name: '{{ template "eraser.name" . }}'
helm.sh/chart: '{{ template "eraser.name" . }}'
name: eraser-manager-rolebinding
namespace: '{{ .Release.Namespace }}'
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: eraser-manager-role
subjects:
- kind: ServiceAccount
name: eraser-controller-manager
namespace: '{{ .Release.Namespace }}'
Loading

0 comments on commit 1d3f27d

Please sign in to comment.