Skip to content

Commit 0efbe08

Browse files
authored
cleanup: remove kube-rbac-proxy (#321)
* cleanup: remove kube-rbac-proxy * remove kube-rbac-proxy and update helm config
1 parent 211a0ef commit 0efbe08

18 files changed

+160
-104
lines changed

chart/templates/deployment.yaml

+3-15
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ spec:
3939
periodSeconds: 20
4040
name: manager
4141
ports:
42+
- containerPort: 8443
43+
name: metrics
44+
protocol: TCP
4245
- containerPort: 9443
4346
name: webhook-server
4447
protocol: TCP
@@ -56,21 +59,6 @@ spec:
5659
- mountPath: /tmp/k8s-webhook-server/serving-certs
5760
name: cert
5861
readOnly: true
59-
- args: {{- toYaml .Values.controllerManager.kubeRbacProxy.args | nindent 8 }}
60-
env:
61-
- name: KUBERNETES_CLUSTER_DOMAIN
62-
value: {{ quote .Values.kubernetesClusterDomain }}
63-
image: {{ .Values.controllerManager.kubeRbacProxy.image.repository }}:{{ .Values.controllerManager.kubeRbacProxy.image.tag
64-
| default .Chart.AppVersion }}
65-
name: kube-rbac-proxy
66-
ports:
67-
- containerPort: 8443
68-
name: https
69-
protocol: TCP
70-
resources: {{- toYaml .Values.controllerManager.kubeRbacProxy.resources | nindent
71-
10 }}
72-
securityContext: {{- toYaml .Values.controllerManager.kubeRbacProxy.containerSecurityContext
73-
| nindent 10 }}
7462
securityContext: {{- toYaml .Values.controllerManager.podSecurityContext | nindent
7563
8 }}
7664
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager

chart/templates/metrics-reader-rbac.yaml

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,26 @@ kind: ClusterRole
33
metadata:
44
name: {{ include "chart.fullname" . }}-metrics-reader
55
labels:
6-
app.kubernetes.io/component: kube-rbac-proxy
76
app.kubernetes.io/created-by: llmaz
87
app.kubernetes.io/part-of: llmaz
98
{{- include "chart.labels" . | nindent 4 }}
109
rules:
1110
- nonResourceURLs:
1211
- /metrics
1312
verbs:
14-
- get
13+
- get
14+
---
15+
apiVersion: rbac.authorization.k8s.io/v1
16+
kind: ClusterRoleBinding
17+
metadata:
18+
name: {{ include "chart.fullname" . }}-metrics-reader-rolebinding
19+
labels:
20+
{{- include "chart.labels" . | nindent 4 }}
21+
roleRef:
22+
apiGroup: rbac.authorization.k8s.io
23+
kind: ClusterRole
24+
name: '{{ include "chart.fullname" . }}-metrics-reader'
25+
subjects:
26+
- kind: ServiceAccount
27+
name: '{{ include "chart.fullname" . }}-controller-manager'
28+
namespace: '{{ .Release.Namespace }}'

chart/templates/metrics-service.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ kind: Service
33
metadata:
44
name: {{ include "chart.fullname" . }}-controller-manager-metrics-service
55
labels:
6-
app.kubernetes.io/component: kube-rbac-proxy
76
app.kubernetes.io/created-by: llmaz
87
app.kubernetes.io/part-of: llmaz
9-
control-plane: controller-manager
108
{{- include "chart.labels" . | nindent 4 }}
119
spec:
1210
type: {{ .Values.metricsService.type }}

chart/templates/proxy-rbac.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ kind: ClusterRole
33
metadata:
44
name: {{ include "chart.fullname" . }}-proxy-role
55
labels:
6-
app.kubernetes.io/component: kube-rbac-proxy
76
app.kubernetes.io/created-by: llmaz
87
app.kubernetes.io/part-of: llmaz
98
{{- include "chart.labels" . | nindent 4 }}
@@ -26,7 +25,6 @@ kind: ClusterRoleBinding
2625
metadata:
2726
name: {{ include "chart.fullname" . }}-proxy-rolebinding
2827
labels:
29-
app.kubernetes.io/component: kube-rbac-proxy
3028
app.kubernetes.io/created-by: llmaz
3129
app.kubernetes.io/part-of: llmaz
3230
{{- include "chart.labels" . | nindent 4 }}

chart/values.yaml

+3-24
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11
controllerManager:
2-
kubeRbacProxy:
3-
args:
4-
- --secure-listen-address=0.0.0.0:8443
5-
- --upstream=http://127.0.0.1:8080/
6-
- --logtostderr=true
7-
- --v=0
8-
containerSecurityContext:
9-
allowPrivilegeEscalation: false
10-
capabilities:
11-
drop:
12-
- ALL
13-
image:
14-
repository: gcr.io/kubebuilder/kube-rbac-proxy
15-
tag: v0.15.0
16-
resources:
17-
limits:
18-
cpu: 500m
19-
memory: 128Mi
20-
requests:
21-
cpu: 5m
22-
memory: 64Mi
232
manager:
243
args:
254
- --health-probe-bind-address=:8081
26-
- --metrics-bind-address=127.0.0.1:8080
5+
- --metrics-bind-address=:8443
276
- --leader-elect
287
- --namespace=llmaz-system
298
containerSecurityContext:
@@ -33,7 +12,7 @@ controllerManager:
3312
- ALL
3413
image:
3514
repository: inftyai/llmaz
36-
tag: v0.1.1
15+
tag: main
3716
resources:
3817
limits:
3918
cpu: 500m
@@ -52,7 +31,7 @@ metricsService:
5231
- name: https
5332
port: 8443
5433
protocol: TCP
55-
targetPort: https
34+
targetPort: 8443
5635
type: ClusterIP
5736
webhookService:
5837
ports:

cmd/main.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
ctrl "sigs.k8s.io/controller-runtime"
3131
"sigs.k8s.io/controller-runtime/pkg/healthz"
3232
"sigs.k8s.io/controller-runtime/pkg/log/zap"
33+
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
3334
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3435
lws "sigs.k8s.io/lws/api/leaderworkerset/v1"
3536

@@ -77,9 +78,18 @@ func main() {
7778

7879
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
7980

81+
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
82+
// More info:
83+
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/server
84+
// - https://book.kubebuilder.io/reference/metrics.html
85+
metricsServerOptions := metricsserver.Options{
86+
BindAddress: metricsAddr,
87+
SecureServing: true,
88+
FilterProvider: filters.WithAuthenticationAndAuthorization,
89+
}
8090
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
8191
Scheme: scheme,
82-
Metrics: metricsserver.Options{BindAddress: metricsAddr},
92+
Metrics: metricsServerOptions,
8393
HealthProbeBindAddress: probeAddr,
8494
LeaderElection: enableLeaderElection,
8595
LeaderElectionID: "fbb36db9.llmaz.io",

config/default/kustomization.yaml

+4-6
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@ resources:
2929
#- ../certmanager
3030
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
3131
#- ../prometheus
32+
# [METRICS] Expose the controller manager metrics service.
33+
- manager_metrics_service.yaml
3234

3335
patches:
34-
# Protect the /metrics endpoint by putting it behind auth.
35-
# If you want your controller-manager to expose the /metrics
36-
# endpoint w/o any authn/z, please comment the following line.
37-
- path: manager_auth_proxy_patch.yaml
38-
3936
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
4037
# crd/kustomization.yaml
4138
- path: manager_webhook_patch.yaml
42-
39+
# Expose port used by the metrics service
40+
- path: manager_metrics_patch.yaml
4341
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'.
4442
# Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks.
4543
# 'CERTMANAGER' needs to be enabled to use ca injection

config/default/manager_auth_proxy_patch.yaml

-40
This file was deleted.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This patch exposes 8443 port used by metrics service
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: controller-manager
6+
namespace: system
7+
spec:
8+
template:
9+
spec:
10+
containers:
11+
- name: manager
12+
ports:
13+
- containerPort: 8443
14+
name: metrics
15+
protocol: TCP

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
labels:
5-
control-plane: controller-manager
65
app.kubernetes.io/name: service
76
app.kubernetes.io/instance: controller-manager-metrics-service
8-
app.kubernetes.io/component: kube-rbac-proxy
97
app.kubernetes.io/created-by: llmaz
108
app.kubernetes.io/part-of: llmaz
11-
app.kubernetes.io/managed-by: kustomize
129
name: controller-manager-metrics-service
1310
namespace: system
1411
spec:
1512
ports:
1613
- name: https
1714
port: 8443
1815
protocol: TCP
19-
targetPort: https
16+
targetPort: 8443
2017
selector:
2118
control-plane: controller-manager

config/manager/manager.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ spec:
6969
- command:
7070
- /manager
7171
args:
72-
- --leader-elect
72+
- --health-probe-bind-address=:8081
73+
- --metrics-bind-address=:8443
74+
- --leader-elect
75+
- --namespace=llmaz-system
7376
image: controller:latest
7477
name: manager
7578
securityContext:
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: metrics-reader-rolebinding
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: metrics-reader
9+
subjects:
10+
- kind: ServiceAccount
11+
name: controller-manager
12+
namespace: system

config/rbac/auth_proxy_client_clusterrole.yaml

-1
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: llmaz
98
app.kubernetes.io/part-of: llmaz
109
app.kubernetes.io/managed-by: kustomize

config/rbac/auth_proxy_role.yaml

-1
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: proxy-role
7-
app.kubernetes.io/component: kube-rbac-proxy
87
app.kubernetes.io/created-by: llmaz
98
app.kubernetes.io/part-of: llmaz
109
app.kubernetes.io/managed-by: kustomize

config/rbac/auth_proxy_role_binding.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ metadata:
44
labels:
55
app.kubernetes.io/name: clusterrolebinding
66
app.kubernetes.io/instance: proxy-rolebinding
7-
app.kubernetes.io/component: kube-rbac-proxy
87
app.kubernetes.io/created-by: llmaz
98
app.kubernetes.io/part-of: llmaz
109
app.kubernetes.io/managed-by: kustomize

config/rbac/kustomization.yaml

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ 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
1612
- auth_proxy_role.yaml
1713
- auth_proxy_role_binding.yaml
1814
- auth_proxy_client_clusterrole.yaml
15+
- auth_proxy_client_binding.yaml

0 commit comments

Comments
 (0)