File tree Expand file tree Collapse file tree 4 files changed +34
-3
lines changed
Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 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 }}
Original file line number Diff line number Diff 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 }}
Original file line number Diff line number Diff 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 }}
1925spec :
2026 {{ if or .Values.ingress.enabled .Values.albIngress.enabled .Values.customNodePort.enabled }}
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 }}
Original file line number Diff line number Diff line change @@ -304,3 +304,9 @@ fileSecretMounts:
304304 mounts : []
305305
306306nodeGroups : []
307+
308+
309+ metricsScraping :
310+ enabled : false
311+ port : 80
312+ path : " /metrics"
You can’t perform that action at this time.
0 commit comments