Skip to content

Commit

Permalink
feat(chart): add a pod monitor to scrape metrics (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
JossWhittle authored Dec 18, 2023
1 parent 0035ede commit 54a5ed0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion charts/canary/templates/controller/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ spec:
{{- include "canary.image" (dict "image" .Values.controller.image) | indent 10 }}

ports:
- containerPort: 8080
- name: http-metrics
containerPort: 8080

envFrom:
{{- include "canary.envFrom" (dict "Release" .Release "Values" .Values "extraEnv" .Values.controller.extraEnvFrom) | indent 12 }}
Expand Down
3 changes: 2 additions & 1 deletion charts/canary/templates/controller/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ spec:
{{- include "canary.image" (dict "image" .Values.controller.image) | indent 10 }}

ports:
- containerPort: 8080
- name: http-metrics
containerPort: 8080

envFrom:
{{ include "canary.envFrom" (dict "extraEnv" .Values.controller.extraEnvFrom) | indent 12 }}
Expand Down
36 changes: 36 additions & 0 deletions charts/canary/templates/prometheus/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "canary.fullname" . }}-podmonitor
namespace: {{ .Release.Namespace }}

labels:
app: {{ include "canary.labels.app" . }}
component: podmonitor
chart: {{ include "canary.labels.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- range $key, $value := .Values.podMonitor.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
annotations:
{{- range $key, $value := .Values.podMonitor.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}

spec:
jobLabel: {{ include "canary.fullname" . }}
podMetricsEndpoints:
- interval: {{ .Values.podMonitor.interval }}
path: /metrics
port: http-metrics
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ include "canary.labels.app" . }}
component: controller
chart: {{ include "canary.labels.chart" . }}
{{- end }}
9 changes: 9 additions & 0 deletions charts/canary/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
crds:
enabled: true

podMonitor:
enabled: true

labels: {}
annotations: {}

interval: 30s


controller:
enabled: true

Expand Down

0 comments on commit 54a5ed0

Please sign in to comment.