Skip to content

Commit

Permalink
Adding multichain-aggregator helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
nzenchik committed Nov 14, 2024
1 parent c36f16d commit 3dfc81b
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/multichain-aggregator/.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/multichain-aggregator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: multichain-aggregator
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: "1.0.0"
62 changes: 62 additions & 0 deletions charts/multichain-aggregator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "multichain-aggregator.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 "multichain-aggregator.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 "multichain-aggregator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "multichain-aggregator.labels" -}}
helm.sh/chart: {{ include "multichain-aggregator.chart" . }}
{{ include "multichain-aggregator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "multichain-aggregator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "multichain-aggregator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "multichain-aggregator.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "multichain-aggregator.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
99 changes: 99 additions & 0 deletions charts/multichain-aggregator/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "multichain-aggregator.fullname" . }}
labels:
{{- include "multichain-aggregator.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "multichain-aggregator.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- if eq .Values.image.pullPolicy "Always" }}
rollme: {{ randAlphaNum 5 | quote }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "multichain-aggregator.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "multichain-aggregator.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: MULTICHAIN_AGGREGATOR__SERVER__HTTP__ADDR
value: "0.0.0.0:{{ .Values.service.port }}"
- name: MULTICHAIN_AGGREGATOR__DATABASE__RUN_MIGRATIONS
value: 'true'
{{- if .Values.config.metrics.enabled }}
- name: MULTICHAIN_AGGREGATOR__METRICS__ENABLED
value: 'true'
- name: MULTICHAIN_AGGREGATOR__METRICS__ADDR
value: 0.0.0.0:{{ .Values.config.metrics.port }}
{{- end }}
{{- if .Values.config.tracing.enabled }}
- name: MULTICHAIN_AGGREGATOR__TRACING__ENABLED
value: 'true'
- name: MULTICHAIN_AGGREGATOR__TRACING__FORMAT
value: {{ .Values.config.tracing.format | quote }}
{{- end }}
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
envFrom:
- secretRef:
name: {{ include "multichain-aggregator.fullname" . }}-env
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.config.metrics.enabled }}
- name: metrics
containerPort: {{ .Values.config.metrics.port }}
protocol: TCP
{{- end }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
43 changes: 43 additions & 0 deletions charts/multichain-aggregator/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "multichain-aggregator.fullname" . }}
labels:
{{- include "multichain-aggregator.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.ingress.className }}
ingressClassName: {{ . }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- with .pathType }}
pathType: {{ . }}
{{- end }}
backend:
service:
name: {{ include "multichain-aggregator.fullname" $ }}
port:
number: {{ $.Values.service.port }}
{{- end }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/multichain-aggregator/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "multichain-aggregator.fullname" . }}-env
labels:
{{- include "multichain-aggregator.labels" . | nindent 4 }}
type: Opaque
data:
MULTICHAIN_AGGREGATOR__DATABASE__CONNECT__URL: {{ .Values.config.databaseUrl | b64enc }}
{{- range $key, $value := .Values.envFromSecret }}
{{ $key }}: {{ $value | b64enc }}
{{- end }}
---
15 changes: 15 additions & 0 deletions charts/multichain-aggregator/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "multichain-aggregator.fullname" . }}
labels:
{{- include "multichain-aggregator.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "multichain-aggregator.selectorLabels" . | nindent 4 }}
13 changes: 13 additions & 0 deletions charts/multichain-aggregator/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "multichain-aggregator.serviceAccountName" . }}
labels:
{{- include "multichain-aggregator.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/multichain-aggregator/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.config.metrics.prometheus.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "multichain-aggregator.fullname" . }}
labels:
{{- include "multichain-aggregator.labels" . | nindent 4 }}
spec:
endpoints:
- interval: "15s"
scrapeTimeout: "5s"
path: /metrics
targetPort: metrics
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "multichain-aggregator.fullname" . }}
{{- end }}
Loading

0 comments on commit 3dfc81b

Please sign in to comment.