Skip to content

Commit

Permalink
Reduce RBAC
Browse files Browse the repository at this point in the history
Fixes: #47 - I don't think create/delete are needed for
namespace, which is user-managed. Patch/update might be
needed to manage the status.

The same goes for ClusterPullSecret - which is a user-managed
resource.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Nov 18, 2024
1 parent 77b2b0b commit a691755
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ bin
*.swo
*~
/registry-creds
/kubeconfig
10 changes: 0 additions & 10 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,15 @@ rules:
resources:
- namespaces
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- namespaces/status
verbs:
- get
- patch
- update
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -69,12 +63,8 @@ rules:
resources:
- clusterpullsecrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ops.alexellis.io
Expand Down
2 changes: 1 addition & 1 deletion controllers/clusterpullsecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ClusterPullSecretReconciler struct {
SecretReconciler *SecretReconciler
}

// +kubebuilder:rbac:groups=ops.alexellis.io,resources=clusterpullsecrets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=ops.alexellis.io,resources=clusterpullsecrets,verbs=get;list;watch
// +kubebuilder:rbac:groups=ops.alexellis.io,resources=clusterpullsecrets/status,verbs=get;update;patch

// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
Expand Down
4 changes: 2 additions & 2 deletions controllers/namespace_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type NamespaceWatcher struct {
SecretReconciler *SecretReconciler
}

// +kubebuilder:rbac:groups=core,resources=namespaces,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=namespaces/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=core,resources=namespaces,verbs=get;list;watch
// +kubebuilder:rbac:groups=core,resources=namespaces/status,verbs=get

func (r *NamespaceWatcher) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
r.Log.WithValues("namespace", req.NamespacedName)
Expand Down
20 changes: 0 additions & 20 deletions kubeconfig

This file was deleted.

11 changes: 0 additions & 11 deletions manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,15 @@ rules:
resources:
- namespaces
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- namespaces/status
verbs:
- get
- patch
- update
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -165,12 +159,8 @@ rules:
resources:
- clusterpullsecrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ops.alexellis.io
Expand Down Expand Up @@ -241,4 +231,3 @@ spec:
cpu: 100m
memory: 45Mi
terminationGracePeriodSeconds: 10
automountServiceAccountToken: true

0 comments on commit a691755

Please sign in to comment.