Skip to content

Commit 2882372

Browse files
committed
remove deprecated kube-rbac-proxy
1 parent 0bb321d commit 2882372

17 files changed

+110
-109
lines changed

cmd/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
ctrl "sigs.k8s.io/controller-runtime"
4343
"sigs.k8s.io/controller-runtime/pkg/client"
4444
"sigs.k8s.io/controller-runtime/pkg/log/zap"
45+
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
4546
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4647
"sigs.k8s.io/controller-runtime/pkg/webhook"
4748
"sigs.k8s.io/yaml"
@@ -126,9 +127,10 @@ func main() {
126127
mgr, err := ctrl.NewManager(k8sConfig, ctrl.Options{
127128
Scheme: scheme,
128129
Metrics: metricsserver.Options{
129-
BindAddress: cfg.ControllerManager.Metrics.BindAddress,
130-
SecureServing: cfg.ControllerManager.Metrics.SecureServing,
131-
TLSOpts: tlsOpts,
130+
BindAddress: cfg.ControllerManager.Metrics.BindAddress,
131+
SecureServing: true,
132+
TLSOpts: tlsOpts,
133+
FilterProvider: filters.WithAuthenticationAndAuthorization,
132134
},
133135
WebhookServer: webhook.NewServer(webhook.Options{
134136
TLSOpts: tlsOpts,

config/default/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ data:
1010
health:
1111
bindAddress: ":8081"
1212
metrics:
13-
bindAddress: "127.0.0.1:8080"
13+
bindAddress: "127.0.0.1:8443"
1414
leaderElection: true

config/default/kustomization.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ resources:
2525
- ../internalcert
2626
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2727
#- ../prometheus
28+
# [METRICS] Expose the controller manager metrics service.
29+
- metrics_service.yaml
2830

2931
patches:
30-
# Protect the /metrics endpoint by putting it behind auth.
31-
# If you want your controller-manager to expose the /metrics
32-
# endpoint w/o any authn/z, please comment the following line.
33-
- path: manager_auth_proxy_patch.yaml
34-
3532
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
3633
# crd/kustomization.yaml
3734
- path: manager_webhook_patch.yaml

config/default/manager_auth_proxy_patch.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

config/rbac/auth_proxy_service.yaml renamed to config/default/metrics_service.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ kind: Service
33
metadata:
44
labels:
55
control-plane: controller-manager
6-
app.kubernetes.io/name: service
7-
app.kubernetes.io/instance: controller-manager-metrics-service
8-
app.kubernetes.io/component: kube-rbac-proxy
9-
app.kubernetes.io/created-by: appwrapper
10-
app.kubernetes.io/part-of: appwrapper
6+
app.kubernetes.io/name: output-dir
117
app.kubernetes.io/managed-by: kustomize
128
name: controller-manager-metrics-service
139
namespace: system
@@ -16,6 +12,6 @@ spec:
1612
- name: https
1713
port: 8443
1814
protocol: TCP
19-
targetPort: https
15+
targetPort: 8443
2016
selector:
2117
control-plane: controller-manager

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ spec:
8080
periodSeconds: 10
8181
resources:
8282
limits:
83-
cpu: 500m
83+
cpu: 2000m
8484
memory: 128Mi
8585
requests:
8686
cpu: 10m

config/rbac/kustomization.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ resources:
1212
- user_role.yaml
1313
- editor_role.yaml
1414
- viewer_role.yaml
15-
# Comment the following 4 lines if you want to disable
16-
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
17-
# which protects your /metrics endpoint.
18-
- auth_proxy_service.yaml
19-
- auth_proxy_role.yaml
20-
- auth_proxy_role_binding.yaml
21-
- auth_proxy_client_clusterrole.yaml
15+
16+
# The following RBAC configurations are used to protect
17+
# the metrics endpoint with authn/authz. These configurations
18+
# ensure that only authorized users and service accounts
19+
# can access the metrics endpoint. Comment the following
20+
# permissions if you want to disable this protection.
21+
# More info: https://book.kubebuilder.io/reference/metrics.html
22+
- metrics_auth_role.yaml
23+
- metrics_auth_role_binding.yaml
24+
- metrics_reader_role.yaml

config/rbac/auth_proxy_role.yaml renamed to config/rbac/metrics_auth_role.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ kind: ClusterRole
33
metadata:
44
labels:
55
app.kubernetes.io/name: clusterrole
6-
app.kubernetes.io/instance: proxy-role
7-
app.kubernetes.io/component: kube-rbac-proxy
6+
app.kubernetes.io/instance: metrics-role
87
app.kubernetes.io/created-by: appwrapper
98
app.kubernetes.io/part-of: appwrapper
109
app.kubernetes.io/managed-by: kustomize
11-
name: proxy-role
10+
name: metrics-auth-role
1211
rules:
1312
- apiGroups:
1413
- authentication.k8s.io

config/rbac/auth_proxy_role_binding.yaml renamed to config/rbac/metrics_auth_role_binding.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ kind: ClusterRoleBinding
33
metadata:
44
labels:
55
app.kubernetes.io/name: clusterrolebinding
6-
app.kubernetes.io/instance: proxy-rolebinding
7-
app.kubernetes.io/component: kube-rbac-proxy
6+
app.kubernetes.io/instance: metrics-auth-rolebinding
87
app.kubernetes.io/created-by: appwrapper
98
app.kubernetes.io/part-of: appwrapper
109
app.kubernetes.io/managed-by: kustomize
11-
name: proxy-rolebinding
10+
name: metrics-auth-rolebinding
1211
roleRef:
1312
apiGroup: rbac.authorization.k8s.io
1413
kind: ClusterRole
15-
name: proxy-role
14+
name: metrics-auth-role
1615
subjects:
1716
- kind: ServiceAccount
1817
name: controller-manager

config/rbac/auth_proxy_client_clusterrole.yaml renamed to config/rbac/metrics_reader_role.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ metadata:
44
labels:
55
app.kubernetes.io/name: clusterrole
66
app.kubernetes.io/instance: metrics-reader
7-
app.kubernetes.io/component: kube-rbac-proxy
87
app.kubernetes.io/created-by: appwrapper
98
app.kubernetes.io/part-of: appwrapper
109
app.kubernetes.io/managed-by: kustomize

0 commit comments

Comments
 (0)