Skip to content

Commit 2f99fd3

Browse files
committed
remove deprecated kube-rbac-proxy
1 parent ed8bee9 commit 2f99fd3

17 files changed

+107
-99
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.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
control-plane: controller-manager
6+
app.kubernetes.io/name: output-dir
7+
app.kubernetes.io/managed-by: kustomize
8+
name: controller-manager-metrics-service
9+
namespace: system
10+
spec:
11+
ports:
12+
- name: https
13+
port: 8443
14+
protocol: TCP
15+
targetPort: 8443
16+
selector:
17+
control-plane: controller-manager

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ spec:
6868
periodSeconds: 10
6969
resources:
7070
limits:
71-
cpu: 500m
71+
cpu: 2000m
7272
memory: 128Mi
7373
requests:
7474
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRole
33
metadata:
4-
name: proxy-role
4+
name: metrics-auth-role
55
rules:
66
- apiGroups:
77
- authentication.k8s.io

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRoleBinding
33
metadata:
4-
name: proxy-rolebinding
4+
name: metrics-auth-rolebinding
55
roleRef:
66
apiGroup: rbac.authorization.k8s.io
77
kind: ClusterRole
8-
name: proxy-role
8+
name: metrics-auth-role
99
subjects:
1010
- kind: ServiceAccount
1111
name: controller-manager

0 commit comments

Comments
 (0)