Skip to content

feat(graph-node): add pg and ipfs charts as dependency #521

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions charts/graph-node/Chart.lock
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 13 additions & 1 deletion charts/graph-node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@ 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
# follow Semantic Versioning. They should reflect the version the application is using.
# 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
54 changes: 54 additions & 0 deletions charts/graph-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<release-name>-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-<release-name>-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
```
Binary file added charts/graph-node/charts/ipfs-cluster-0.1.14.tgz
Binary file not shown.
Binary file added charts/graph-node/charts/postgresql-16.6.3.tgz
Binary file not shown.
27 changes: 27 additions & 0 deletions charts/graph-node/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 12 additions & 0 deletions charts/graph-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
36 changes: 35 additions & 1 deletion charts/graph-node/templates/graph-node/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 31 additions & 2 deletions charts/graph-node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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