From d1fefb52388aeffdbe287d10f612a44389cd7779 Mon Sep 17 00:00:00 2001 From: WrenIX Date: Tue, 20 Feb 2024 23:43:46 +0100 Subject: [PATCH] fix(matrix-sliding-sync): init --- docs/modules/charts/nav.adoc | 1 + .../charts/pages/matrix-sliding-sync.adoc | 1 + matrix-sliding-sync/.helmignore | 23 + matrix-sliding-sync/Chart.yaml | 12 + matrix-sliding-sync/README.adoc | 639 ++++++++++++++++++ matrix-sliding-sync/templates/NOTES.txt | 22 + matrix-sliding-sync/templates/_helpers.tpl | 62 ++ matrix-sliding-sync/templates/deployment.yaml | 79 +++ matrix-sliding-sync/templates/hpa.yaml | 32 + matrix-sliding-sync/templates/ingress.yaml | 61 ++ matrix-sliding-sync/templates/secrets.yaml | 31 + matrix-sliding-sync/templates/service.yaml | 21 + .../templates/serviceaccount.yaml | 13 + .../templates/servicemonitor.yaml | 18 + .../templates/tests/test-connection.yaml | 15 + matrix-sliding-sync/values.yaml | 129 ++++ publish.sh | 2 +- 17 files changed, 1160 insertions(+), 1 deletion(-) create mode 120000 docs/modules/charts/pages/matrix-sliding-sync.adoc create mode 100644 matrix-sliding-sync/.helmignore create mode 100644 matrix-sliding-sync/Chart.yaml create mode 100644 matrix-sliding-sync/README.adoc create mode 100644 matrix-sliding-sync/templates/NOTES.txt create mode 100644 matrix-sliding-sync/templates/_helpers.tpl create mode 100644 matrix-sliding-sync/templates/deployment.yaml create mode 100644 matrix-sliding-sync/templates/hpa.yaml create mode 100644 matrix-sliding-sync/templates/ingress.yaml create mode 100644 matrix-sliding-sync/templates/secrets.yaml create mode 100644 matrix-sliding-sync/templates/service.yaml create mode 100644 matrix-sliding-sync/templates/serviceaccount.yaml create mode 100644 matrix-sliding-sync/templates/servicemonitor.yaml create mode 100644 matrix-sliding-sync/templates/tests/test-connection.yaml create mode 100644 matrix-sliding-sync/values.yaml diff --git a/docs/modules/charts/nav.adoc b/docs/modules/charts/nav.adoc index 0d3faa0..9fd46e8 100644 --- a/docs/modules/charts/nav.adoc +++ b/docs/modules/charts/nav.adoc @@ -10,6 +10,7 @@ ** xref:headscale-ui.adoc[headscale-ui] ** xref:hydrogen-web.adoc[hydrogen-web] ** xref:jellyfin.adoc[jellyfin] +** xref:matrix-sliding-sync.adoc[matrix-sliding-sync] ** xref:matrix-synapse.adoc[matrix-synapse] ** xref:mautrix-signal.adoc[mautrix-signal] ** xref:miniserve.adoc[miniserve] diff --git a/docs/modules/charts/pages/matrix-sliding-sync.adoc b/docs/modules/charts/pages/matrix-sliding-sync.adoc new file mode 120000 index 0000000..abf59a4 --- /dev/null +++ b/docs/modules/charts/pages/matrix-sliding-sync.adoc @@ -0,0 +1 @@ +../../../../matrix-sliding-sync/README.adoc \ No newline at end of file diff --git a/matrix-sliding-sync/.helmignore b/matrix-sliding-sync/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/matrix-sliding-sync/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/matrix-sliding-sync/Chart.yaml b/matrix-sliding-sync/Chart.yaml new file mode 100644 index 0000000..4df9597 --- /dev/null +++ b/matrix-sliding-sync/Chart.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: v2 +name: matrix-sliding-sync +description: Proxy implementation of MSC3575's sync protocol. +icon: https://matrix.org/images/matrix-logo.svg +type: application +version: 0.1.0 +# renovate: image=ghcr.io/matrix-org/sliding-sync +appVersion: "0.99.15" +maintainers: + - name: WrenIX + url: https://wrenix.eu diff --git a/matrix-sliding-sync/README.adoc b/matrix-sliding-sync/README.adoc new file mode 100644 index 0000000..59b15c9 --- /dev/null +++ b/matrix-sliding-sync/README.adoc @@ -0,0 +1,639 @@ + + += matrix-sliding-sync + +image::https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square[Version: 0.1.0] +image::https://img.shields.io/badge/Version-application-informational?style=flat-square[Type: application] +image::https://img.shields.io/badge/AppVersion-0.99.15-informational?style=flat-square[AppVersion: 0.99.15] +== Maintainers + +.Maintainers +|=== +| Name | Email | Url + +| WrenIX +| +| +|=== + +== Usage + +Helm must be installed and setup to your kubernetes cluster to use the charts. +Refer to Helm's https://helm.sh/docs[documentation] to get started. +Once Helm has been set up correctly, fetch the charts as follows: + +[source,bash] +---- +helm pull oci://codeberg.org/wrenix/helm-charts/matrix-sliding-sync +---- + +You can install a chart release using the following command: + +[source,bash] +---- +helm install matrix-sliding-sync-release oci://codeberg.org/wrenix/helm-charts/matrix-sliding-sync --values values.yaml +---- + +To uninstall a chart release use `helm`'s delete command: + +[source,bash] +---- +helm uninstall matrix-sliding-sync-release +---- + +== Values + +.Values +|=== +| Key | Type | Default | Description + +| affinity +| object +| `{}` +| + +| autoscaling.enabled +| bool +| `false` +| + +| autoscaling.maxReplicas +| int +| `100` +| + +| autoscaling.minReplicas +| int +| `1` +| + +| autoscaling.targetCPUUtilizationPercentage +| int +| `80` +| + +| config.homeserver +| string +| `"http://localhost:8008"` +| + +| config.metrics +| int +| `9100` +| + +| config.postgresql.database +| string +| `"sliding_sync"` +| + +| config.postgresql.host +| string +| `"localhost"` +| + +| config.postgresql.maxConn +| int +| `0` +| + +| config.postgresql.password +| string +| `"secret"` +| + +| config.postgresql.port +| int +| `5432` +| + +| config.postgresql.sslmode +| string +| `"disable"` +| + +| config.postgresql.username +| string +| `"sliding_sync"` +| + +| config.syncSecret +| string +| `nil` +| + +| fullnameOverride +| string +| `""` +| + +| global.image.pullPolicy +| string +| `nil` +| if set it will overwrite all pullPolicy + +| global.image.registry +| string +| `nil` +| if set it will overwrite all registry entries + +| image.pullPolicy +| string +| `"IfNotPresent"` +| + +| image.registry +| string +| `"ghcr.io"` +| + +| image.repository +| string +| `"matrix-org/sliding-sync"` +| + +| image.tag +| string +| `nil` +| Overrides the image tag whose default is the chart appVersion. + +| imagePullSecrets +| list +| `[]` +| + +| ingress.annotations +| object +| `{}` +| + +| ingress.className +| string +| `""` +| + +| ingress.enabled +| bool +| `false` +| + +| ingress.hosts[0].host +| string +| `"chart-example.local"` +| + +| ingress.hosts[0].paths[0].path +| string +| `"/"` +| + +| ingress.hosts[0].paths[0].pathType +| string +| `"ImplementationSpecific"` +| + +| ingress.tls +| list +| `[]` +| + +| livenessProbe.httpGet.path +| string +| `"/"` +| + +| livenessProbe.httpGet.port +| string +| `"http"` +| + +| nameOverride +| string +| `""` +| + +| nodeSelector +| object +| `{}` +| + +| podAnnotations +| object +| `{}` +| + +| podLabels +| object +| `{}` +| + +| podSecurityContext.fsGroup +| int +| `2000` +| + +| prometheus.servicemonitor.enabled +| bool +| `false` +| + +| prometheus.servicemonitor.labels +| object +| `{}` +| + +| readinessProbe.httpGet.path +| string +| `"/"` +| + +| readinessProbe.httpGet.port +| string +| `"http"` +| + +| replicaCount +| int +| `1` +| + +| resources +| object +| `{}` +| + +| securityContext.capabilities.drop[0] +| string +| `"ALL"` +| + +| securityContext.readOnlyRootFilesystem +| bool +| `true` +| + +| securityContext.runAsNonRoot +| bool +| `true` +| + +| securityContext.runAsUser +| int +| `1000` +| + +| service.port +| int +| `8008` +| + +| service.type +| string +| `"ClusterIP"` +| + +| serviceAccount.annotations +| object +| `{}` +| + +| serviceAccount.automount +| bool +| `true` +| + +| serviceAccount.create +| bool +| `true` +| + +| serviceAccount.name +| string +| `""` +| + +| tolerations +| list +| `[]` +| + +| volumeMounts +| list +| `[]` +| + +| volumes +| list +| `[]` +| +|=== + +Autogenerated from chart metadata using https://github.com/norwoodj/helm-docs[helm-docs] += matrix-sliding-sync + +image::https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square[Version: 0.1.0] +image::https://img.shields.io/badge/Version-application-informational?style=flat-square[Type: application] +image::https://img.shields.io/badge/AppVersion-0.99.15-informational?style=flat-square[AppVersion: 0.99.15] + +Proxy implementation of MSC3575's sync protocol. + +== Maintainers + +.Maintainers +|=== +| Name | Email | Url + +| WrenIX +| +| +|=== + +== Values + +.Values +|=== +| Key | Type | Default | Description + +| affinity +| object +| `{}` +| + +| autoscaling.enabled +| bool +| `false` +| + +| autoscaling.maxReplicas +| int +| `100` +| + +| autoscaling.minReplicas +| int +| `1` +| + +| autoscaling.targetCPUUtilizationPercentage +| int +| `80` +| + +| config.homeserver +| string +| `"http://localhost:8008"` +| + +| config.metrics +| int +| `9100` +| + +| config.postgresql.database +| string +| `"sliding_sync"` +| + +| config.postgresql.host +| string +| `"localhost"` +| + +| config.postgresql.maxConn +| int +| `0` +| + +| config.postgresql.password +| string +| `"secret"` +| + +| config.postgresql.port +| int +| `5432` +| + +| config.postgresql.sslmode +| string +| `"disable"` +| + +| config.postgresql.username +| string +| `"sliding_sync"` +| + +| config.syncSecret +| string +| `nil` +| + +| fullnameOverride +| string +| `""` +| + +| global.image.pullPolicy +| string +| `nil` +| if set it will overwrite all pullPolicy + +| global.image.registry +| string +| `nil` +| if set it will overwrite all registry entries + +| image.pullPolicy +| string +| `"IfNotPresent"` +| + +| image.registry +| string +| `"ghcr.io"` +| + +| image.repository +| string +| `"matrix-org/sliding-sync"` +| + +| image.tag +| string +| `nil` +| Overrides the image tag whose default is the chart appVersion. + +| imagePullSecrets +| list +| `[]` +| + +| ingress.annotations +| object +| `{}` +| + +| ingress.className +| string +| `""` +| + +| ingress.enabled +| bool +| `false` +| + +| ingress.hosts[0].host +| string +| `"chart-example.local"` +| + +| ingress.hosts[0].paths[0].path +| string +| `"/"` +| + +| ingress.hosts[0].paths[0].pathType +| string +| `"ImplementationSpecific"` +| + +| ingress.tls +| list +| `[]` +| + +| livenessProbe.httpGet.path +| string +| `"/"` +| + +| livenessProbe.httpGet.port +| string +| `"http"` +| + +| nameOverride +| string +| `""` +| + +| nodeSelector +| object +| `{}` +| + +| podAnnotations +| object +| `{}` +| + +| podLabels +| object +| `{}` +| + +| podSecurityContext.fsGroup +| int +| `2000` +| + +| prometheus.servicemonitor.enabled +| bool +| `false` +| + +| prometheus.servicemonitor.labels +| object +| `{}` +| + +| readinessProbe.httpGet.path +| string +| `"/"` +| + +| readinessProbe.httpGet.port +| string +| `"http"` +| + +| replicaCount +| int +| `1` +| + +| resources +| object +| `{}` +| + +| securityContext.capabilities.drop[0] +| string +| `"ALL"` +| + +| securityContext.readOnlyRootFilesystem +| bool +| `true` +| + +| securityContext.runAsNonRoot +| bool +| `true` +| + +| securityContext.runAsUser +| int +| `1000` +| + +| service.port +| int +| `8008` +| + +| service.type +| string +| `"ClusterIP"` +| + +| serviceAccount.annotations +| object +| `{}` +| + +| serviceAccount.automount +| bool +| `true` +| + +| serviceAccount.create +| bool +| `true` +| + +| serviceAccount.name +| string +| `""` +| + +| tolerations +| list +| `[]` +| + +| volumeMounts +| list +| `[]` +| + +| volumes +| list +| `[]` +| +|=== + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.2](https://github.com/norwoodj/helm-docs/releases/v1.11.2) diff --git a/matrix-sliding-sync/templates/NOTES.txt b/matrix-sliding-sync/templates/NOTES.txt new file mode 100644 index 0000000..62e2871 --- /dev/null +++ b/matrix-sliding-sync/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "matrix-sliding-sync.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "matrix-sliding-sync.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "matrix-sliding-sync.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "matrix-sliding-sync.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/matrix-sliding-sync/templates/_helpers.tpl b/matrix-sliding-sync/templates/_helpers.tpl new file mode 100644 index 0000000..672a34c --- /dev/null +++ b/matrix-sliding-sync/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "matrix-sliding-sync.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "matrix-sliding-sync.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "matrix-sliding-sync.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "matrix-sliding-sync.labels" -}} +helm.sh/chart: {{ include "matrix-sliding-sync.chart" . }} +{{ include "matrix-sliding-sync.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "matrix-sliding-sync.selectorLabels" -}} +app.kubernetes.io/name: {{ include "matrix-sliding-sync.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "matrix-sliding-sync.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "matrix-sliding-sync.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/matrix-sliding-sync/templates/deployment.yaml b/matrix-sliding-sync/templates/deployment.yaml new file mode 100644 index 0000000..bd9bfa4 --- /dev/null +++ b/matrix-sliding-sync/templates/deployment.yaml @@ -0,0 +1,79 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "matrix-sliding-sync.fullname" . }} + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "matrix-sliding-sync.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "matrix-sliding-sync.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- with .Values.image }} + image: "{{ coalesce $.Values.global.image.registry .registry }}/{{ .repository }}:{{ .tag | default (printf "v%s" $.Chart.AppVersion) }}" + imagePullPolicy: {{ coalesce $.Values.global.image.pullPolicy .pullPolicy }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "matrix-sliding-sync.fullname" . }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + {{- with .Values.config.metrics }} + - name: metrics + containerPort: {{ . }} + protocol: TCP + {{- end }} + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/matrix-sliding-sync/templates/hpa.yaml b/matrix-sliding-sync/templates/hpa.yaml new file mode 100644 index 0000000..2be38cd --- /dev/null +++ b/matrix-sliding-sync/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "matrix-sliding-sync.fullname" . }} + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "matrix-sliding-sync.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/matrix-sliding-sync/templates/ingress.yaml b/matrix-sliding-sync/templates/ingress.yaml new file mode 100644 index 0000000..d707a17 --- /dev/null +++ b/matrix-sliding-sync/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "matrix-sliding-sync.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/matrix-sliding-sync/templates/secrets.yaml b/matrix-sliding-sync/templates/secrets.yaml new file mode 100644 index 0000000..43b2e59 --- /dev/null +++ b/matrix-sliding-sync/templates/secrets.yaml @@ -0,0 +1,31 @@ +{{- $secretName := include "matrix-sliding-sync.fullname" . }} +{{- $secret := (lookup "v1" "Secret" .Release.Namespace $secretName) }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ $secretName }} + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 4 }} +data: + SYNCV3_SERVER: {{ .Values.config.homeserver | b64enc }} + {{- with .Values.config.postgresql }} + SYNCV3_DB: {{ (printf "postgresql://%s:%s@%s:%v/%s?sslmode=%s" + .username + .password + .host + .port + .database + .sslmode + ) | b64enc }} + {{- end }} + SYNCV3_SECRET: {{ .Values.config.syncSecret + | default (dig "data" "SYNCV3_SECRET" "" $secret | b64dec) + | default (randAlphaNum 64) + | b64enc + }} + SYNCV3_BINDADDR: {{ printf ":%v" .Values.service.port | b64enc }} + {{- with .Values.config.metrics }} + SYNCV3_PROM: {{ printf ":%v" . | b64enc }} + {{- end }} + SYNCV3_LOG_LEVEL: {{ .Values.config.logLevel | b64enc }} + SYNCV3_MAX_DB_CONN: {{ toString .Values.config.postgresql.maxConn | b64enc }} diff --git a/matrix-sliding-sync/templates/service.yaml b/matrix-sliding-sync/templates/service.yaml new file mode 100644 index 0000000..62d6040 --- /dev/null +++ b/matrix-sliding-sync/templates/service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "matrix-sliding-sync.fullname" . }} + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - name: http + protocol: TCP + port: {{ .Values.service.port }} + targetPort: http + {{- with .Values.config.metrics }} + - name: metrics + protocol: TCP + port: {{ . }} + targetPort: metrics + {{- end }} + selector: + {{- include "matrix-sliding-sync.selectorLabels" . | nindent 4 }} diff --git a/matrix-sliding-sync/templates/serviceaccount.yaml b/matrix-sliding-sync/templates/serviceaccount.yaml new file mode 100644 index 0000000..b47cf33 --- /dev/null +++ b/matrix-sliding-sync/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "matrix-sliding-sync.serviceAccountName" . }} + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/matrix-sliding-sync/templates/servicemonitor.yaml b/matrix-sliding-sync/templates/servicemonitor.yaml new file mode 100644 index 0000000..57d2e4e --- /dev/null +++ b/matrix-sliding-sync/templates/servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if .Values.prometheus.servicemonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "matrix-sliding-sync.fullname" . }} + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 4 }} + {{- with .Values.prometheus.servicemonitor.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + path: "/metrics" + selector: + matchLabels: + {{- include "matrix-sliding-sync.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/matrix-sliding-sync/templates/tests/test-connection.yaml b/matrix-sliding-sync/templates/tests/test-connection.yaml new file mode 100644 index 0000000..78ac09f --- /dev/null +++ b/matrix-sliding-sync/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "matrix-sliding-sync.fullname" . }}-test-connection" + labels: + {{- include "matrix-sliding-sync.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "matrix-sliding-sync.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/matrix-sliding-sync/values.yaml b/matrix-sliding-sync/values.yaml new file mode 100644 index 0000000..ecb4e08 --- /dev/null +++ b/matrix-sliding-sync/values.yaml @@ -0,0 +1,129 @@ +--- +global: + image: + # -- if set it will overwrite all registry entries + registry: + # -- if set it will overwrite all pullPolicy + pullPolicy: + +image: + registry: ghcr.io + repository: matrix-org/sliding-sync + pullPolicy: IfNotPresent + # -- Overrides the image tag whose default is the chart appVersion. + tag: + +replicaCount: 1 + +config: + homeserver: http://localhost:8008 + syncSecret: + postgresql: + host: localhost + port: 5432 + database: sliding_sync + username: sliding_sync + password: secret + sslmode: disable + maxConn: 0 + metrics: 9100 + logLevel: INFO + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +prometheus: + servicemonitor: + enabled: false + labels: {} + +podAnnotations: {} +podLabels: {} + +podSecurityContext: + fsGroup: 2000 + +securityContext: + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + +service: + type: ClusterIP + port: 8008 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +livenessProbe: + tcpSocket: + port: http +readinessProbe: + tcpSocket: + port: http + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/publish.sh b/publish.sh index fcf2aaf..103bf05 100755 --- a/publish.sh +++ b/publish.sh @@ -53,7 +53,7 @@ for p in * ; do helm package "${p}" helm push "${p}-${v}.tgz" "${HELM_REPO}"; - git add "${p}/" + git add "${p}/" "docs/modules/charts/nav.adoc" "docs/modules/charts/pages/${p}.adoc" git commit -m "${COMMIT_SCOPE}(${p}): ${COMMIT_MESSAGE}" git tag "${tag}" --no-sign; git push --tags origin main;