Skip to content

Commit

Permalink
[sc-7470]: erpc helm chart (#159)
Browse files Browse the repository at this point in the history
* 💥 initial erpc chart

* make erpc config more configurable

* more tweaks and config

* disable redis by default
  • Loading branch information
WesleyCharlesBlake authored Aug 20, 2024
1 parent 7830ebd commit c4d627f
Show file tree
Hide file tree
Showing 17 changed files with 845 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/erpc/.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/
6 changes: 6 additions & 0 deletions charts/erpc/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 20.0.3
digest: sha256:532209d01728c77a76852f4d30574bca8d0bcd49e16de758d73ca1987c64aec4
generated: "2024-08-20T20:34:07.118507+02:00"
36 changes: 36 additions & 0 deletions charts/erpc/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v2
name: erpc
description: A Helm chart for deploying eRPC — fault-tolerant evm rpc proxy with reorg-aware permanent caching to Kubernetes
icon: https://avatars.githubusercontent.com/u/87739326
maintainers:
- name: WesleyCharlesBlake
url: https://github.com/WesleyCharlesBlake
- name: chronicleprotocol
url: https://chroniclelabs.org

# 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.0.1

# 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.0.12

dependencies:
- name: redis
version: "20.x.x"
repository: "https://charts.bitnami.com/bitnami"
condition: redis.enabled
93 changes: 93 additions & 0 deletions charts/erpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# erpc

![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.12](https://img.shields.io/badge/AppVersion-0.0.12-informational?style=flat-square)

A Helm chart for deploying eRPC — fault-tolerant evm rpc proxy with reorg-aware permanent caching to Kubernetes

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| WesleyCharlesBlake | | <https://github.com/WesleyCharlesBlake> |
| chronicleprotocol | | <https://chroniclelabs.org> |

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| https://charts.bitnami.com/bitnami | redis | 20.x.x |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| env | object | `{}` | create env vars from secrets, eg RPC provider API keys (eg, Blast API, DRPC, Infura, Alchemy, etc. ) |
| erpc.cacheConfig | object | `{"driver":"memory"}` | provides a DB backend for caching. must be one of `memory`, `redis`, or `postgresql`. ref: https://docs.erpc.cloud/config/database |
| erpc.projects | list | `[{"id":"testnet","networkIds":["5","421614","11155111"]}]` | Projects define the networks and chains that eRPC will proxy for. ref: https://docs.erpc.cloud/config/projects |
| erpc.projects[0].networkIds | list | `["5","421614","11155111"]` | A network represents a chain in EVM, and it is a local grouping for upstreams. ref: https://docs.erpc.cloud/config/projects/networks |
| erpc.rateLimiters | list | `[{"id":"p3","rules":[{"maxCount":10000,"method":"*","period":"1s"}]},{"id":"p2","rules":[{"maxCount":1000,"method":"*","period":"2s"}]},{"id":"p1","rules":[{"maxCount":300,"method":"*","period":"1s"}]}]` | Define rate limiters for upstreams. ref: https://docs.erpc.cloud/config/projects/rate-limiters |
| erpc.upstreams | list | `[{"chainId":"11155111","endpoint":"https://ethereum-sepolia-rpc.publicnode.com","id":"sep-public-node","rateLimit":"p2"},{"chainId":"11155111","endpoint":"https://eth-sepolia.public.blastapi.io","id":"sep-blast-node","rateLimit":"p2"},{"chainId":"300","endpoint":"https://zksync-sepolia.drpc.org","id":"zksync-sep-drpc","rateLimit":"p3"},{"chainId":5,"endpoint":"https://zksync-era-sepolia.blockpi.network/v1/rpc/public","id":"zksync-sep-blockpi","rateLimit":"p1"},{"endpoint":"envio://rpc.hypersync.xyz","id":"envio-public","rateLimit":"p2"}]` | A upstream is defined to handle 1 or more networks (a.k.a. chains). ref: https://docs.erpc.cloud/config/projects/upstreams |
| erpc.upstreams[4] | object | `{"endpoint":"envio://rpc.hypersync.xyz","id":"envio-public","rateLimit":"p2"}` | Ref: https://docs.erpc.cloud/config/projects/upstreams#envio-json-rpc |
| extraObjects | list | `[]` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"ghcr.io/erpc/erpc"` | |
| image.tag | string | `""` | |
| imagePullSecrets | list | `[]` | |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts[0].host | string | `"chart-example.local"` | |
| ingress.hosts[0].paths[0].path | string | `"/"` | |
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
| livenessProbe | object | See `values.yaml` | Liveness probe |
| maxSurge | string | `nil` | default is 1 |
| maxUnavailable | string | `nil` | default is 0 |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| preStopSleepSeconds | string | `nil` | default is 20 seconds |
| readinessProbe | object | See `values.yaml` | Readiness probe |
| redis.auth.password | string | `"yourRedisSecret"` | |
| redis.enabled | bool | `false` | If enabled a redis chart will be deployed as a dependency |
| redis.master.persistence.enabled | bool | `false` | |
| redis.master.persistence.size | string | `"8Gi"` | |
| redis.replica.persistence.enabled | bool | `false` | |
| redis.replica.persistence.size | string | `"8Gi"` | |
| redis.replica.replicaCount | int | `1` | |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| service.annotations | object | `{}` | |
| service.ports.http.port | int | `4000` | |
| service.ports.http.protocol | string | `"TCP"` | |
| service.ports.metrics.port | int | `4001` | |
| service.ports.metrics.protocol | string | `"TCP"` | |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| serviceMonitor | object | `{"annotations":{},"enabled":false,"interval":"1m","labels":{},"namespace":null,"path":"/metrics","port":"metrics","relabelings":[],"scheme":"http","scrapeTimeout":"30s","tlsConfig":{}}` | If true, create a ServiceMonitor CRD for prometheus operator |
| serviceMonitor.annotations | object | `{}` | Additional ServiceMonitor annotations |
| serviceMonitor.enabled | bool | `false` | If true, a ServiceMonitor CRD is created for a prometheus operator https://github.com/coreos/prometheus-operator |
| serviceMonitor.interval | string | `"1m"` | ServiceMonitor scrape interval |
| serviceMonitor.labels | object | `{}` | Additional ServiceMonitor labels |
| serviceMonitor.namespace | string | `nil` | Alternative namespace for ServiceMonitor |
| serviceMonitor.path | string | `"/metrics"` | Path to scrape |
| serviceMonitor.port | string | `"metrics"` | port to scrape |
| serviceMonitor.relabelings | list | `[]` | ServiceMonitor relabelings |
| serviceMonitor.scheme | string | `"http"` | ServiceMonitor scheme |
| serviceMonitor.scrapeTimeout | string | `"30s"` | ServiceMonitor scrape timeout |
| serviceMonitor.tlsConfig | object | `{}` | ServiceMonitor TLS configuration |
| tolerations | list | `[]` | |
| updateStrategy | string | `nil` | default RollingUpdate |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
22 changes: 22 additions & 0 deletions charts/erpc/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "erpc.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "erpc.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "erpc.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "erpc.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions charts/erpc/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "erpc.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 "erpc.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 "erpc.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "erpc.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "erpc.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
73 changes: 73 additions & 0 deletions charts/erpc/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "erpc.fullname" . }}-config
data:
erpc.yaml: |
logLevel: warn
{{ if .Values.erpc.cacheConfig }}
database:
evmJsonRpcCache:
{{- .Values.erpc.cacheConfig | toYaml | nindent 8 }}
{{- end }}
server:
httpHost: 0.0.0.0
httpPort: {{ .Values.service.ports.http.port | default "4000" }}
metrics:
enabled: true
host: 0.0.0.0
port: {{ .Values.service.ports.metrics.port | default "4001" }}
projects:
{{- range $project := .Values.erpc.projects }}
- id: {{ $project.id }}
networks:
{{- range $project.networkIds }}
- architecture: evm
evm:
chainId: {{ . }}
failsafe:
timeout:
duration: 30s
retry:
maxCount: 3
delay: 500ms
backoffMaxDelay: 10s
backoffFactor: 0.3
jitter: 500ms
hedge:
delay: 3000ms
maxCount: 2
{{- end }}
{{- end }}
upstreams:
{{- range $upstream := .Values.erpc.upstreams }}
- id: {{ $upstream.id }}
endpoint: {{ $upstream.endpoint }}
rateLimitBudget: {{ $upstream.rateLimit }}
evm:
chainId: {{ $upstream.chainId }}
failsafe:
timeout:
duration: 15s
retry:
maxCount: 2
delay: 1000ms
backoffMaxDelay: 10s
backoffFactor: 0.3
jitter: 500ms
{{- end }}
rateLimiters:
budgets:
{{- range $rateLimiter := .Values.erpc.rateLimiters }}
- id: {{ $rateLimiter.id }}
rules:
{{- range $rateLimiter.rules }}
- method: {{ .method | quote }}
maxCount: {{ .maxCount }}
period: {{ .period }}
{{- end }}
{{- end }}
Loading

0 comments on commit c4d627f

Please sign in to comment.