diff --git a/charts/graph-node/Chart.lock b/charts/graph-node/Chart.lock new file mode 100644 index 00000000..032b1167 --- /dev/null +++ b/charts/graph-node/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 16.6.3 +- name: ipfs-cluster + repository: https://ethpandaops.github.io/ethereum-helm-charts + version: 0.1.14 +digest: sha256:1547f7cc44c8512eafcf92aa9cb7476c77f977dc646bb8661c9bd2bbc50aaedf +generated: "2025-04-17T12:36:59.465701+02:00" diff --git a/charts/graph-node/Chart.yaml b/charts/graph-node/Chart.yaml index 805f2f33..b221921b 100644 --- a/charts/graph-node/Chart.yaml +++ b/charts/graph-node/Chart.yaml @@ -15,7 +15,7 @@ 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.5.9 +version: 0.5.10 # 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 @@ -23,3 +23,15 @@ version: 0.5.9 # It is recommended to use it with quotes. # renovate: image=graphprotocol/graph-node appVersion: "v0.36.1" + +dependencies: + - name: postgresql + alias: postgresql + version: "16.6.3" + repository: https://charts.bitnami.com/bitnami + condition: postgresql.enabled + - name: ipfs-cluster + alias: ipfs-cluster + version: "0.1.14" + repository: https://ethpandaops.github.io/ethereum-helm-charts + condition: ipfs-cluster.enabled \ No newline at end of file diff --git a/charts/graph-node/README.md b/charts/graph-node/README.md index 78bfc98e..c43062f7 100644 --- a/charts/graph-node/README.md +++ b/charts/graph-node/README.md @@ -322,3 +322,57 @@ We welcome and appreciate your contributions! Please see the [Contributor Guide] - [Erigon](../erigon) - [Proxyd](../proxyd) + +### Dependencies + +The chart includes optional dependencies for PostgreSQL and IPFS cluster. These dependencies are enabled by default and will automatically configure Graph Node to use them. + +#### PostgreSQL Dependency + +The chart includes a PostgreSQL dependency that can be used as the primary database for Graph Node. When enabled, it will automatically configure the following environment variables: + +- `PRIMARY_SUBGRAPH_DATA_PGHOST`: Defaults to `-postgresql` +- `PRIMARY_SUBGRAPH_DATA_PGDATABASE`: Defaults to `graph-node` +- `PRIMARY_SUBGRAPH_DATA_PGUSER`: Defaults to `postgres` +- `PRIMARY_SUBGRAPH_DATA_PGPASSWORD`: Automatically retrieved from the PostgreSQL secret + +You can override any of these values by providing your own configuration in the `env` and `secretEnv` sections. + +Example configuration: +```yaml +postgresql: + enabled: true + secretName: postgresql + global: + postgresql: + auth: + database: graph-node + primary: + extendedConfiguration: | + max_connections = 10000 + resources: + limits: + cpu: 2000m + ephemeral-storage: 2Gi + memory: 4000Mi + requests: + cpu: 100m + ephemeral-storage: 50Mi + memory: 128Mi +``` + +#### IPFS Cluster Dependency + +The chart includes an IPFS cluster dependency that can be used for IPFS operations. When enabled, it will automatically configure the following environment variable: + +- `IPFS`: Defaults to `http://ipfs--ipfs-cluster:5001` + +You can override this value by providing your own configuration in the `env` section. + +Example configuration: +```yaml +ipfs-cluster: + enabled: true + p2pNodePort: + enabled: false +``` \ No newline at end of file diff --git a/charts/graph-node/charts/ipfs-cluster-0.1.14.tgz b/charts/graph-node/charts/ipfs-cluster-0.1.14.tgz new file mode 100644 index 00000000..c04981a5 Binary files /dev/null and b/charts/graph-node/charts/ipfs-cluster-0.1.14.tgz differ diff --git a/charts/graph-node/charts/postgresql-16.6.3.tgz b/charts/graph-node/charts/postgresql-16.6.3.tgz new file mode 100644 index 00000000..36ca74dc Binary files /dev/null and b/charts/graph-node/charts/postgresql-16.6.3.tgz differ diff --git a/charts/graph-node/templates/NOTES.txt b/charts/graph-node/templates/NOTES.txt index e69de29b..b4f3743f 100644 --- a/charts/graph-node/templates/NOTES.txt +++ b/charts/graph-node/templates/NOTES.txt @@ -0,0 +1,27 @@ +Thank you for installing {{ .Chart.Name }}. + +Your release is named {{ .Release.Name }}. + +To learn more about the release, try: + + $ helm status {{ .Release.Name }} -n {{ .Release.Namespace }} + $ helm get all {{ .Release.Name }} -n {{ .Release.Namespace }} + +{{ if .Values.postgresql.enabled }} +PostgreSQL has been deployed as a dependency: + - Host: {{ .Release.Name }}-postgresql + - Port: 5432 + - Database: graph-node + - Username: postgres + - Password: Retrieved from the {{ .Release.Name }}-postgresql secret +{{ end }} + +{{ if index .Values "ipfs-cluster" "enabled" }} +IPFS Cluster has been deployed as a dependency: + - Service: ipfs-{{ .Release.Name }}-ipfs-cluster + - Port: 5001 + - IPFS API: http://ipfs-{{ .Release.Name }}-ipfs-cluster:5001 +{{ end }} + +To verify the deployment: + $ kubectl get pods -l "app.kubernetes.io/instance={{ .Release.Name }}" -n {{ .Release.Namespace }} \ No newline at end of file diff --git a/charts/graph-node/templates/_helpers.tpl b/charts/graph-node/templates/_helpers.tpl index 62d73fc6..7184e999 100644 --- a/charts/graph-node/templates/_helpers.tpl +++ b/charts/graph-node/templates/_helpers.tpl @@ -5,6 +5,18 @@ Expand the name of the chart. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} +{{/* +Get PostgreSQL secret name +*/}} +{{- define "graph-node.postgresql.secretName" -}} +{{- $secretName := .Values.postgresql.auth.existingSecret -}} +{{- if not $secretName -}} + {{- printf "%s-postgresql" .Release.Name -}} +{{- else -}} + {{- $secretName -}} +{{- end -}} +{{- 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). diff --git a/charts/graph-node/templates/graph-node/all.yaml b/charts/graph-node/templates/graph-node/all.yaml index a892cd96..bf16d176 100644 --- a/charts/graph-node/templates/graph-node/all.yaml +++ b/charts/graph-node/templates/graph-node/all.yaml @@ -121,15 +121,32 @@ spec: {{- end }} {{- range $key, $val := $values.env }} - name: {{ $key | quote }} + {{- if and (eq $key "PRIMARY_SUBGRAPH_DATA_PGHOST") (empty $val) }} + value: {{ printf "%s-postgresql" $.Release.Name | quote }} + {{- else if and (eq $key "PRIMARY_SUBGRAPH_DATA_PGDATABASE") (empty $val) }} + value: "graph-node" + {{- else if and (eq $key "IPFS") (empty $val) }} + value: {{ printf "http://ipfs-%s-ipfs-cluster:5001" $.Release.Name | quote }} + {{- else }} value: {{ $val | quote }} + {{- end }} {{- end }} {{- range $key, $val := $values.secretEnv }} - name: {{ $key | quote }} + {{- if and (eq $key "PRIMARY_SUBGRAPH_DATA_PGUSER") (empty $val.secretName) }} + value: "postgres" + {{- else }} valueFrom: secretKeyRef: + {{- if and (eq $key "PRIMARY_SUBGRAPH_DATA_PGPASSWORD") (empty $val.secretName) }} + name: {{ printf "%s-postgresql" $.Release.Name | quote }} + key: "postgres-password" + {{- else }} name: {{ $val.secretName | quote }} key: {{ $val.key | quote }} + {{- end }} optional: false + {{- end }} {{- end }} command: - sh @@ -230,15 +247,32 @@ spec: {{- end }} {{- range $key, $val := $values.env }} - name: {{ $key | quote }} + {{- if and (eq $key "PRIMARY_SUBGRAPH_DATA_PGHOST") (empty $val) }} + value: {{ printf "%s-postgresql" $.Release.Name | quote }} + {{- else if and (eq $key "PRIMARY_SUBGRAPH_DATA_PGDATABASE") (empty $val) }} + value: "graph-node" + {{- else if and (eq $key "IPFS") (empty $val) }} + value: {{ printf "http://ipfs-%s-ipfs-cluster:5001" $.Release.Name | quote }} + {{- else }} value: {{ $val | quote }} + {{- end }} {{- end }} - {{- range $key, $val := $values.secretEnv }} + {{- range $key, $val := $values.secretEnv }} - name: {{ $key | quote }} + {{- if and (eq $key "PRIMARY_SUBGRAPH_DATA_PGUSER") (empty $val.secretName) }} + value: "postgres" + {{- else }} valueFrom: secretKeyRef: + {{- if and (eq $key "PRIMARY_SUBGRAPH_DATA_PGPASSWORD") (empty $val.secretName) }} + name: {{ printf "%s-postgresql" $.Release.Name | quote }} + key: "postgres-password" + {{- else }} name: {{ $val.secretName | quote }} key: {{ $val.key | quote }} + {{- end }} optional: false + {{- end }} {{- end }} ports: - name: http-query diff --git a/charts/graph-node/values.yaml b/charts/graph-node/values.yaml index 70541aff..c1461e61 100644 --- a/charts/graph-node/values.yaml +++ b/charts/graph-node/values.yaml @@ -159,12 +159,14 @@ graphNodeDefaults: # -- Environment variable defaults that come from `Secret`s for all Graph Node groups secretEnv: PRIMARY_SUBGRAPH_DATA_PGUSER: - # -- Name of the secret that contains your PG username + # -- Name of the secret that contains your PG username. + # If not specified, will use the dependency PostgreSQL user secretName: # -- Name of the data key in the secret that contains your PG username key: PRIMARY_SUBGRAPH_DATA_PGPASSWORD: - # -- Name of the secret that contains your PG password + # -- Name of the secret that contains your PG password. + # If not specified, will use the dependency PostgreSQL credentials secretName: # -- Name of the data key in the secret that contains your PG password key: @@ -278,3 +280,30 @@ configTemplate: | # There's no 'match' field, so any subgraph that hasn't matched above, matches this rule shards = ["primary"] indexers = {{ toJson .computed.indexPools.default }} + +ipfs-cluster: + enabled: false + p2pNodePort: + enabled: false + +postgresql: + enabled: false + secretName: postgresql + global: + postgresql: + auth: + database: graph-node + primary: + initdb: + args: "--lc-collate=C --lc-ctype=C --encoding=UTF8" + extendedConfiguration: | + max_connections = 10000 + resources: + limits: + cpu: 2000m + ephemeral-storage: 2Gi + memory: 4000Mi + requests: + cpu: 100m + ephemeral-storage: 50Mi + memory: 128Mi \ No newline at end of file