Skip to content

Commit

Permalink
Adding RPC node helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
nzenchik committed May 22, 2024
1 parent b74c56f commit 73b92ce
Show file tree
Hide file tree
Showing 9 changed files with 505 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/rpc-node/.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/rpc-node/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: rpc-node
description: A Helm chart for RPC node and consensus

# 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: "0.1.0"
62 changes: 62 additions & 0 deletions charts/rpc-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "rpc-node.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 "rpc-node.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 "rpc-node.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "rpc-node.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "rpc-node.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
60 changes: 60 additions & 0 deletions charts/rpc-node/templates/execution-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{- if .Values.execution.ingress.enabled -}}
{{- $fullName := include "rpc-node.fullname" . -}}
{{- if and .Values.execution.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.execution.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.execution.ingress.annotations "kubernetes.io/ingress.class" .Values.execution.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "rpc-node.labels" . | nindent 4 }}
{{- with .Values.execution.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.execution.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.execution.ingress.className }}
{{- end }}
{{- if .Values.execution.ingress.tls }}
tls:
{{- range .Values.execution.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.execution.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}-execution-cluster
port:
number: {{ .port }}
{{- else }}
serviceName: {{ $fullName }}-execution-cluster
servicePort: {{ .port }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/rpc-node/templates/execution-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.execution.envFromSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "rpc-node.fullname" . }}-execution-env
labels:
{{- include "rpc-node.labels" . | nindent 4 }}
type: Opaque
data:
{{- range $key, $value := .Values.execution.envFromSecret }}
{{ $key }}: {{ $value | b64enc }}
{{- end }}
{{- end }}
39 changes: 39 additions & 0 deletions charts/rpc-node/templates/execution-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "rpc-node.fullname" . }}-execution-cluster
labels:
{{- include "rpc-node.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
{{- range .Values.execution.service.cluster.ports }}
- port: {{ .port }}
targetPort: {{ .port }}
protocol: {{ .protocol }}
name: {{ .name }}
{{- end }}
selector:
app: {{ .Release.Name }}-execution
{{- include "rpc-node.selectorLabels" . | nindent 4 }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "rpc-node.fullname" . }}-execution-node
labels:
{{- include "rpc-node.labels" . | nindent 4 }}
spec:
type: NodePort
externalTrafficPolicy: Local
ports:
{{- range .Values.execution.service.node.ports }}
- port: {{ .port }}
targetPort: {{ .port }}
protocol: {{ .protocol }}
name: {{ .name }}
nodePort: {{ .port }}
{{- end }}
selector:
app: {{ .Release.Name }}-execution
{{- include "rpc-node.selectorLabels" . | nindent 4 }}
127 changes: 127 additions & 0 deletions charts/rpc-node/templates/execution-stateful-set.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "rpc-node.fullname" . }}-execution
labels:
app: {{ .Release.Name }}-execution
{{- include "rpc-node.labels" . | nindent 4 }}
spec:
replicas: 1
serviceName: {{ include "rpc-node.fullname" . }}-execution
selector:
matchLabels:
app: {{ .Release.Name }}-execution
{{- include "rpc-node.selectorLabels" . | nindent 6 }}
updateStrategy:
type: {{ .Values.updateStrategy }}
{{- if .Values.execution.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: execution-data
spec:
accessModes:
{{- range .Values.execution.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.execution.persistence.size | quote }}
{{- if .Values.execution.persistence.storageClass }}
{{- if (eq "-" .Values.execution.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.execution.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
template:
metadata:
{{- with .Values.execution.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: {{ .Release.Name }}-execution
{{- include "rpc-node.labels" . | nindent 8 }}
{{- with .Values.execution.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "rpc-node.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.execution.podSecurityContext | nindent 8 }}
containers:
- name: execution
securityContext:
{{- toYaml .Values.execution.securityContext | nindent 12 }}
image: "{{ .Values.execution.image.repository }}:{{ .Values.execution.image.tag }}"
imagePullPolicy: {{ .Values.execution.image.pullPolicy }}
{{- with .Values.execution.command }}
command: {{ . | toYaml | nindent 12 }}
{{- end }}
{{- with .Values.execution.args }}
args: {{ toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.execution.env }}
env:
{{- range $key, $value := .Values.execution.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- if .Values.execution.envFromSecret }}
envFrom:
- secretRef:
name: {{ include "rpc-node.fullname" . }}-execution-env
{{- range .Values.execution.envFrom }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- end }}
ports:
{{- range .Values.execution.service.cluster.ports }}
- name: {{ .name }}
containerPort: {{ .port }}
protocol: {{ .protocol }}
{{- end }}
{{- range .Values.execution.service.node.ports }}
- name: {{ .name }}
containerPort: {{ .port }}
protocol: {{ .protocol }}
{{- end }}
livenessProbe:
{{- toYaml .Values.execution.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.execution.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.execution.resources | nindent 12 }}
{{- if or .Values.execution.persistence.enabled .Values.volumeMounts }}
volumeMounts:
{{- if .Values.execution.persistence.enabled }}
- name: execution-data
mountPath: /data
{{- end }}
{{- with .Values.execution.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.execution.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: 300
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/rpc-node/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 "rpc-node.serviceAccountName" . }}
labels:
{{- include "rpc-node.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading

0 comments on commit 73b92ce

Please sign in to comment.