feat(service-monitor): support bearer token authentication on metrics endpoint

Signed-off-by: Hitesh Nayak <hiteshnayak305@gmail.com>
This commit is contained in:
Hitesh Nayak 2024-04-04 02:16:56 +05:30
parent 2a9273d32f
commit 0a433ab599
No known key found for this signature in database
GPG Key ID: 2E4D20F7F119206B
3 changed files with 23 additions and 0 deletions

View File

@ -389,6 +389,10 @@ https
{{ default (printf "%s-gpg-key" (include "gitea.fullname" .)) .Values.signing.existingSecret }}
{{- end -}}
{{- define "gitea.metrics-secret-name" -}}
{{ default (printf "%s-metrics-secret" (include "gitea.fullname" .)) }}
{{- end -}}
{{- define "gitea.serviceAccountName" -}}
{{ .Values.serviceAccount.name | default (include "gitea.fullname" .) }}
{{- end -}}

View File

@ -0,0 +1,11 @@
{{- if and (.Values.gitea.config.metrics) (.Values.gitea.config.metrics.TOKEN) -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "gitea.metrics-secret-name" . }}
labels:
{{- include "gitea.labels" . | nindent 4 }}
type: Opaque
data:
token: {{ .Values.gitea.config.metrics.TOKEN | b64enc }}
{{- end }}

View File

@ -14,4 +14,12 @@ spec:
{{- include "gitea.selectorLabels" . | nindent 6 }}
endpoints:
- port: http
{{- if and (.Values.gitea.config.metrics) (.Values.gitea.config.metrics.TOKEN) }}
authorization:
type: Bearer
credentials:
name: {{ include "gitea.metrics-secret-name" . }}
key: token
optional: true
{{- end -}}
{{- end -}}