From ce0984c447bf2608dbb1974bc43c7dec5d539fc6 Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 19 Jan 2024 17:34:21 +0100 Subject: [PATCH] feat Add sliding-sync-proxy chart files --- charts/sliding-sync-proxy/Chart.yaml | 21 ++++++ .../sliding-sync-proxy/templates/_helpers.tpl | 51 ++++++++++++++ .../sliding-sync-proxy/templates/db-init.yaml | 20 ++++++ .../templates/deployment.yaml | 67 +++++++++++++++++++ charts/sliding-sync-proxy/templates/hpa.yaml | 29 ++++++++ .../sliding-sync-proxy/templates/service.yaml | 16 +++++ charts/sliding-sync-proxy/values.yaml | 63 +++++++++++++++++ 7 files changed, 267 insertions(+) create mode 100644 charts/sliding-sync-proxy/Chart.yaml create mode 100644 charts/sliding-sync-proxy/templates/_helpers.tpl create mode 100644 charts/sliding-sync-proxy/templates/db-init.yaml create mode 100644 charts/sliding-sync-proxy/templates/deployment.yaml create mode 100644 charts/sliding-sync-proxy/templates/hpa.yaml create mode 100644 charts/sliding-sync-proxy/templates/service.yaml create mode 100644 charts/sliding-sync-proxy/values.yaml diff --git a/charts/sliding-sync-proxy/Chart.yaml b/charts/sliding-sync-proxy/Chart.yaml new file mode 100644 index 0000000..7ad7f2c --- /dev/null +++ b/charts/sliding-sync-proxy/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: sliding-sync-proxy +description: A proxy for modern Matrix messaging clients +icon: https://avatars.githubusercontent.com/u/8418310?s=200&v=4 +appVersion: "0.99.14" + +type: application +version: 1.0.0 +maintainers: +- name: Tommy Skaug + email: tommy@skaug.me + +keywords: +- messaging +- encrypted +- matrix +- proxy +- slidingsync +- syncv3 +sources: +- https://github.com/matrix-org/sliding-sync diff --git a/charts/sliding-sync-proxy/templates/_helpers.tpl b/charts/sliding-sync-proxy/templates/_helpers.tpl new file mode 100644 index 0000000..7e889ef --- /dev/null +++ b/charts/sliding-sync-proxy/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "sliding-sync-proxy.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 "sliding-sync-proxy.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 "sliding-sync-proxy.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "sliding-sync-proxy.labels" -}} +helm.sh/chart: {{ include "sliding-sync-proxy.chart" . }} +{{ include "sliding-sync-proxy.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "sliding-sync-proxy.selectorLabels" -}} +app.kubernetes.io/name: {{ include "sliding-sync-proxy.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} \ No newline at end of file diff --git a/charts/sliding-sync-proxy/templates/db-init.yaml b/charts/sliding-sync-proxy/templates/db-init.yaml new file mode 100644 index 0000000..cfe4fc9 --- /dev/null +++ b/charts/sliding-sync-proxy/templates/db-init.yaml @@ -0,0 +1,20 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ include "sliding-sync-proxy.fullname" . }}-db-init + labels: + {{- include "sliding-sync-proxy.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded +spec: + template: + spec: + restartPolicy: Never + containers: + - name: general-db-init + image: "{{ .Values.initContainers.dbInit.image.repository }}:{{ .Values.initContainers.dbInit.image.tag }}" + envFrom: + - secretRef: + name: {{ .Values.existingSecret }} + backoffLimit: 3 \ No newline at end of file diff --git a/charts/sliding-sync-proxy/templates/deployment.yaml b/charts/sliding-sync-proxy/templates/deployment.yaml new file mode 100644 index 0000000..ab1e6e9 --- /dev/null +++ b/charts/sliding-sync-proxy/templates/deployment.yaml @@ -0,0 +1,67 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "sliding-sync-proxy.fullname" . }} + labels: + {{- include "sliding-sync-proxy.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "sliding-sync-proxy.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "sliding-sync-proxy.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default (printf "v%s" .Chart.AppVersion) }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: SYNCV3_SERVER + value: {{ .Values.homeserver }} + - name: SYNCV3_BINDADDR + value: {{ .Values.serverAddress }} + envFrom: + - secretRef: + name: {{ .Values.existingSecret }} + ports: + - name: http + containerPort: 8008 + protocol: TCP + livenessProbe: + tcpSocket: + port: http + readinessProbe: + tcpSocket: + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} \ No newline at end of file diff --git a/charts/sliding-sync-proxy/templates/hpa.yaml b/charts/sliding-sync-proxy/templates/hpa.yaml new file mode 100644 index 0000000..87027c0 --- /dev/null +++ b/charts/sliding-sync-proxy/templates/hpa.yaml @@ -0,0 +1,29 @@ +{{- if .Values.autoscaling.enabled }} +--- +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "sliding-sync-proxy.fullname" . }} + labels: + {{- include "sliding-sync-proxy.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "sliding-sync-proxy.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/sliding-sync-proxy/templates/service.yaml b/charts/sliding-sync-proxy/templates/service.yaml new file mode 100644 index 0000000..f6b2814 --- /dev/null +++ b/charts/sliding-sync-proxy/templates/service.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "sliding-sync-proxy.fullname" . }} + labels: + {{- include "sliding-sync-proxy.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "sliding-sync-proxy.selectorLabels" . | nindent 4 }} \ No newline at end of file diff --git a/charts/sliding-sync-proxy/values.yaml b/charts/sliding-sync-proxy/values.yaml new file mode 100644 index 0000000..9ec9672 --- /dev/null +++ b/charts/sliding-sync-proxy/values.yaml @@ -0,0 +1,63 @@ +homeserver: "https://synapse.example.com" +serverAddress: "https://slidingsync.example.com" +existingSecret: "slidingsync-secret" + +initContainers: + dbInit: + image: + repository: ghcr.io/onedr0p/postgres-init + tag: "16" + envFrom: + - secretRef: + name: slidingsync-secret + +image: + repository: ghcr.io/matrix-org/sliding-sync + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +replicaCount: 1 + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +podSecurityContext: + fsGroup: 2000 + +securityContext: + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} +# limits: +# cpu: 100m +# memory: 128Mi +# requests: +# cpu: 100m +# memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}