Skip to content

Commit

Permalink
add metric scraping config on web charts
Browse files Browse the repository at this point in the history
  • Loading branch information
yosefmih committed Dec 11, 2024
1 parent f88f924 commit 435ba13
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
6 changes: 6 additions & 0 deletions applications/web/templates/deployment-blue-green-legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ spec:
- name: http
containerPort: {{ $.Values.container.port }}
protocol: TCP
{{- if and .Values.metricsScraping.enabled (ne .Values.metricsScraping.port .Values.container.port) }}
# if metrics scraping is enabled and the port is not the same as the container port, add a metrics port
- name: metrics
containerPort: {{ .Values.metricsScraping.port }}
protocol: TCP
{{- end }}
{{- range $.Values.container.extraPorts }}
- name: {{ .name }}
containerPort: {{ .containerPort }}
Expand Down
6 changes: 6 additions & 0 deletions applications/web/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ spec:
- name: http
containerPort: {{ .Values.container.port }}
protocol: TCP
{{- if and .Values.metricsScraping.enabled (ne .Values.metricsScraping.port .Values.container.port) }}
# if metrics scraping is enabled and the port is not the same as the container port, add a metrics port
- name: metrics
containerPort: {{ .Values.metricsScraping.port }}
protocol: TCP
{{- end }}
{{- range .Values.container.extraPorts }}
- name: {{ .name }}
containerPort: {{ .containerPort }}
Expand Down
19 changes: 16 additions & 3 deletions applications/web/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ metadata:
{{- if .Values.labels }}
{{- toYaml .Values.labels | nindent 4 }}
{{- end }}
{{- if .Values.service.annotations }}
{{- if gt (len .Values.service.annotations) 0}}
{{- if or .Values.metricsScraping.enabled (and .Values.service.annotations (gt (len .Values.service.annotations) 0)) }}
annotations:
{{- if .Values.metricsScraping.enabled }}
porter.prometheus/scrape: "true"
porter.prometheus/port: {{ .Values.metricsScraping.port | quote }}
porter.prometheus/path: {{ .Values.metricsScraping.path | quote }}
porter.prometheus/scheme: "http"
{{- end }}
{{- if and .Values.service.annotations (gt (len .Values.service.annotations) 0) }}
{{- range $k, $v := .Values.service.annotations }}
{{ $k }}: {{ $v | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
spec:
{{ if or .Values.ingress.enabled .Values.albIngress.enabled .Values.customNodePort.enabled }}
Expand All @@ -32,6 +38,13 @@ spec:
{{- else if .Values.customNodePort.enabled }}
nodePort: {{ .Values.customNodePort.port }}
{{- end }}
{{- if and .Values.metricsScraping.enabled (ne .Values.metricsScraping.port .Values.service.port) }}
# add metrics scraping port if metrics scraping is enabled and the port is not the same as the service port
- port: {{ .Values.metricsScraping.port }}
targetPort: metrics
protocol: TCP
name: metrics
{{- end }}
{{- range .Values.service.extraPorts }}
- port: {{ .port }}
targetPort: {{ .targetPort }}
Expand Down
6 changes: 6 additions & 0 deletions applications/web/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,9 @@ fileSecretMounts:
mounts: []

nodeGroups: []


metricsScraping:
enabled: false
port: 80
path: "/metrics"

0 comments on commit 435ba13

Please sign in to comment.