Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Optimism charts, update CI lint workflow #278

Merged
merged 14 commits into from
Jan 15, 2024
22 changes: 12 additions & 10 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
-
Expand All @@ -21,20 +21,20 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Set up Helm
uses: azure/setup-helm@v1
uses: azure/setup-helm@v3
with:
version: v3.5.4
version: v3.13.3
-
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: "3.10"
-
uses: helm/chart-testing-action@v2.1.0
uses: helm/chart-testing-action@v2.6.1
-
name: Config chart-testing
run: cp .github/ct.yaml $CT_CONFIG_DIR
Expand All @@ -55,14 +55,16 @@ jobs:
exclude_list=$(cat /tmp/_library_charts | sed '/^ *$/d;N;s/\n/,/' | sed 's/dysnix\///g')

if [[ -n "$test_list" ]]; then
echo "::set-output name=testing::true"
echo "testing=true" >> "$GITHUB_OUTPUT"
fi
if [[ -n "$exclude_list" ]]; then
echo "::set-output name=excluded-charts::--excluded-charts ${exclude_list}"
echo "excluded-charts=--excluded-charts ${exclude_list}" >> "$GITHUB_OUTPUT"
fi
-
name: Create Kubernetes Cluster (kind)
uses: helm/[email protected]
uses: helm/[email protected]
with:
node_image: kindest/node:v1.27.3
if: steps.charts.outputs.testing == 'true'
-
name: Install Charts chart-testing
Expand Down
21 changes: 21 additions & 0 deletions dysnix/op-geth/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: op-geth
description: Optimism op-geth execution-layer client Helm chart

version: 0.1.0
appVersion: v1.101305.0

keywords:
- geth
- optimism
- op-geth
- cryptocurrency
- blockchain
- ethereum

sources:
- https://github.com/dysnix/charts

maintainers:
- name: VladStarr
email: [email protected]
76 changes: 76 additions & 0 deletions dysnix/op-geth/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "op-geth.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 "op-geth.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 "op-geth.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "op-geth.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "op-geth.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

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

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

{{- define "op-geth.healthcheck" -}}
{{- $context := index . 0 }}
{{- $root := index . 1 }}
{{- if and $root.exec (kindIs "string" $root.exec.command) }}
{{- omit $root "enabled" "exec" | toYaml }}
exec:
command:
{{- tpl $root.exec.command $context | nindent 4 }}
{{- else }}
{{- omit $root "enabled" | toYaml }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions dysnix/op-geth/templates/configmap-scripts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "op-geth.fullname" . }}-scripts
labels:
{{- include "op-geth.labels" . | nindent 4 }}
data:
init-download.sh: |-
{{- include (print $.Template.BasePath "/scripts/_init-download.tpl") . | nindent 4 }}
61 changes: 61 additions & 0 deletions dysnix/op-geth/templates/ingress-http.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if and .Values.services.rpc.enabled .Values.ingress.http.enabled -}}
{{- $fullName := include "op-geth.fullname" . -}}
{{- $svcPort := .Values.services.rpc.httpPort -}}
{{- if and .Values.ingress.http.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.http.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.http.annotations "kubernetes.io/ingress.class" .Values.ingress.http.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 }}-http
labels:
{{- include "op-geth.labels" . | nindent 4 }}
{{- with .Values.ingress.http.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.http.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.http.className }}
{{- end }}
{{- if .Values.ingress.http.tls }}
tls:
{{- range .Values.ingress.http.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.http.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 }}-rpc
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}-rpc
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
61 changes: 61 additions & 0 deletions dysnix/op-geth/templates/ingress-ws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if and .Values.services.rpc.enabled .Values.ingress.ws.enabled -}}
{{- $fullName := include "op-geth.fullname" . -}}
{{- $svcPort := .Values.services.rpc.wsPort -}}
{{- if and .Values.ingress.ws.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.ws.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.ws.annotations "kubernetes.io/ingress.class" .Values.ingress.ws.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 }}-ws
labels:
{{- include "op-geth.labels" . | nindent 4 }}
{{- with .Values.ingress.ws.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.ws.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.ws.className }}
{{- end }}
{{- if .Values.ingress.ws.tls }}
tls:
{{- range .Values.ingress.ws.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.ws.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 }}-rpc
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}-rpc
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
24 changes: 24 additions & 0 deletions dysnix/op-geth/templates/scripts/_init-download.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

# TODO: improve zstd extraction with mbuffer

set -e

mkdir -p /root/.ethereum/{{ .Values.config.network }}
cd /root/.ethereum/{{ .Values.config.network }}

if [ ! -f /root/.ethereum/.downloaded ]; then
echo "Not initialized, proceeding with download..."
{{- if contains "lz4" .Values.init.download.url }}
apk add lz4
wget -qO- {{ .Values.init.download.url }} | lz4 -cd | tar -xvf -
{{- else if contains "zstd" .Values.init.download.url }}
apk add zstd
wget -qO- {{ .Values.init.download.url }} | zstd -cd | tar -xvf -
{{- else }}
wget -qO- {{ .Values.init.download.url }} | tar -xvf -
{{- end }}
touch /root/.ethereum/.downloaded
else
echo "Already initialized, skipping."
fi
8 changes: 8 additions & 0 deletions dysnix/op-geth/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "op-geth.fullname" . }}
labels:
{{- include "op-geth.labels" . | nindent 4 }}
data:
jwt.hex: {{ .Values.config.jwt | b64enc | quote }}
38 changes: 38 additions & 0 deletions dysnix/op-geth/templates/service-authrpc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- with .Values.services.authrpc }}
{{- if .enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "op-geth.fullname" $ }}-authrpc
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
service-type: authrpc
{{- include "op-geth.labels" $ | nindent 4 }}
spec:
type: {{ .type }}
{{- with .loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- with .clusterIP }}
clusterIP: {{ . }}
{{- end }}
{{- with .externalTrafficPolicy }}
externalTrafficPolicy: {{ . }}
{{- end }}
{{- with .internalTrafficPolicy }}
internalTrafficPolicy: {{ . }}
{{- end }}
{{- with .publishNotReadyAddresses }}
publishNotReadyAddresses: {{ . }}
{{- end }}
ports:
- name: authrpc
port: {{ .port }}
targetPort: authrpc
selector:
{{- include "op-geth.selectorLabels" $ | nindent 4 }}
{{- end }}
{{- end }}
Loading