Skip to content

Commit 60c3f0c

Browse files
ChughShilpasutaakar
authored andcommitted
Restrict secrets RBAC to namespace-scoped Role
1 parent ad45188 commit 60c3f0c

5 files changed

Lines changed: 35 additions & 10 deletions

File tree

manifests/base/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ resources:
55
- ./rbac/cluster-role-binding.yaml
66
- ./rbac/role.yaml
77
- ./rbac/service-account.yaml
8+
- ./rbac/webhook-secret-role.yaml
9+
- ./rbac/webhook-secret-role-binding.yaml
810
- ./webhook
911
- service.yaml
1012
- deployment.yaml

manifests/base/rbac/role.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,6 @@ rules:
4343
- pods/exec
4444
verbs:
4545
- create
46-
- apiGroups:
47-
- ""
48-
resources:
49-
- secrets
50-
verbs:
51-
- get
52-
- list
53-
- update
54-
- watch
5546
- apiGroups:
5647
- ""
5748
resources:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: RoleBinding
4+
metadata:
5+
labels:
6+
app: training-operator
7+
name: training-operator-webhook
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: Role
11+
name: training-operator-webhook
12+
subjects:
13+
- kind: ServiceAccount
14+
name: training-operator
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
labels:
6+
app: training-operator
7+
name: training-operator-webhook
8+
rules:
9+
- apiGroups:
10+
- ""
11+
resources:
12+
- secrets
13+
verbs:
14+
- get
15+
- list
16+
- update
17+
- watch

pkg/cert/cert.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ type Config struct {
3838
WebhookConfigurationName string
3939
}
4040

41-
//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;update
41+
// Note: Secrets access is handled via a namespace-scoped Role (not ClusterRole) to limit
42+
// permissions to the operator's own namespace only. See manifests/base/rbac/webhook-secret-role.yaml.
4243
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=validatingwebhookconfigurations,verbs=get;list;watch;update
4344

4445
// ManageCerts creates all certs for webhooks.

0 commit comments

Comments
 (0)