Skip to content

Commit

Permalink
feat(external-node): add helm chart (#3)
Browse files Browse the repository at this point in the history
* feat(external-node): add helm chart

* change ip
  • Loading branch information
fborello-lambda authored Aug 23, 2024
1 parent e3cf6dd commit c50be63
Show file tree
Hide file tree
Showing 12 changed files with 959 additions and 0 deletions.
23 changes: 23 additions & 0 deletions infra/helm-charts/external-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 infra/helm-charts/external-node/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: external-node
description: A Helm chart for Kubernetes

# 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: "1.16.0"
19 changes: 19 additions & 0 deletions infra/helm-charts/external-node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# How

To install the helm chart(deploy all the manifests):

```sh
helm install external-node . --values values.yaml
```

If there are some changes, you can use `upgrade`. Helm will change only what it needs:

```sh
helm upgrade external-node . --values values.yaml --debug
```

If you want to delete the installed helm chart use `delete`:

```sh
helm delete external-node
```
13 changes: 13 additions & 0 deletions infra/helm-charts/external-node/templates/backendconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- range .Values.nodename }}
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: {{.}}-hc-config
spec:
healthCheck:
checkIntervalSec: 15
port: 3071
type: HTTP
requestPath: /health
---
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: html
data:
index.html: |
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error Grafana</title>
</head>
<body>
<h2>Error</h2>
</body>
</html>
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: default-backend-ingress-grafana
spec:
selector:
matchLabels:
app: default-backend-ingress-grafana
template:
metadata:
labels:
app: default-backend-ingress-grafana

spec:
containers:
- name: default-backend-ingress-grafana
image: nginx:latest
resources:
limits:
memory: "128Mi"
cpu: "500m"
volumeMounts:
- name: html-volume
mountPath: /usr/share/nginx/html/index.html
subPath: index.html
ports:
- containerPort: 80
volumes:
- name: html-volume
configMap:
name: html
---
apiVersion: v1
kind: Service
metadata:
name: default-backend-ingress-grafana-service
spec:
type: NodePort
selector:
app: default-backend-ingress-grafana
ports:
- port: 80
targetPort: 80
protocol: TCP
91 changes: 91 additions & 0 deletions infra/helm-charts/external-node/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{{- range .Values.nodename }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.}}
namespace: {{$.Values.namespace}}
spec:
replicas: 1
selector:
matchLabels:
app: {{.}}
template:
metadata:
labels:
app: {{.}}
spec:
{{- $fullUrl := printf "%s/%s" $.Values.deployment.env.DATABASE_URL . -}}
{{- $parsedUrl := (urlParse $fullUrl) -}}
{{- $parsedHost := (regexSplit ":" $parsedUrl.host -1) -}}
{{- $parsedCredentials := (regexSplit ":" $parsedUrl.userinfo -1) -}}

{{- if eq $parsedUrl.scheme "postgres" }}
{{- else }}
{{- fail (printf "Invalid: %s" $fullUrl) }}
{{- end }}

initContainers:
- name: {{.}}-drop-db
image: postgres:14
env:
- name: PGUSER
value: {{index $parsedCredentials 0}}
- name: PGPASSWORD
value: {{index $parsedCredentials 1}}
- name: POSTGRES_DB
value: {{$parsedUrl.path | trimAll "/"}}
- name: PGHOST
value: {{index $parsedHost 0}}
- name: PGPORT
value: "{{index $parsedHost 1}}"
- name: MAIN_DB
value: {{$parsedUrl.scheme}}
command: ["sh", "-c", "psql -d $MAIN_DB -c \"DROP DATABASE IF EXISTS \\\"$POSTGRES_DB\\\";\" "]

containers:
- name: {{.}}
image: matterlabs/external-node:v24.7.0-alpha-linux-amd64
ports:
- containerPort: 3050
- containerPort: 3051
- containerPort: 3071
- containerPort: 3312
readinessProbe:
httpGet:
path: /health
port: 3071
env:
- name: EN_HTTP_PORT
value: "3050"
- name: EN_WS_PORT
value: "3051"
- name: EN_HEALTHCHECK_PORT
value: "3071"
- name: EN_PROMETHEUS_PORT
value: "3312"
- name: DATABASE_URL
value: "{{$.Values.deployment.env.DATABASE_URL}}/{{.}}"
- name: DATABASE_POOL_SIZE
value: "10"
- name: EN_ETH_CLIENT_URL
value: {{$.Values.deployment.env.EN_ETH_CLIENT_URL}}
- name: EN_MAIN_NODE_URL
value: {{$.Values.deployment.env.EN_MAIN_NODE_URL}}
- name: EN_L1_CHAIN_ID
value: "{{$.Values.deployment.env.EN_L1_CHAIN_ID}}"
- name: EN_L2_CHAIN_ID
value: "{{$.Values.deployment.env.EN_L2_CHAIN_ID}}"
- name: EN_STATE_CACHE_PATH
value: "./db/ext-node/state_keeper"
- name: EN_MERKLE_TREE_PATH
value: "./db/ext-node/lightweight"
- name: EN_SNAPSHOTS_RECOVERY_ENABLED
value: "true"
- name: EN_SNAPSHOTS_OBJECT_STORE_BUCKET_BASE_URL
value: {{$.Values.deployment.env.EN_SNAPSHOTS_OBJECT_STORE_BUCKET_BASE_URL}}
- name: EN_SNAPSHOTS_OBJECT_STORE_MODE
value: "GCSAnonymousReadOnly"
- name: RUST_LOG
value: "warn,zksync=info,zksync_core::metadata_calculator=debug,zksync_state=debug,zksync_utils=debug,zksync_web3_decl::client=error"
---
{{- end }}
Loading

0 comments on commit c50be63

Please sign in to comment.