-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: v2 | ||
name: bor | ||
description: Polygon Bor execution layer node Helm chart | ||
|
||
version: 0.0.1 | ||
appVersion: "1.0.6" | ||
|
||
keywords: | ||
- geth | ||
- bor | ||
- polygon | ||
- matic | ||
- cryptocurrency | ||
- blockchain | ||
|
||
sources: | ||
- https://github.com/dysnix/charts | ||
|
||
maintainers: | ||
- name: VladStarr | ||
email: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Bor RPC can be accessed via port {{ .Values.services.rpc.http.port }} on the following DNS name from within your cluster: | ||
{{ include "bor.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local | ||
|
||
To connect to Bor RPC: | ||
|
||
1. Forward the port of the pod: | ||
|
||
$ kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bor.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath='{ .items[0].metadata.name }') {{ .Values.services.rpc.http.port }} | ||
|
||
2. Connect using the bor cli: | ||
|
||
$ bor attach http://{{ include "bor.fullname" . }}:{{ .Values.services.rpc.http.port }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "bor.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 "bor.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 "bor.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "bor.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create -}} | ||
{{ default (include "bor.fullname" .) .Values.serviceAccount.name }} | ||
{{- else -}} | ||
{{ default "default" .Values.serviceAccount.name }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "bor.labels" -}} | ||
helm.sh/chart: {{ include "bor.chart" . }} | ||
app.kubernetes.io/name: {{ include "bor.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "bor.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "bor.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- with .Values.podLabels }} | ||
{{ toYaml . | indent 0 }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Convert Golang slice to Toml array | ||
*/}} | ||
{{- define "toml.list" -}} | ||
{{- print "[" }} | ||
{{- range $idx, $element := . }} | ||
{{- if $idx }}, {{ end }} | ||
{{- $element | quote }} | ||
{{- end -}} | ||
{{ print "]" -}} | ||
{{- end }} | ||
|
||
{{/* | ||
Render Toml properties | ||
*/}} | ||
{{- define "toml.properties" -}} | ||
{{- $root := index . 0 }} | ||
{{- $context := index . 1 }} | ||
{{- range $k, $v := $root }} | ||
{{- if not (kindIs "map" $v) }} | ||
{{- if kindIs "string" $v }} | ||
{{- if contains "{{" $v }} {{- /* render templated values */}} | ||
{{- $v = tpl $v $context }} | ||
{{- if not (or (regexMatch "^[0-9]+$" $v) (regexMatch "^(true|false)$" $v)) }} | ||
{{- $v = quote $v }} | ||
{{- end }} | ||
{{- else }} | ||
{{- $v = quote $v }} | ||
{{- end }} | ||
{{- else if or (kindIs "int" $v) (kindIs "float64" $v) }} | ||
{{- $v = int $v }} | ||
{{- else if kindIs "slice" $v }} | ||
{{- $v = include "toml.list" $v }} | ||
{{- end }} | ||
{{- if contains "." $k }} | ||
{{- $k = quote $k }} | ||
{{- end }} | ||
{{ $k }} = {{ $v }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Render full Toml config including tables | ||
*/}} | ||
{{- define "toml.config" -}} | ||
{{- $context := index . 0 }} | ||
{{- $root := index . 1 }} | ||
{{- include "toml.properties" (list $root $context) }} {{- /* top-level table */}} | ||
{{- range $k, $v := $root }} | ||
{{- if kindIs "map" $v }} | ||
{{- if contains "." $k }} | ||
{{- $k = quote $k }} | ||
{{- end }} | ||
|
||
[{{ $k }}] | ||
{{- include "toml.properties" (list $v $context) }} {{- /* 1st-level table */}} | ||
{{- range $i, $j := $v }} | ||
{{- if kindIs "map" $j }} | ||
{{- if contains "." $i }} | ||
{{- $i = quote $i }} | ||
{{- end }} | ||
{{- $i = print $k "." $i }} | ||
|
||
[{{ $i }}] | ||
{{- include "toml.properties" (list $j $context) }} {{- /* 2nd-level table */}} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- define "bor.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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "bor.fullname" . }}-scripts | ||
labels: | ||
{{- include "bor.labels" . | nindent 4 }} | ||
data: | ||
check-readiness.sh: |- | ||
{{- include (print $.Template.BasePath "/scripts/_check-readiness.tpl") . | nindent 4 }} | ||
download-snapshot.sh: |- | ||
{{- include (print $.Template.BasePath "/scripts/_download-snapshot.tpl") . | nindent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "bor.fullname" . }}-config | ||
labels: | ||
{{- include "bor.labels" . | nindent 4 }} | ||
data: | ||
config.toml: |- | ||
{{- include "toml.config" (list $ .Values.config) | indent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "bor.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 "bor.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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "bor.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 "bor.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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
# Retrieving latest block timestamp | ||
get_block_timestamp() { | ||
bor attach http://localhost:{{ .Values.config.jsonrpc.http.port }} --exec "eth.getBlock(eth.blockNumber).timestamp" 2>/dev/null | ||
} | ||
|
||
if [ -z $1 ]; then | ||
echo "Usage: $0 {allowed-block-gap-in-seconds}" && exit 1 | ||
fi | ||
|
||
allowed_gap=$1 | ||
current_gap=$(expr $(date +%s) - $(get_block_timestamp)) | ||
|
||
if [ $current_gap -le $allowed_gap ]; then | ||
exit 0 | ||
else | ||
echo "Current block timestamp gap ($current_gap) is higher than allowed ($allowed_gap)" && exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if [ ! -f /data/.downloaded ]; then | ||
apt-get -y update && apt-get -y install wget | ||
wget -qO download.sh https://snapshot-download.polygon.technology/snapdown.sh | ||
sed -i 's/sudo//g' download.sh | ||
chmod +x download.sh | ||
|
||
./download.sh --network {{ .Values.config.chain }} --client bor --extract-dir /data/bor/chaindata --validate-checksum true | ||
touch /data/.downloaded | ||
else | ||
echo "Initial snapshot already downloaded, skipping." | ||
fi |
Oops, something went wrong.