From ec498655742173fdd3a06b2f1a30dfff7e20cec7 Mon Sep 17 00:00:00 2001 From: Alex Manning Date: Wed, 27 Sep 2023 23:00:52 +0100 Subject: [PATCH] Add chart for rust-synapse-compress-state. --- .woodpecker/rust-synapse-compress-state.yaml | 12 ++++ .../rust-synapse-compress-state/.helmignore | 23 +++++++ charts/rust-synapse-compress-state/Chart.yaml | 24 +++++++ .../templates/_helpers.tpl | 62 +++++++++++++++++ .../templates/cronjob.yaml | 69 +++++++++++++++++++ .../templates/secret.yaml | 9 +++ .../rust-synapse-compress-state/values.yaml | 48 +++++++++++++ 7 files changed, 247 insertions(+) create mode 100644 .woodpecker/rust-synapse-compress-state.yaml create mode 100644 charts/rust-synapse-compress-state/.helmignore create mode 100644 charts/rust-synapse-compress-state/Chart.yaml create mode 100644 charts/rust-synapse-compress-state/templates/_helpers.tpl create mode 100644 charts/rust-synapse-compress-state/templates/cronjob.yaml create mode 100644 charts/rust-synapse-compress-state/templates/secret.yaml create mode 100644 charts/rust-synapse-compress-state/values.yaml diff --git a/.woodpecker/rust-synapse-compress-state.yaml b/.woodpecker/rust-synapse-compress-state.yaml new file mode 100644 index 0000000..60f188a --- /dev/null +++ b/.woodpecker/rust-synapse-compress-state.yaml @@ -0,0 +1,12 @@ +--- +when: + path: "charts/rust-synapse-compress-state/**" + branch: main +steps: + package: + image: "docker.io/alpine/helm:latest" + secrets: [helm_user, helm_password, helm_repo] + commands: + - helm plugin install https://github.com/chartmuseum/helm-push + - helm repo add therepo $HELM_REPO --username $HELM_USER --password $HELM_PASSWORD + - helm cm-push charts/rust-synapse-compress-state therepo diff --git a/charts/rust-synapse-compress-state/.helmignore b/charts/rust-synapse-compress-state/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/rust-synapse-compress-state/.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/charts/rust-synapse-compress-state/Chart.yaml b/charts/rust-synapse-compress-state/Chart.yaml new file mode 100644 index 0000000..ac0f142 --- /dev/null +++ b/charts/rust-synapse-compress-state/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: rust-synapse-compress-state +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +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. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "3956e0f6be3a58c50f14146d78c30a74fcb3cca9" diff --git a/charts/rust-synapse-compress-state/templates/_helpers.tpl b/charts/rust-synapse-compress-state/templates/_helpers.tpl new file mode 100644 index 0000000..e05fc8f --- /dev/null +++ b/charts/rust-synapse-compress-state/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "rust-synapse-compress-state.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 "rust-synapse-compress-state.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 "rust-synapse-compress-state.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "rust-synapse-compress-state.labels" -}} +helm.sh/chart: {{ include "rust-synapse-compress-state.chart" . }} +{{ include "rust-synapse-compress-state.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "rust-synapse-compress-state.selectorLabels" -}} +app.kubernetes.io/name: {{ include "rust-synapse-compress-state.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "rust-synapse-compress-state.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "rust-synapse-compress-state.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/rust-synapse-compress-state/templates/cronjob.yaml b/charts/rust-synapse-compress-state/templates/cronjob.yaml new file mode 100644 index 0000000..7555c26 --- /dev/null +++ b/charts/rust-synapse-compress-state/templates/cronjob.yaml @@ -0,0 +1,69 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "rust-synapse-compress-state.fullname" . }} + labels: + {{- include "rust-synapse-compress-state.labels" . | nindent 4 }} +# The cronjob spec. +spec: + schedule: {{ .Values.schedule }} + concurrencyPolicy: Forbid + startingDeadlineSeconds: 3600 + successfulJobsHistoryLimit: 1 + failedJobsHistoryLimit: 1 + jobTemplate: + # The job spec + spec: + backoffLimit: 1 + # The pod template. + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 14 }} + {{- end }} + labels: + {{- include "rust-synapse-compress-state.selectorLabels" . | nindent 14 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 14 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 14 }} + restartPolicy: Never + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 18 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + resources: + {{- toYaml .Values.resources | nindent 18 }} + command: + - /usr/local/bin/synapse_auto_compressor + args: + - -p + - "$(POSTGRES_CONNECTION_STRING)" + - -c + - {{ .Values.chunkSize | quote }} + - -n + - {{ .Values.numChunks | quote }} + env: + - name: POSTGRES_CONNECTION_STRING + valueFrom: + secretKeyRef: + name: {{ include "rust-synapse-compress-state.fullname" . }} + key: postgres-connection-string + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 14 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 14 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 14 }} + {{- end }} diff --git a/charts/rust-synapse-compress-state/templates/secret.yaml b/charts/rust-synapse-compress-state/templates/secret.yaml new file mode 100644 index 0000000..23f404d --- /dev/null +++ b/charts/rust-synapse-compress-state/templates/secret.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "rust-synapse-compress-state.fullname" . }} + labels: + {{- include "rust-synapse-compress-state.labels" . | nindent 4 }} +stringData: + postgres-connection-string: {{ .Values.postgresConnectionString }} diff --git a/charts/rust-synapse-compress-state/values.yaml b/charts/rust-synapse-compress-state/values.yaml new file mode 100644 index 0000000..b5c5b4e --- /dev/null +++ b/charts/rust-synapse-compress-state/values.yaml @@ -0,0 +1,48 @@ +--- + +image: + repository: git.a09.uk/alex/rust-synapse-compress-state + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +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 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +schedule: "5 4 * * *" + +postgresConnectionString: "" +chunkSize: "500" +chunkCount: "100"