Skip to content

Commit

Permalink
add interceptor helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
matilote committed Oct 17, 2024
1 parent 2b97459 commit 1b69fd5
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/helm-docs/_templates.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{ define "extra.installation" -}}

## Installation

```bash
helm repo add nethermind https://nethermindeth.github.io/helm-charts
helm install {{ template "chart.name" . }} nethermind/{{ template "chart.name" . }}
```

{{- end }}
51 changes: 51 additions & 0 deletions .github/workflows/chart-releaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Helm Charts Release

on:
push:
branches:
- main
workflow_dispatch:

jobs:
helm-chart-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.12.1

- name: Helm Dependencies
run: |
helm dependency update helm-chart
- name: Run chart-releaser
uses: helm/chart-releaser-action@main
with:
charts_dir: helm-chart
pages_branch: charts-releases
skip_upload: true
env:
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CR_SKIP_EXISTING: true
CR_GENERATE_RELEASE_NOTES: true

- name: Publish to JFrog Artifactory
shell: bash
run: |
helm registry login nethermind.jfrog.io --username ${{ secrets.ARTIFACTORY_ANGKOR_USERNAME }} --password ${{ secrets.ARTIFACTORY_ANGKOR_TOKEN_CONTRIBUTOR }}
for chart in .cr-release-packages/*.tgz; do
helm push "$chart" oci://nethermind.jfrog.io/angkor-helmoci-local
done
31 changes: 31 additions & 0 deletions .github/workflows/helm-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Generate Helm Docs

on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
generate-helm-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0

- name: Set up Docker
uses: docker/setup-buildx-action@v2

- name: Run helm-docs
run: docker run --rm -v $(pwd):/helm-docs jnorwood/helm-docs:v1.14.2 --chart-search-root=. --template-files=./.github/helm-docs/_templates.gotmpl --template-files=README.md.gotmpl

- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.event.pull_request.head.ref }}
message: "docs: auto-generate chart docs"
23 changes: 23 additions & 0 deletions .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/
9 changes: 9 additions & 0 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: jrpc-interceptor
description: A Helm chart for the JRPC Interceptor application
type: application
version: 0.1.0
appVersion: "main"
maintainers:
- name: Nethermind
url: https://nethermind.io
51 changes: 51 additions & 0 deletions helm-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "jrpc-interceptor.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 "jrpc-interceptor.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 "jrpc-interceptor.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "jrpc-interceptor.selectorLabels" -}}
app.kubernetes.io/name: {{ include "jrpc-interceptor.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
42 changes: 42 additions & 0 deletions helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "jrpc-interceptor.fullname" . }}
labels:
{{- include "jrpc-interceptor.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "jrpc-interceptor.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "jrpc-interceptor.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.ports.http }}
protocol: TCP
- name: metrics
containerPort: {{ .Values.ports.metrics }}
protocol: TCP
env:
- name: LISTEN_PORT
value: "{{ .Values.host }}:{{ .Values.ports.http }}"
- name: SERVICE_TO_PROXY
value: {{ .Values.env.SERVICE_TO_PROXY | quote }}
- name: LOG_SERVER_URL
value: "{{ .Values.host }}:{{ .Values.ports.logServer }}"
- name: PROMETHEUS_URL
value: "{{ .Values.host }}:{{ .Values.ports.metrics }}"
- name: USE_PROMETHEUS
value: {{ .Values.env.USE_PROMETHEUS | quote }}
- name: LOG_SERVER_DEBUG
value: {{ .Values.env.LOG_SERVER_DEBUG | quote }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
19 changes: 19 additions & 0 deletions helm-chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "jrpc-interceptor.fullname" . }}
labels:
{{- include "jrpc-interceptor.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.ports.http }}
targetPort: http
protocol: TCP
name: http
- port: {{ .Values.ports.metrics }}
targetPort: metrics
protocol: TCP
name: metrics
selector:
{{- include "jrpc-interceptor.selectorLabels" . | nindent 4 }}
27 changes: 27 additions & 0 deletions helm-chart/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "jrpc-interceptor.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- else }}
namespace: {{ .Release.Namespace }}
{{- end }}
labels:
{{- include "jrpc-interceptor.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: metrics
interval: {{ .Values.serviceMonitor.interval }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
selector:
matchLabels:
{{- include "jrpc-interceptor.selectorLabels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
36 changes: 36 additions & 0 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
replicaCount: 1

image:
repository: ghcr.io/nethermindeth/jrpc-interceptor
pullPolicy: Always
tag: "main"

service:
type: ClusterIP

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

host: 0.0.0.0

ports:
http: 8081
metrics: 9120
logServer: 514

env:
SERVICE_TO_PROXY: "op-fullnode-op-execution:8545"
USE_PROMETHEUS: "true"
LOG_SERVER_DEBUG: "true"

serviceMonitor:
enabled: true
namespace: "" # If empty, will use the release namespace
interval: 15s
scrapeTimeout: 10s
additionalLabels: {}

0 comments on commit 1b69fd5

Please sign in to comment.