Skip to content

Commit 1361c2f

Browse files
committed
Use kube-rbac-proxy to expose prometheus metric endpoint
1 parent 699b8cb commit 1361c2f

23 files changed

+177
-12
lines changed

chart/templates/_helpers.tpl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,29 @@ storage:
351351
{{ toYaml .remoteStorage | indent 2 }}
352352
{{- end -}}
353353
{{- end -}}
354+
355+
{{- define "gitpod.kube-rbac-proxy" -}}
356+
- name: kube-rbac-proxy
357+
image: quay.io/brancz/kube-rbac-proxy:v0.9.0
358+
args:
359+
- --logtostderr
360+
- --insecure-listen-address=[$(IP)]:9500
361+
- --upstream=http://127.0.0.1:9500/
362+
env:
363+
- name: IP
364+
valueFrom:
365+
fieldRef:
366+
fieldPath: status.podIP
367+
ports:
368+
- containerPort: 9500
369+
name: metrics
370+
resources:
371+
requests:
372+
cpu: 1m
373+
memory: 30Mi
374+
securityContext:
375+
runAsGroup: 65532
376+
runAsNonRoot: true
377+
runAsUser: 65532
378+
terminationMessagePolicy: FallbackToLogsOnError
379+
{{- end -}}

chart/templates/blobserve-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ data:
1717
{
1818
{{ if .Values.components.workspace.pullSecret.secretName -}}"dockerAuth": "/mnt/pull-secret.json",{{- end }}
1919
"pprofAddr": ":6060",
20-
"prometheusAddr": ":9500"
20+
"prometheusAddr": "127.0.0.1:9500"
2121
, "blobserve": {
2222
"port": {{ $comp.ports.service.containerPort }},
2323
"timeout": {{ ($comp.timeout | default "5s") | quote }},

chart/templates/blobserve-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ spec:
7171
mountPath: /mnt/pull-secret.json
7272
subPath: .dockerconfigjson
7373
{{- end }}
74+
{{ include "gitpod.kube-rbac-proxy" $this | indent 6 }}
7475
volumes:
7576
- name: cache
7677
emptyDir: {}

chart/templates/blobserve-rolebinding.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,23 @@ roleRef:
1717
kind: ClusterRole
1818
name: {{ .Release.Namespace }}-ns-psp:restricted-root-user
1919
apiGroup: rbac.authorization.k8s.io
20+
21+
---
22+
23+
kind: ClusterRoleBinding
24+
apiVersion: rbac.authorization.k8s.io/v1
25+
metadata:
26+
name: blobserve-kube-rbac-proxy
27+
labels:
28+
app: {{ template "gitpod.fullname" . }}
29+
component: blobserve
30+
kind: role-binding
31+
stage: {{ .Values.installation.stage }}
32+
subjects:
33+
- kind: ServiceAccount
34+
name: blobserve
35+
namespace: {{ .Release.Namespace }}
36+
roleRef:
37+
kind: ClusterRole
38+
name: {{ .Release.Namespace }}-kube-rbac-proxy
39+
apiGroup: rbac.authorization.k8s.io

chart/templates/blobserve-serviceaccount.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ metadata:
1010
component: blobserve
1111
kind: service-account
1212
stage: {{ .Values.installation.stage }}
13-
automountServiceAccountToken: false

chart/templates/image-builder-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ data:
4444
"address": ":6060"
4545
},
4646
"prometheus": {
47-
"address": ":9500"
47+
"address": "127.0.0.1:9500"
4848
},
4949
"service": {
5050
"address": ":8080"

chart/templates/image-builder-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ spec:
8686
{{- end }}
8787
{{ include "gitpod.container.defaultEnv" $this | indent 8 }}
8888
{{ include "gitpod.container.tracingEnv" $this | indent 8 }}
89+
{{ include "gitpod.kube-rbac-proxy" $this | indent 6 }}
8990
- name: service
9091
image: {{ template "gitpod.comp.imageFull" $this }}
9192
args:

chart/templates/image-builder-rolebinding.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,23 @@ roleRef:
1717
kind: ClusterRole
1818
name: {{ .Release.Namespace }}-ns-image-builder
1919
apiGroup: rbac.authorization.k8s.io
20+
21+
---
22+
23+
kind: ClusterRoleBinding
24+
apiVersion: rbac.authorization.k8s.io/v1
25+
metadata:
26+
name: image-builder-kube-rbac-proxy
27+
labels:
28+
app: {{ template "gitpod.fullname" . }}
29+
component: image-builder
30+
kind: role-binding
31+
stage: {{ .Values.installation.stage }}
32+
subjects:
33+
- kind: ServiceAccount
34+
name: image-builder
35+
namespace: {{ .Release.Namespace }}
36+
roleRef:
37+
kind: ClusterRole
38+
name: {{ .Release.Namespace }}-kube-rbac-proxy
39+
apiGroup: rbac.authorization.k8s.io

chart/templates/image-builder-serviceaccount.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ metadata:
1010
component: image-builder
1111
kind: service-account
1212
stage: {{ .Values.installation.stage }}
13-
automountServiceAccountToken: false
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2+
# Licensed under the MIT License. See License-MIT.txt in the project root for license information.
3+
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: ClusterRole
6+
metadata:
7+
name: {{ .Release.Namespace }}-kube-rbac-proxy
8+
rules:
9+
- apiGroups: ["authentication.k8s.io"]
10+
resources:
11+
- tokenreviews
12+
verbs: ["create"]
13+
- apiGroups: ["authorization.k8s.io"]
14+
resources:
15+
- subjectaccessreviews
16+
verbs: ["create"]

chart/templates/registry-facade-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ data:
5353
]
5454
},
5555
"pprofAddr": ":6060",
56-
"prometheusAddr": ":9500"
56+
"prometheusAddr": "127.0.0.1:9500"
5757
}
5858
{{- end -}}

chart/templates/registry-facade-daemonset.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ spec:
7474
- name: https-certificates
7575
mountPath: "/mnt/certificates"
7676
{{- end }}
77+
{{ include "gitpod.kube-rbac-proxy" $this | indent 6 }}
7778
volumes:
7879
- name: cache
7980
emptyDir: {}

chart/templates/registry-facade-rolebinding.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,23 @@ roleRef:
1717
kind: ClusterRole
1818
name: {{ .Release.Namespace }}-ns-registry-facade
1919
apiGroup: rbac.authorization.k8s.io
20+
21+
---
22+
23+
kind: ClusterRoleBinding
24+
apiVersion: rbac.authorization.k8s.io/v1
25+
metadata:
26+
name: registry-facade-kube-rbac-proxy
27+
labels:
28+
app: {{ template "gitpod.fullname" . }}
29+
component: registry-facade
30+
kind: role-binding
31+
stage: {{ .Values.installation.stage }}
32+
subjects:
33+
- kind: ServiceAccount
34+
name: registry-facade
35+
namespace: {{ .Release.Namespace }}
36+
roleRef:
37+
kind: ClusterRole
38+
name: {{ .Release.Namespace }}-kube-rbac-proxy
39+
apiGroup: rbac.authorization.k8s.io

chart/templates/registry-facade-serviceaccount.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ metadata:
1010
component: registry-facade
1111
kind: service-account
1212
stage: {{ .Values.installation.stage }}
13-
automountServiceAccountToken: false

chart/templates/ws-daemon-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ service:
7272
crt: "/certs/tls.crt"
7373
key: "/certs/tls.key"
7474
prometheus:
75-
address: ":9500"
75+
address: "127.0.0.1:9500"
7676
pprof:
7777
address: ":6060"
7878
{{ end }}

chart/templates/ws-daemon-daemonset.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,6 @@ spec:
201201
securityContext:
202202
privileged: true
203203
procMount: Unmasked
204+
{{ include "gitpod.kube-rbac-proxy" $this | indent 6 }}
204205
{{ toYaml .Values.defaults | indent 6 }}
205206
{{ end }}

chart/templates/ws-daemon-rolebinding.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,23 @@ roleRef:
1717
kind: ClusterRole
1818
name: {{ .Release.Namespace }}-ns-ws-daemon
1919
apiGroup: rbac.authorization.k8s.io
20+
21+
---
22+
23+
kind: ClusterRoleBinding
24+
apiVersion: rbac.authorization.k8s.io/v1
25+
metadata:
26+
name: ws-daemon-rb-kube-rbac-proxy
27+
labels:
28+
app: {{ template "gitpod.fullname" . }}
29+
component: ws-daemon
30+
kind: role-binding
31+
stage: {{ .Values.installation.stage }}
32+
subjects:
33+
- kind: ServiceAccount
34+
name: ws-daemon
35+
namespace: {{ .Release.Namespace }}
36+
roleRef:
37+
kind: ClusterRole
38+
name: {{ .Release.Namespace }}-kube-rbac-proxy
39+
apiGroup: rbac.authorization.k8s.io

chart/templates/ws-manager-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ data:
118118
"addr": "localhost:6060"
119119
},
120120
"prometheus": {
121-
"addr": ":9500"
121+
"addr": "127.0.0.1:9500"
122122
}
123123
}
124124
{{- end -}}

chart/templates/ws-manager-rolebinding.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,23 @@ roleRef:
1717
subjects:
1818
- kind: ServiceAccount
1919
name: ws-manager
20+
21+
---
22+
23+
apiVersion: rbac.authorization.k8s.io/v1
24+
kind: ClusterRoleBinding
25+
metadata:
26+
name: ws-manager-kube-rbac-proxy
27+
labels:
28+
app: {{ template "gitpod.fullname" . }}
29+
component: ws-manager
30+
kind: role-binding
31+
stage: {{ .Values.installation.stage }}
32+
subjects:
33+
- kind: ServiceAccount
34+
name: ws-manager
35+
namespace: {{ .Release.Namespace }}
36+
roleRef:
37+
kind: ClusterRole
38+
name: {{ .Release.Namespace }}-kube-rbac-proxy
39+
apiGroup: rbac.authorization.k8s.io

chart/templates/ws-scheduler-clusterrolebinding.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,26 @@ subjects:
1717
roleRef:
1818
kind: ClusterRole
1919
name: {{ .Release.Namespace }}-ns-ws-scheduler
20-
apiGroup: rbac.authorization.k8s.io
20+
apiGroup: rbac.authorization.k8s.io
21+
22+
---
23+
24+
kind: ClusterRoleBinding
25+
apiVersion: rbac.authorization.k8s.io/v1
26+
metadata:
27+
name: {{ .Release.Namespace }}-ns-ws-scheduler-kube-rbac-proxy
28+
labels:
29+
app: {{ template "gitpod.fullname" . }}
30+
component: ws-scheduler
31+
kind: role-binding
32+
stage: {{ .Values.installation.stage }}
33+
subjects:
34+
- kind: ServiceAccount
35+
name: ws-scheduler
36+
namespace: {{ .Release.Namespace }}
37+
roleRef:
38+
kind: ClusterRole
39+
name: {{ .Release.Namespace }}-kube-rbac-proxy
40+
apiGroup: rbac.authorization.k8s.io
41+
42+

chart/templates/ws-scheduler-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ data:
1919
"addr": "localhost:6060"
2020
},
2121
"prometheus": {
22-
"addr": ":9500"
22+
"addr": "127.0.0.1:9500"
2323
},
2424
"scheduler": {
2525
"schedulerName": "{{ $comp.schedulerName }}",

components/image-builder/example-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"address": ":9999"
1414
},
1515
"prometheus": {
16-
"address": ":9500"
16+
"address": "127.0.0.1:9500"
1717
},
1818
"service": {
1919
"address": ":8080"

components/ws-daemon/example-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"address": ":8080"
2929
},
3030
"prometheus": {
31-
"address": ":9500"
31+
"address": "127.0.0.1:9500"
3232
}
3333
}

0 commit comments

Comments
 (0)