Skip to content

Commit 767d31c

Browse files
authored
fix: rbac too wide (#99)
1 parent 177df23 commit 767d31c

10 files changed

+62
-82
lines changed
+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
resources:
2+
- role.yaml
3+
- role_binding.yaml
24
- secret.yaml

config/internalcert/role.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
labels:
5+
app.kubernetes.io/name: role
6+
app.kubernetes.io/instance: internal-cert-role
7+
app.kubernetes.io/component: internal-cert
8+
app.kubernetes.io/created-by: kube-startup-cpu-boost
9+
app.kubernetes.io/part-of: kube-startup-cpu-boost
10+
app.kubernetes.io/managed-by: kustomize
11+
name: internal-cert-role
12+
rules:
13+
- apiGroups:
14+
- ""
15+
resources:
16+
- secrets
17+
verbs:
18+
- get
19+
- list
20+
- watch
21+
- create
22+
- update
23+
- patch
24+
- delete

config/rbac/auth_proxy_role_binding.yaml renamed to config/internalcert/role_binding.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
apiVersion: rbac.authorization.k8s.io/v1
2-
kind: ClusterRoleBinding
2+
kind: RoleBinding
33
metadata:
44
labels:
5-
app.kubernetes.io/name: clusterrolebinding
6-
app.kubernetes.io/instance: proxy-rolebinding
7-
app.kubernetes.io/component: kube-rbac-proxy
5+
app.kubernetes.io/name: rolebinding
6+
app.kubernetes.io/instance: internal-cert-rolebinding
7+
app.kubernetes.io/component: internal-cert
88
app.kubernetes.io/created-by: kube-startup-cpu-boost
99
app.kubernetes.io/part-of: kube-startup-cpu-boost
1010
app.kubernetes.io/managed-by: kustomize
11-
name: proxy-rolebinding
11+
name: internal-cert-rolebinding
1212
roleRef:
1313
apiGroup: rbac.authorization.k8s.io
14-
kind: ClusterRole
15-
name: proxy-role
14+
kind: Role
15+
name: internal-cert-role
1616
subjects:
1717
- kind: ServiceAccount
1818
name: controller-manager

config/internalcert/secret.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
apiVersion: v1
22
kind: Secret
33
metadata:
4+
labels:
5+
app.kubernetes.io/name: secret
6+
app.kubernetes.io/instance: webhook-secret
7+
app.kubernetes.io/component: internal-cert
8+
app.kubernetes.io/created-by: kube-startup-cpu-boost
9+
app.kubernetes.io/part-of: kube-startup-cpu-boost
10+
app.kubernetes.io/managed-by: kustomize
411
name: webhook-secret
5-
namespace: system

config/rbac/auth_proxy_client_clusterrole.yaml

-16
This file was deleted.

config/rbac/auth_proxy_role.yaml

-24
This file was deleted.

config/rbac/auth_proxy_service.yaml

-21
This file was deleted.

config/rbac/kustomization.yaml

-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ resources:
99
- role_binding.yaml
1010
- leader_election_role.yaml
1111
- leader_election_role_binding.yaml
12-
# Comment the following 4 lines if you want to disable
13-
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
14-
# which protects your /metrics endpoint.
15-
- auth_proxy_service.yaml
16-
- auth_proxy_role.yaml
17-
- auth_proxy_role_binding.yaml
18-
- auth_proxy_client_clusterrole.yaml

config/rbac/role.yaml

+18-3
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,37 @@ rules:
1212
- ""
1313
resources:
1414
- pods
15-
- secrets
1615
verbs:
1716
- get
1817
- list
1918
- update
2019
- watch
2120
- apiGroups:
2221
- admissionregistration.k8s.io
22+
resourceNames:
23+
- kube-startup-cpu-boost-mutating-webhook-configuration
2324
resources:
2425
- mutatingwebhookconfigurations
25-
- validatingwebhookconfigurations
2626
verbs:
2727
- get
28-
- list
2928
- update
29+
- apiGroups:
30+
- admissionregistration.k8s.io
31+
resources:
32+
- mutatingwebhookconfigurations
33+
- validatingwebhookconfigurations
34+
verbs:
35+
- list
3036
- watch
37+
- apiGroups:
38+
- admissionregistration.k8s.io
39+
resourceNames:
40+
- kube-startup-cpu-boost-validating-webhook-configuration
41+
resources:
42+
- validatingwebhookconfigurations
43+
verbs:
44+
- get
45+
- update
3146
- apiGroups:
3247
- autoscaling.x-k8s.io
3348
resources:

internal/util/cert.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ const (
3232
webhookSecretName = "kube-startup-cpu-boost-webhook-secret"
3333
)
3434

35-
//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;update
36-
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=mutatingwebhookconfigurations,verbs=get;list;watch;update
37-
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=validatingwebhookconfigurations,verbs=get;list;watch;update
35+
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=mutatingwebhookconfigurations,verbs=list;watch
36+
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=validatingwebhookconfigurations,verbs=list;watch
37+
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=mutatingwebhookconfigurations,resourceNames=kube-startup-cpu-boost-mutating-webhook-configuration,verbs=get;update
38+
//+kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=validatingwebhookconfigurations,resourceNames=kube-startup-cpu-boost-validating-webhook-configuration,verbs=get;update
3839

3940
func ManageCerts(mgr ctrl.Manager, namespace string, setupFinished chan struct{}) error {
4041
dnsName := fmt.Sprintf("%s.%s.svc", webhookServiceName, namespace)

0 commit comments

Comments
 (0)