Skip to content

Commit

Permalink
add sink noop helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
kw1knode committed Jul 8, 2024
1 parent 0ab22ab commit a004dbf
Show file tree
Hide file tree
Showing 9 changed files with 483 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/substreams-sink-noop/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
24 changes: 24 additions & 0 deletions charts/substreams-sink-noop/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: substreams-sink-noop
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: 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: "v1.2.1"
1 change: 1 addition & 0 deletions charts/substreams-sink-noop/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

85 changes: 85 additions & 0 deletions charts/substreams-sink-noop/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{{/*
Expand the name of the chart.
This template returns the chart name, either using the default .Chart.Name or an override .Values.nameOverride.
It truncates the result to 63 characters and removes any trailing hyphens.
*/}}
{{- define "noop.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 the release name contains the chart name, it will be used as a full name. Otherwise, it combines the release name and the chart name.
*/}}
{{- define "noop.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.
This combines the chart name and version, replaces any '+' with '_', truncates to 63 characters, and removes trailing hyphens.
*/}}
{{- define "noop.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
This template includes the chart label and version, selector labels, app version if available, and managed-by label.
*/}}
{{- define "noop.labels" -}}
helm.sh/chart: {{ include "noop.chart" . }}
{{ include "noop.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
This template provides standard selector labels including the app name and instance.
*/}}
{{- define "noop.selectorLabels" -}}
app.kubernetes.io/name: {{ include "noop.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
This selects the service account name based on whether it is created and any overrides.
*/}}
{{- define "noop.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "noop.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create a label for a component
This template is used to add a component label to Kubernetes resources.
*/}}
{{- define "noop.componentLabelFor" -}}
app.kubernetes.io/component: {{ . }}
{{- end }}

{{/*
Generate a unique name for resources based on network name.
*/}}
{{- define "noop.uniqueName" -}}
{{- printf "substreams-sink-noop-%s" (default "ethereum" .Values.networkName) | trunc 63 | trimSuffix "-" }}
{{- end }}


26 changes: 26 additions & 0 deletions charts/substreams-sink-noop/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "noop.uniqueName" . }}-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "noop.uniqueName" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/substreams-sink-noop/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- $values := .Values.noop }}
{{- $networkName := $values.networkName | default "ethereum" }}
{{- $componentName := printf "noop-%s" $networkName }}
{{- $componentLabel := include "noop.componentLabelFor" $componentName | default "" }}


apiVersion: v1
kind: Service
metadata:
name: {{ include "noop.uniqueName" . }}-svc
labels:
{{- include "noop.labels" . | nindent 4 }}
spec:
type: {{ .Values.noop.service.type }}
{{- if .Values.noop.service.ipFamilyPolicy }}
ipFamilyPolicy: {{ .Values.noop.service.ipFamilyPolicy }}
{{- end }}
{{- if .Values.noop.service.clusterIP }}
clusterIP: {{ .Values.noop.service.clusterIP }}
{{- end }}
ports:
- name: grpc
port: {{ .Values.noop.service.ports.grpc }}
targetPort: grpc
protocol: TCP
- name: metrics
port: {{ .Values.noop.service.ports.metrics }}
targetPort: metrics
protocol: TCP
selector:
{{- include "noop.selectorLabels" . | nindent 4 }}
{{- $componentLabel | nindent 4 }}
17 changes: 17 additions & 0 deletions charts/substreams-sink-noop/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.serviceAccount.create }}
{{- $values := .Values.noop }}
{{- $networkName := $values.networkName | default "ethereum" }}
{{- $componentName := printf "noop-%s" $networkName }}
{{- $componentLabel := include "noop.componentLabelFor" $componentName | default "" }}

apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "noop.uniqueName" . }}-sa
labels:
{{- include "noop.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
104 changes: 104 additions & 0 deletions charts/substreams-sink-noop/templates/statefulSet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{{- $values := .Values.noop }}
{{- $networkName := $values.networkName | default "ethereum" }}
{{- $componentName := printf "noop-%s" $networkName }}
{{- $componentLabel := include "noop.componentLabelFor" $componentName | default "" }}

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "noop.uniqueName" .}}
labels:
{{- include "noop.labels" . | nindent 4 }}
{{- $componentLabel | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "noop.selectorLabels" . | nindent 4 }}
{{- if $values.volumeClaimSpec.enabled }}
volumeClaimTemplates:
- metadata:
name: state-store
spec:
{{- with $spec := $values.volumeClaimSpec }}
{{- $spec := omit $spec "enabled" }}
{{- toYaml $spec | nindent 8 }}
{{- end }}
{{- end }}
template:
metadata:
{{- with $values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "noop.labels" . | nindent 4 }}
{{- $componentLabel | nindent 4 }}
spec:
{{- with $values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if $values.nodeSelector }}
nodeSelector:
{{- toYaml $values.nodeSelector | nindent 8 }}
{{- end }}
{{- if $.Values.serviceAccount.create }}
serviceAccountName: {{ include "noop.serviceAccountName" . }}
{{- end }}
terminationGracePeriodSeconds: {{ $values.terminationGracePeriodSeconds | default 60 }}
containers:
- name: {{ $componentName }}
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
args:
- "{{ $values.endpoint | default "mainnet.eth.streamingfast.io:443" }}"
- "{{ $values.manifest | default "https://github.com/streamingfast/substreams-eth-block-meta/releases/download/v0.4.1/substreams-eth-block-meta-v0.4.1.spkg" }}"
- "{{ $values.module | default "graph_out" }}"
{{- if $values.volumeClaimSpec.enabled }}
- "--state-store=./state/state.yaml"
{{- end }}
{{- if and $values.startBlock $values.stopBlock }}
- "{{ $values.startBlock }}:{{ $values.stopBlock }}"
{{- else if $values.startBlock }}
- "+{{ $values.startBlock }}"
{{- end }}
{{- range $value := $values.extraArgs }}
- "{{ $value }}"
{{- end }}
ports:
- name: http
containerPort: {{ index $values.service.ports "grpc" }}
protocol: TCP
- name: metrics
containerPort: {{ index $values.service.ports "metrics" }}
protocol: TCP
{{- if $values.volumeClaimSpec.enabled }}
volumeMounts:
- name: state-store
mountPath: /state
{{- end }}
{{- if $.Values.resources }}
resources:
{{- if $.Values.resources.requests }}
requests:
{{- if $.Values.resources.requests.cpu }}
cpu: {{ $.Values.resources.requests.cpu }}
{{- end }}
{{- if $.Values.resources.requests.memory }}
memory: {{ $.Values.resources.requests.memory }}
{{- end }}
{{- end }}
{{- if $.Values.resources.limits }}
limits:
{{- if $.Values.resources.limits.cpu }}
cpu: {{ $.Values.resources.limits.cpu }}
{{- end }}
{{- if $.Values.resources.limits.memory }}
memory: {{ $.Values.resources.limits.memory }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit a004dbf

Please sign in to comment.