Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions deploy/charts/buzz/templates/extramanifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- /*
Free-form extra manifests. Each entry in .Values.extraManifests is rendered
through `tpl` (so entries may reference release values / helpers) and emitted
as its own document. Lets operators ship companion objects (e.g. Istio mesh
glue, NetworkPolicies) alongside the relay without forking the chart.
*/ -}}
{{- range .Values.extraManifests }}
---
{{ tpl (toYaml .) $ }}
{{- end }}
31 changes: 31 additions & 0 deletions deploy/charts/buzz/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- /*
Prometheus Operator ServiceMonitor for the relay's /metrics endpoint.
Opt-in (serviceMonitor.enabled). Selects the relay Service by the chart's
selector labels (which the Service carries in its own metadata.labels) and
scrapes the named `metrics` port.
*/ -}}
{{- if .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "buzz.fullname" . }}
{{- with .Values.serviceMonitor.namespace }}
namespace: {{ . | quote }}
{{- end }}
labels:
{{- include "buzz.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "buzz.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
interval: {{ .Values.serviceMonitor.interval | quote }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end -}}
70 changes: 70 additions & 0 deletions deploy/charts/buzz/tests/extras_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
suite: extraManifests + serviceMonitor renderers
templates:
- templates/extramanifests.yaml
- templates/servicemonitor.yaml
set:
relayUrl: wss://buzz.example.com
ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000"
externalPostgresql.url: postgres://u:p@h:5432/d
externalRedis.url: redis://h:6379
s3.endpoint: http://minio:9000
s3.accessKey: a
s3.secretKey: s
tests:
- it: emits nothing by default (extraManifests empty)
template: templates/extramanifests.yaml
asserts:
- hasDocuments:
count: 0

- it: renders each extraManifests entry, tpl-resolving release values
template: templates/extramanifests.yaml
set:
extraManifests:
- apiVersion: v1
kind: ConfigMap
metadata:
name: '{{ include "buzz.fullname" . }}-extra'
data:
host: '{{ .Values.relayUrl }}'
asserts:
- hasDocuments:
count: 1
- equal:
path: kind
value: ConfigMap
- equal:
path: metadata.name
value: RELEASE-NAME-buzz-extra
- equal:
path: data.host
value: wss://buzz.example.com

- it: omits the ServiceMonitor unless enabled
template: templates/servicemonitor.yaml
asserts:
- hasDocuments:
count: 0

- it: renders a ServiceMonitor scraping the metrics port when enabled
template: templates/servicemonitor.yaml
set:
serviceMonitor.enabled: true
serviceMonitor.labels.release: kube-prometheus-stack
asserts:
- hasDocuments:
count: 1
- equal:
path: kind
value: ServiceMonitor
- equal:
path: spec.endpoints[0].port
value: metrics
- equal:
path: spec.selector.matchLabels["app.kubernetes.io/name"]
value: buzz
- notExists:
path: spec.selector.matchLabels["app.kubernetes.io/component"]
- equal:
path: metadata.labels.release
value: kube-prometheus-stack
Loading