Skip to content

Commit

Permalink
Merge pull request #124 from MediaMarktSaturn/application/add-pod-mon…
Browse files Browse the repository at this point in the history
…itor-and-refine-additionalports

[Application] Add PodMonitor support and refine additional ports accordingly
  • Loading branch information
heubeck committed Jul 5, 2024
2 parents 79fa11e + 848d529 commit 293f179
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ spec:
- name: grpc
protocol: TCP
containerPort: 8082
servicePort: 82
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ linkerd:
enabled: false

monitoring:
serviceMonitor: true
podMonitor: true
namespace: monitoring

canary:
Expand Down
2 changes: 1 addition & 1 deletion charts/application/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ maintainers:
- name: MediaMarktSaturn
url: https://github.com/MediaMarktSaturn
appVersion: 1.0.0
version: 1.15.0
version: 1.16.0
2 changes: 2 additions & 0 deletions charts/application/templates/k8s-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ spec:
protocol: TCP
name: http
{{- range $ap := .Values.additionalPorts }}
{{- if $ap.servicePort }}
- port: {{ $ap.servicePort }}
targetPort: {{ $ap.containerPort }}
protocol: {{ $ap.protocol }}
name: {{ $ap.name }}
{{- end }}
{{- end }}

selector:
{{- include "selectorLabels" . | nindent 4 }}
Expand Down
31 changes: 31 additions & 0 deletions charts/application/templates/prometheus-pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.monitoring.podMonitor }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ .Release.Name }}
namespace: {{ .Values.monitoring.namespace }}
labels:
{{- include "labels" . | nindent 4 }}
spec:
jobLabel: {{ .Release.Name }}
selector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
{{- if .Values.canary.enabled }}
- "{{- printf "%s-primary" .Release.Name -}}"
- "{{- printf "%s-canary" .Release.Name -}}"
{{ else }}
- "{{ .Release.Name }}"
{{ end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
podMetricsEndpoints:
- port: {{ .Values.monitoring.metricsPortName | quote }}
path: {{ .Values.monitoring.metricsPath | quote }}
interval: {{ .Values.monitoring.scrapeInterval | quote }}
scrapeTimeout: {{ .Values.monitoring.scrapeTimeout | quote }}
followRedirects: {{ .Values.monitoring.followRedirects }}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
matchNames:
- {{ .Release.Namespace }}
endpoints:
- port: http
- port: {{ .Values.monitoring.metricsPortName | quote }}
path: {{ .Values.monitoring.metricsPath | quote }}
interval: {{ .Values.monitoring.scrapeInterval | quote }}
scrapeTimeout: {{ .Values.monitoring.scrapeTimeout | quote }}
Expand Down
4 changes: 4 additions & 0 deletions charts/application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ gatewayApi:

monitoring:
serviceMonitor: false
# choose podMonitor, if serviceMonitor is not possible because of e.g. a not exposed pod port exposing metrics
podMonitor: false
namespace: monitoring
metricsPath: /metrics
metricsPortName: http
scrapeInterval: 30s
scrapeTimeout: 10s
followRedirects: true
Expand Down Expand Up @@ -272,6 +275,7 @@ additionalPorts: []
# - name: grpc
# protocol: TCP
# containerPort: 8081
# # omit servicePort to only add it to the pod
# servicePort: 81

# additional /etc/hosts entries, either a list, or a single hostname
Expand Down

0 comments on commit 293f179

Please sign in to comment.