diff --git a/charts/substreams-sink/Chart.yaml b/charts/substreams-sink/Chart.yaml new file mode 100644 index 0000000..25e0156 --- /dev/null +++ b/charts/substreams-sink/Chart.yaml @@ -0,0 +1,25 @@ +apiVersion: v2 +name: substreams-sink +description: substreams-sink + +# 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: 1.0.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: "v0.0.0" + diff --git a/charts/substreams-sink/README b/charts/substreams-sink/README new file mode 100644 index 0000000..ed1e532 --- /dev/null +++ b/charts/substreams-sink/README @@ -0,0 +1 @@ +# This should appear as readme in artifacthub \ No newline at end of file diff --git a/charts/substreams-sink/templates/_helpers.tpl b/charts/substreams-sink/templates/_helpers.tpl new file mode 100644 index 0000000..ebb5e3b --- /dev/null +++ b/charts/substreams-sink/templates/_helpers.tpl @@ -0,0 +1,78 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "substreams-sink.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 "substreams-sink.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $baseName := default .Chart.Name .Values.nameOverride -}} +{{- $name := .Release.Name -}} +{{- if and .Values.sinkType (not .Values.fullnameOverride) }} +{{- $name = printf "%s-%s" $name .Values.sinkType -}} +{{- end }} +{{- if and .Values.chain (not .Values.fullnameOverride) }} +{{- $name = printf "%s-%s" $name .Values.chain -}} +{{- end }} +{{- $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "substreams-sink.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create common lablels. +*/}} +{{- define "substreams-sink.common-labels" -}} +app: {{ include "substreams-sink.fullname" . }} +{{- if .Values.sinkType }} +sinkType: {{ .Values.sinkType }} +{{- end }} +{{- if .Values.chain }} +chain: {{ .Values.chain }} +{{- end }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "substreams-sink.labels" -}} +helm.sh/chart: {{ include "substreams-sink.chart" . }} +{{ include "substreams-sink.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "substreams-sink.selectorLabels" -}} +app.kubernetes.io/name: {{ include "substreams-sink.name" . }} +app.kubernetes.io/instance: {{ include "substreams-sink.fullname" . }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "substreams-sink.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "substreams-sink.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/substreams-sink/templates/deployment.yaml b/charts/substreams-sink/templates/deployment.yaml new file mode 100644 index 0000000..4973ea5 --- /dev/null +++ b/charts/substreams-sink/templates/deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: {{ if .Values.cursorPvc.enabled }}StatefulSet{{ else }}Deployment{{ end }} +metadata: + name: {{ include "substreams-sink.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "substreams-sink.common-labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "substreams-sink.common-labels" . | nindent 6 }} + replicas: 1 + template: + metadata: + labels: + {{- include "substreams-sink.common-labels" . | nindent 8 }} + spec: + containers: + - name: {{ include "substreams-sink.fullname" . }} + image: {{ .Values.image -}} :{{ .Values.tag }} + {{- if .Values.args }} + args: {{ .Values.args }} + {{- end }} + ports: + - containerPort: {{ .Values.env.port }} + envFrom: + - configMapRef: + name: env-{{ include "substreams-sink.fullname" . }} + {{- if .Values.secretName }} + - secretRef: + name: {{ .Values.secretName }} + {{- end }} + {{- if .Values.livenessProbe.enabled }} + livenessProbe: + httpGet: + path: {{ .Values.livenessProbe.path }} + port: {{ .Values.env.port }} + initialDelaySeconds: 20 + timeoutSeconds: 2 + periodSeconds: 5 + {{- end }} + {{- if .Values.cursorPvc.enabled }} + volumeMounts: + - name: cursor-volume + mountPath: /cursor + volumes: + - name: cursor-volume + persistentVolumeClaim: + claimName: pvc-{{ include "substreams-sink.fullname" . }} + {{- end }} \ No newline at end of file diff --git a/charts/substreams-sink/templates/env.yaml b/charts/substreams-sink/templates/env.yaml new file mode 100644 index 0000000..0d7186f --- /dev/null +++ b/charts/substreams-sink/templates/env.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: env-{{ include "substreams-sink.fullname" . }} + labels: + {{- include "substreams-sink.common-labels" . | nindent 4 }} +data: + {{- range $key, $val := .Values.env }} + {{- if $val }} + {{ $key | upper }}: {{ $val | quote }} + {{- end }} + {{- end }} \ No newline at end of file diff --git a/charts/substreams-sink/templates/pvc.yaml b/charts/substreams-sink/templates/pvc.yaml new file mode 100644 index 0000000..cdd07ce --- /dev/null +++ b/charts/substreams-sink/templates/pvc.yaml @@ -0,0 +1,16 @@ +{{- if .Values.cursorPvc.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc-{{ include "substreams-sink.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "substreams-sink.common-labels" . | nindent 4 }} +spec: + storageClassName: {{ .Values.cursorPvc.storageClassName }} + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi +{{- end }} \ No newline at end of file diff --git a/charts/substreams-sink/templates/service.yaml b/charts/substreams-sink/templates/service.yaml new file mode 100644 index 0000000..14665f4 --- /dev/null +++ b/charts/substreams-sink/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "substreams-sink.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "substreams-sink.common-labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + selector: + {{- include "substreams-sink.common-labels" . | nindent 4 }} + ports: + - protocol: TCP + port: {{ .Values.env.port }} + targetPort: {{ .Values.env.port }} \ No newline at end of file diff --git a/charts/substreams-sink/values.yaml b/charts/substreams-sink/values.yaml new file mode 100644 index 0000000..653cca8 --- /dev/null +++ b/charts/substreams-sink/values.yaml @@ -0,0 +1,38 @@ +nameOverride: "" +fullnameOverride: "" + +replicaCount: 1 +image: ghcr.io/pinax-network/substreams-sink-prometheus +tag: v0.7.11 +args: "" +# args: ["run"] + +sinkType: "" +chain: "" + +env: + substreams_endpoint: "" + manifest: "" + module_name: "" + start_block: "" + stop_block: "" + # cursor_file: "/cursor/cursor.lock" + # production_mode: true + # hostname: 0.0.0.0 + # port: 9102 + # verbose: true + +# SUBSTREAMS_API_KEY +secretName: token-secret + +livenessProbe: + enabled: false + path: /health + +service: + type: ClusterIP + +cursorPvc: + # if true, set cursor_file: "/cursor/cursor.lock" + enabled: false + storageClassName: mayastor-ext4 \ No newline at end of file