Skip to content

Commit

Permalink
add substreams-sink general chart
Browse files Browse the repository at this point in the history
  • Loading branch information
coutug committed Mar 19, 2024
1 parent 1957181 commit 0612aa6
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 0 deletions.
25 changes: 25 additions & 0 deletions charts/substreams-sink/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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"

1 change: 1 addition & 0 deletions charts/substreams-sink/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This should appear as readme in artifacthub
78 changes: 78 additions & 0 deletions charts/substreams-sink/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
50 changes: 50 additions & 0 deletions charts/substreams-sink/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 12 additions & 0 deletions charts/substreams-sink/templates/env.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions charts/substreams-sink/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
15 changes: 15 additions & 0 deletions charts/substreams-sink/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
38 changes: 38 additions & 0 deletions charts/substreams-sink/values.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0612aa6

Please sign in to comment.