From 896eb98429b18ab759eb40f46228b81655827895 Mon Sep 17 00:00:00 2001 From: Mario Cao Date: Mon, 28 Oct 2024 14:09:12 +0100 Subject: [PATCH] chore: add helm example --- helm/.helmignore | 23 ++++++++++++++++ helm/Chart.yaml | 5 ++++ helm/templates/_helpers.tpl | 31 +++++++++++++++++++++ helm/templates/configmap.yaml | 15 +++++++++++ helm/templates/deployment.yaml | 49 ++++++++++++++++++++++++++++++++++ helm/templates/ingress.yaml | 0 helm/templates/secret.yaml | 9 +++++++ helm/templates/service.yaml | 13 +++++++++ helm/values.yaml | 18 +++++++++++++ 9 files changed, 163 insertions(+) create mode 100644 helm/.helmignore create mode 100644 helm/Chart.yaml create mode 100644 helm/templates/_helpers.tpl create mode 100644 helm/templates/configmap.yaml create mode 100644 helm/templates/deployment.yaml create mode 100644 helm/templates/ingress.yaml create mode 100644 helm/templates/secret.yaml create mode 100644 helm/templates/service.yaml create mode 100644 helm/values.yaml diff --git a/helm/.helmignore b/helm/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/.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/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..b130cc9 --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: seda-data-proxy +description: A Helm chart for Kubernetes to deploy the SEDA Data Proxy. +version: 0.1.0 +appVersion: "1.0" diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl new file mode 100644 index 0000000..fa4d50f --- /dev/null +++ b/helm/templates/_helpers.tpl @@ -0,0 +1,31 @@ +{{/* +Generate a full name for the resources, optionally including the release name. +*/}} +{{- define "seda-data-proxy.fullname" -}} +{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "seda-data-proxy.labels" -}} +app.kubernetes.io/name: {{ include "seda-data-proxy.name" . }} +helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "seda-data-proxy.selectorLabels" -}} +app.kubernetes.io/name: {{ include "seda-data-proxy.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Template for the name of the application +*/}} +{{- define "seda-data-proxy.name" -}} +{{- .Chart.Name -}} +{{- end }} diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml new file mode 100644 index 0000000..7c232ae --- /dev/null +++ b/helm/templates/configmap.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "seda-data-proxy.fullname" . }}-config +data: + config.json: | + { + "routes": [ + { + "path": "/*", + "upstreamUrl": "https://swapi.dev/api/", + "methods": ["GET"] + } + ] + } diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml new file mode 100644 index 0000000..15d9237 --- /dev/null +++ b/helm/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "seda-data-proxy.fullname" . }} + labels: + {{- include "seda-data-proxy.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "seda-data-proxy.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "seda-data-proxy.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.port }} + env: + {{- range .Values.envVars }} + - name: {{ .name }} + value: {{ .value }} + {{- end }} + - name: SEDA_DATA_PROXY_PRIVATE_KEY + valueFrom: + secretKeyRef: + name: {{ include "seda-data-proxy.fullname" . }}-secrets + key: SEDA_DATA_PROXY_PRIVATE_KEY + args: ["run", {{ .Values.sedaProxyFlags }} ] + readinessProbe: + httpGet: + path: /status/health + port: {{ .Values.service.port }} + livenessProbe: + httpGet: + path: /status/health + port: {{ .Values.service.port }} + volumeMounts: + - name: config-volume + mountPath: /app/config.json + subPath: config.json + volumes: + - name: config-volume + configMap: + name: {{ include "seda-data-proxy.fullname" . }}-config diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml new file mode 100644 index 0000000..e69de29 diff --git a/helm/templates/secret.yaml b/helm/templates/secret.yaml new file mode 100644 index 0000000..d5f2bf8 --- /dev/null +++ b/helm/templates/secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "seda-data-proxy.fullname" . }}-secrets + labels: + {{- include "seda-data-proxy.labels" . | nindent 4 }} +type: Opaque +data: + SEDA_DATA_PROXY_PRIVATE_KEY: {{ .Values.secret.sedaDataProxyPrivateKey | b64enc | quote }} diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml new file mode 100644 index 0000000..5501f74 --- /dev/null +++ b/helm/templates/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "seda-data-proxy.fullname" . }} + labels: + {{- include "seda-data-proxy.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.port }} + selector: + {{- include "seda-data-proxy.selectorLabels" . | nindent 4 }} diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..1160d34 --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,18 @@ +image: + repository: ghcr.io/sedaprotocol/seda-data-proxy + tag: "v0.0.2" + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 5384 + +replicaCount: 1 + +# export SEDA_PRIVATE_KEY= +# helm install my-release ./chart-name --set secret.sedaDataProxyPrivateKey=$SEDA_PRIVATE_KEY +secret: + sedaDataProxyPrivateKey: "" + +# Uncomment for testing (itdisables request verification) +# sedaProxyFlags: "--disable-proof"