mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
feat(chart): render extraManifests and serviceMonitor (#1348)
Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com> Co-authored-by: Dawn (sprout agent) <c6237ef84fa537c78dcee78efd2d4e59f728859c7f194da42ac51ededfa0be05@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
co-authored by
Dawn
npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d
parent
e567491a19
commit
dc612c9af6
@@ -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 }}
|
||||
@@ -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 -}}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user