Skip to content

Commit 863c282

Browse files
authored
Merge pull request #1454 from porter-dev/ym/metric_scraping_apps
feat: add metric scraping config on web charts
2 parents 36a0aa5 + f08a3ab commit 863c282

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

applications/web/templates/deployment-blue-green-legacy.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ spec:
7474
- name: http
7575
containerPort: {{ $.Values.container.port }}
7676
protocol: TCP
77+
{{- if and .Values.metricsScraping.enabled (ne .Values.metricsScraping.port .Values.container.port) }}
78+
# if metrics scraping is enabled and the port is not the same as the container port, add a metrics port
79+
- name: metrics
80+
containerPort: {{ .Values.metricsScraping.port }}
81+
protocol: TCP
82+
{{- end }}
7783
{{- range $.Values.container.extraPorts }}
7884
- name: {{ .name }}
7985
containerPort: {{ .containerPort }}

applications/web/templates/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ spec:
168168
- name: http
169169
containerPort: {{ .Values.container.port }}
170170
protocol: TCP
171+
{{- if and .Values.metricsScraping.enabled (ne .Values.metricsScraping.port .Values.container.port) }}
172+
# if metrics scraping is enabled and the port is not the same as the container port, add a metrics port
173+
- name: metrics
174+
containerPort: {{ .Values.metricsScraping.port }}
175+
protocol: TCP
176+
{{- end }}
171177
{{- range .Values.container.extraPorts }}
172178
- name: {{ .name }}
173179
containerPort: {{ .containerPort }}

applications/web/templates/service.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ metadata:
88
{{- if .Values.labels }}
99
{{- toYaml .Values.labels | nindent 4 }}
1010
{{- end }}
11-
{{- if .Values.service.annotations }}
12-
{{- if gt (len .Values.service.annotations) 0}}
11+
{{- if or .Values.metricsScraping.enabled (and .Values.service.annotations (gt (len .Values.service.annotations) 0)) }}
1312
annotations:
13+
{{- if .Values.metricsScraping.enabled }}
14+
porter.prometheus/scrape: "true"
15+
porter.prometheus/port: {{ .Values.metricsScraping.port | quote }}
16+
porter.prometheus/path: {{ .Values.metricsScraping.path | quote }}
17+
porter.prometheus/scheme: "http"
18+
{{- end }}
19+
{{- if and .Values.service.annotations (gt (len .Values.service.annotations) 0) }}
1420
{{- range $k, $v := .Values.service.annotations }}
1521
{{ $k }}: {{ $v | quote }}
1622
{{- end }}
17-
{{- end }}
23+
{{- end }}
1824
{{- end }}
1925
spec:
2026
{{ if or .Values.ingress.enabled .Values.albIngress.enabled .Values.customNodePort.enabled }}
@@ -32,6 +38,13 @@ spec:
3238
{{- else if .Values.customNodePort.enabled }}
3339
nodePort: {{ .Values.customNodePort.port }}
3440
{{- end }}
41+
{{- if and .Values.metricsScraping.enabled (ne .Values.metricsScraping.port .Values.service.port) }}
42+
# add metrics scraping port if metrics scraping is enabled and the port is not the same as the service port
43+
- port: {{ .Values.metricsScraping.port }}
44+
targetPort: metrics
45+
protocol: TCP
46+
name: metrics
47+
{{- end }}
3548
{{- range .Values.service.extraPorts }}
3649
- port: {{ .port }}
3750
targetPort: {{ .targetPort }}

applications/web/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,9 @@ fileSecretMounts:
304304
mounts: []
305305

306306
nodeGroups: []
307+
308+
309+
metricsScraping:
310+
enabled: false
311+
port: 80
312+
path: "/metrics"

0 commit comments

Comments
 (0)