From 81d76a9005ad94f6b92d9e8211eff897e49aa502 Mon Sep 17 00:00:00 2001 From: WrenIX <133280015+wrenix@users.noreply.github.com> Date: Fri, 27 Oct 2023 00:10:46 +0200 Subject: [PATCH 1/3] feat: update image, cleaning code --- Chart.yaml | 6 ++-- templates/deployment.yaml | 75 ++++++++++++++++++++------------------- values.yaml | 12 ++++--- 3 files changed, 50 insertions(+), 43 deletions(-) diff --git a/Chart.yaml b/Chart.yaml index 0b6cce6..f0a6045 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 -appVersion: latest +appVersion: 0.4.3 description: A Matrix-Signal puppeting bridge. name: mautrix-signal -version: 0.2.0 +version: 0.2.1 type: application keywords: - synapse @@ -21,6 +21,6 @@ annotations: artifacthub.io/containsSecurityUpdates: 'false' artifacthub.io/images: | - name: mautrix-signal - image: "dock.mau.dev/mautrix/signal:latest" + image: "dock.mau.dev/mautrix/signal:v0.4.3" - name: signald image: "signald/signald:0.23.2" diff --git a/templates/deployment.yaml b/templates/deployment.yaml index bd21dc7..e7a1c7a 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -5,23 +5,21 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "mautrix-signal.fullname" . }} - {{- if .Values.deploymentAnnotations }} + {{- with .Values.deploymentAnnotations }} annotations: - {{- range $key, $value := .Values.deploymentAnnotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} + {{- toYaml . | nindent 4 }} {{- end }} labels: -{{ include "mautrix-signal.labels" . | indent 4 }} + {{- include "mautrix-signal.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} -{{- if .Values.strategy }} + {{- if .Values.strategy }} strategy: -{{ toYaml .Values.strategy | indent 4 }} -{{ if eq .Values.strategy.type "Recreate" }} + {{- toYaml .Values.strategy | nindent 4 }} + {{- if eq .Values.strategy.type "Recreate" }} rollingUpdate: null -{{- end }} -{{- end }} + {{- end }} + {{- end }} selector: matchLabels: {{- include "mautrix-signal.selectorLabels" . | nindent 6 }} @@ -29,27 +27,28 @@ spec: metadata: labels: {{- include "mautrix-signal.selectorLabels" . | nindent 8 }} - {{- if $podAnnotations }} - annotations: - {{- range $key, $value := $podAnnotations }} - {{ $key }}: {{ $value | quote }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} {{- end }} + {{- with $podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} {{- end }} spec: - {{- with .Values.imagePullSecrets }} + {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} serviceAccountName: {{ template "mautrix-signal.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} - {{- if .Values.dnsConfig }} + {{- with .Values.dnsConfig }} dnsConfig: - {{- toYaml .Values.dnsConfig | nindent 8 }} + {{- toYaml . | nindent 8 }} {{- end }} initContainers: - name: init - image: "{{ .Values.image.mautrixSignal.repository }}:{{ tpl .Values.image.mautrixSignal.tag . }}" + image: "{{ .Values.image.mautrixSignal.registry }}/{{ .Values.image.mautrixSignal.repository }}:{{ .Values.image.mautrixSignal.tag | default (printf "v%s" .Chart.AppVersion) }}" imagePullPolicy: {{ .Values.image.mautrixSignal.pullPolicy }} command: ["/bin/sh"] args: @@ -73,35 +72,39 @@ spec: - name: mautrix-signal securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.mautrixSignal.repository }}:{{ tpl .Values.image.mautrixSignal.tag . }}" + image: "{{ .Values.image.mautrixSignal.registry }}/{{ .Values.image.mautrixSignal.repository }}:{{ .Values.image.mautrixSignal.tag | default (printf "v%s" .Chart.AppVersion) }}" imagePullPolicy: {{ .Values.image.mautrixSignal.pullPolicy }} ports: - name: http containerPort: {{ required "need config.appservice.port" .Values.config.appservice.port }} protocol: TCP - env: - [] + {{- with .Values.probes.liveness }} livenessProbe: httpGet: path: /_matrix/mau/live port: http - failureThreshold: {{ .Values.probes.liveness.failureThreshold }} - periodSeconds: {{ .Values.probes.liveness.periodSeconds }} + failureThreshold: {{ .failureThreshold }} + periodSeconds: {{ .periodSeconds }} + {{- end }} + {{- with .Values.probes.readiness }} readinessProbe: httpGet: path: /_matrix/mau/live port: http - failureThreshold: {{ .Values.probes.readiness.failureThreshold }} - periodSeconds: {{ .Values.probes.readiness.periodSeconds }} -{{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} + failureThreshold: {{ .failureThreshold }} + periodSeconds: {{ .periodSeconds }} + {{- end }} + {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} + {{- with .Values.probes.startup }} startupProbe: httpGet: path: /_matrix/mau/live port: http - initialDelaySeconds: {{ .Values.probes.startup.initialDelaySeconds }} - failureThreshold: {{ .Values.probes.startup.failureThreshold }} - periodSeconds: {{ .Values.probes.startup.periodSeconds }} -{{- end }} + initialDelaySeconds: {{ .initialDelaySeconds }} + failureThreshold: {{ .failureThreshold }} + periodSeconds: {{ .periodSeconds }} + {{- end }} + {{- end }} volumeMounts: - name: config mountPath: /config @@ -114,7 +117,7 @@ spec: - name: signald securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.signald.repository }}:{{ tpl .Values.image.signald.tag . }}" + image: "{{ .Values.image.signald.registry }}/{{ .Values.image.signald.repository }}:{{ .Values.image.signald.tag }}" imagePullPolicy: {{ .Values.image.signald.pullPolicy }} args: # user socket @@ -155,11 +158,11 @@ spec: nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.affinity }} + {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} + {{- end }} + {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} diff --git a/values.yaml b/values.yaml index 4b3fe6e..b6d52a6 100644 --- a/values.yaml +++ b/values.yaml @@ -6,12 +6,15 @@ replicaCount: 1 image: mautrixSignal: - repository: dock.mau.dev/mautrix/signal - tag: "{{ .Chart.AppVersion }}" - pullPolicy: Always + registry: dock.mau.dev + repository: mautrix/signal + # Overrides the image tag whose default is the chart appVersion. + tag: "" + pullPolicy: IfNotPresent signald: + registry: docker.io repository: signald/signald - tag: 0.23.0 + tag: 0.23.2 pullPolicy: IfNotPresent imagePullSecrets: [] @@ -388,6 +391,7 @@ tolerations: [] affinity: {} podAnnotations: {} +podLabels: {} deploymentAnnotations: {} From 1178844cfaeecb5f58700b44f589a48eb1be82ee Mon Sep 17 00:00:00 2001 From: WrenIX Date: Fri, 27 Oct 2023 00:36:38 +0200 Subject: [PATCH 2/3] feat(metrics): forward port --- Chart.yaml | 2 +- templates/deployment.yaml | 5 +++++ templates/service.yaml | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Chart.yaml b/Chart.yaml index f0a6045..a523711 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: 0.4.3 description: A Matrix-Signal puppeting bridge. name: mautrix-signal -version: 0.2.1 +version: 0.3.0 type: application keywords: - synapse diff --git a/templates/deployment.yaml b/templates/deployment.yaml index e7a1c7a..ef6fb0f 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -78,6 +78,11 @@ spec: - name: http containerPort: {{ required "need config.appservice.port" .Values.config.appservice.port }} protocol: TCP + {{- if .Values.config.metrics.enabled }} + - name: metrics + containerPort: {{ .Values.config.metrics.listen_port }} + protocol: TCP + {{- end }} {{- with .Values.probes.liveness }} livenessProbe: httpGet: diff --git a/templates/service.yaml b/templates/service.yaml index 8b052f8..d332467 100644 --- a/templates/service.yaml +++ b/templates/service.yaml @@ -14,6 +14,12 @@ spec: targetPort: http protocol: TCP name: http + {{- if .Values.config.metrics.enabled }} + - port: {{ .Values.config.metrics.listen_port }} + targetPort: metrics + protocol: TCP + name: metrics + {{- end }} selector: {{- include "mautrix-signal.selectorLabels" . | nindent 4 }} {{- end }} From dd1e35822f5859e385455a40d020f3990b2bf7a4 Mon Sep 17 00:00:00 2001 From: WrenIX Date: Fri, 27 Oct 2023 00:47:16 +0200 Subject: [PATCH 3/3] feat(metrics): add servicemonitor --- templates/servicemonitor.yaml | 18 ++++++++++++++++++ values.yaml | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 templates/servicemonitor.yaml diff --git a/templates/servicemonitor.yaml b/templates/servicemonitor.yaml new file mode 100644 index 0000000..a7c78f8 --- /dev/null +++ b/templates/servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if and .Values.prometheus.servicemonitor.enabled ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "mautrix-signal.fullname" . }} + labels: + {{- include "mautrix-signal.labels" . | nindent 4 }} + {{- with .Values.prometheus.servicemonitor.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + path: /metrics + selector: + matchLabels: + {{- include "mautrix-signal.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/values.yaml b/values.yaml index b6d52a6..00dea27 100644 --- a/values.yaml +++ b/values.yaml @@ -412,3 +412,8 @@ persistence: size: 1Gi ## persistence.skipuninstall -- Do not delete the pvc upon helm uninstall skipuninstall: false + +prometheus: + servicemonitor: + enabled: false + labels: {}