From f3f6208efb40438b6314c0569e046faff339051d Mon Sep 17 00:00:00 2001 From: Dwight Donovan Benvenuto <0x46616c6b@users.noreply.github.com> Date: Wed, 5 May 2021 23:43:38 +0200 Subject: [PATCH] feat(jvb): add option to enable prometheus metrics sidecar for jvb (#6) * add option to enable metrics sidecar for jvb * bump chart version * remove targetPort for metrics-service * enable service for metrics only when metrics enabled * add readinessProbe to metrics container --- Chart.yaml | 2 +- README.md | 8 ++++++++ templates/jvb/configmap.yaml | 3 +++ templates/jvb/deployment.yaml | 24 ++++++++++++++++++++++++ templates/jvb/metrics-prometheus.yaml | 23 +++++++++++++++++++++++ templates/jvb/metrics-service.yaml | 16 ++++++++++++++++ values.yaml | 19 +++++++++++++++++++ 7 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 templates/jvb/metrics-prometheus.yaml create mode 100644 templates/jvb/metrics-service.yaml diff --git a/Chart.yaml b/Chart.yaml index 3d9f194..105e79f 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -14,7 +14,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 0.1.2 +version: 0.1.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. diff --git a/README.md b/README.md index e12c09d..3ad570a 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,14 @@ Parameter | Description | Default `jvb.xmpp.password` | Password used by jvb to authenticate on the XMPP service | 10 random chars `jvb.livenessProbe` | Map that holds the liveness probe, you can add parameters such as timeout or retries following the Kubernetes spec | A livenessProbe map `jvb.readinessProbe` | Map that holds the liveness probe, you can add parameters such as timeout or retries following the Kubernetes spec | A readinessProbe map +`jvb.metrics.enabled` | Boolean that control the metrics exporter for jvb. If true the `ServiceMonitor` will also created | `false` +`jvb.metrics.image.repository` | Default image repository for metrics exporter | `docker.io/systemli/prometheus-jitsi-meet-exporter` +`jvb.metrics.image.tag` | Default tag for metrics exporter | `1.1.5` +`jvb.metrics.image.pullPolicy` | ImagePullPolicy for metrics exporter | `IfNotPresent` +`jvb.metrics.serviceMonitor.enabled` | `ServiceMonitor` for Prometheus | `true` +`jvb.metrics.serviceMonitor.selector` | Selector for `ServiceMonitor` | `{ release: prometheus-operator }` +`jvb.metrics.serviceMonitor.interval` | Interval for `ServiceMonitor` | `10s` +`jvb.metrics.resources` | Resources for the metrics container | `{ requests: { cpu: 10m, memory: 16Mi }, limits: { cpu: 20m, memory: 32Mi } }` `web.httpsEnabled` | Boolean that enabled tls-termination on the web pods. Useful if you expose the UI via a `Loadbalancer` IP instead of an ingress | `false` `web.httpRedirect` | Boolean that enabled http-to-https redirection. Useful for ingress that don't support this feature (ex: GKE ingress) | `false` `web.extraEnvs` | Map containing additional environment variable to web pods | '{}' diff --git a/templates/jvb/configmap.yaml b/templates/jvb/configmap.yaml index 733a8ee..387da07 100644 --- a/templates/jvb/configmap.yaml +++ b/templates/jvb/configmap.yaml @@ -20,3 +20,6 @@ data: {{ $key }}: {{ tpl $value $ | quote }} {{- end }} {{- end }} + {{- if .Values.jvb.metrics.enabled }} + JVB_ENABLE_APIS: 'rest,colibri' + {{- end }} diff --git a/templates/jvb/deployment.yaml b/templates/jvb/deployment.yaml index 3d79951..5c16670 100644 --- a/templates/jvb/deployment.yaml +++ b/templates/jvb/deployment.yaml @@ -80,6 +80,30 @@ spec: resources: {{- toYaml .Values.jvb.resources | nindent 12 }} + {{- if .Values.jvb.metrics.enabled }} + - name: metrics + image: {{ .Values.jvb.metrics.image.repository }}:{{ .Values.jvb.metrics.image.tag }} + imagePullPolicy: {{ .Values.jvb.metrics.image.pullPolicy }} + securityContext: + runAsUser: 10001 + command: + - /prometheus-jitsi-meet-exporter + - -videobridge-url + - http://localhost:8080/colibri/stats + ports: + - containerPort: 9888 + name: metrics + protocol: TCP + readinessProbe: + httpGet: + path: /health + port: 9888 + initialDelaySeconds: 3 + periodSeconds: 5 + resources: + {{- toYaml .Values.jvb.metrics.resources | nindent 12 }} + {{- end }} + {{- with .Values.jvb.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/templates/jvb/metrics-prometheus.yaml b/templates/jvb/metrics-prometheus.yaml new file mode 100644 index 0000000..916dd3d --- /dev/null +++ b/templates/jvb/metrics-prometheus.yaml @@ -0,0 +1,23 @@ +{{- if and (.Values.jvb.metrics.enabled) (.Values.jvb.metrics.serviceMonitor.enabled) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "jitsi-meet.jvb.fullname" . }} + labels: + {{- include "jitsi-meet.jvb.labels" . | nindent 4 }} + {{- range $key, $value := .Values.jvb.metrics.serviceMonitor.selector }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + endpoints: + - port: metrics + {{- if .Values.jvb.metrics.serviceMonitor.interval }} + interval: {{ .Values.jvb.metrics.serviceMonitor.interval }} + {{- end }} + selector: + matchLabels: + {{- include "jitsi-meet.jvb.labels" . | nindent 6 }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + {{- end -}} diff --git a/templates/jvb/metrics-service.yaml b/templates/jvb/metrics-service.yaml new file mode 100644 index 0000000..d0708b3 --- /dev/null +++ b/templates/jvb/metrics-service.yaml @@ -0,0 +1,16 @@ +{{- if .Values.jvb.metrics.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "jitsi-meet.jvb.fullname" . }}-metrics + labels: + {{- include "jitsi-meet.jvb.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 9888 + protocol: TCP + name: metrics + selector: + {{- include "jitsi-meet.jvb.selectorLabels" . | nindent 4 }} + {{- end }} diff --git a/values.yaml b/values.yaml index b6e33c6..592b110 100644 --- a/values.yaml +++ b/values.yaml @@ -157,6 +157,25 @@ jvb: affinity: {} extraEnvs: {} + metrics: + enabled: false + image: + repository: docker.io/systemli/prometheus-jitsi-meet-exporter + tag: 1.1.6 + pullPolicy: IfNotPresent + serviceMonitor: + enabled: true + selector: + release: prometheus-operator + interval: 10s + resources: + requests: + cpu: 10m + memory: 16Mi + limits: + cpu: 20m + memory: 32Mi + serviceAccount: # Specifies whether a service account should be created create: true