Skip to content

Commit

Permalink
Feature: Add graph-node to charts. (#1489)
Browse files Browse the repository at this point in the history
Added a `graph-node` helm chart to the charts.

---------

Co-authored-by: Jordan Oroshiba <[email protected]>
  • Loading branch information
sambukowski and joroshiba authored Sep 27, 2024
1 parent 790af57 commit 77c70bf
Show file tree
Hide file tree
Showing 13 changed files with 497 additions and 0 deletions.
10 changes: 10 additions & 0 deletions charts/deploy.just
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ deploy-metrics-server:
deploy-ingress-controller:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml

deploy-graph-node namespace=defaultNamespace: (deploy-chart "graph-node" namespace)
delete-graph-node namespace=defaultNamespace: (delete-chart "graph-node" namespace)
delete-graph-node-pvc namespace=defaultNamespace:
kubectl delete pvc -n namespace \
-l 'app.kubernetes.io/instance=graph-node-chart' \
-o name | xargs -r kubectl delete -n ${namespace} && \
kubectl delete pvc -n namespace \
-l 'app.kubernetes.io/managed-by=Helm' \
--field-selector 'metadata.name in (ipfs-pvc,postgres-pvc)'

[private]
deploy-celestia-local namespace=defaultNamespace: (deploy-chart "celestia-local" namespace)

Expand Down
23 changes: 23 additions & 0 deletions charts/graph-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/
13 changes: 13 additions & 0 deletions charts/graph-node/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
name: graph-node
description: A Helm chart for Graph Node deployment
version: 0.1.0
appVersion: "0.0.1"

maintainers:
- name: wafflesvonmaple
url: astria.org
- name: quasystaty1
url: astria.org
- name: joroshiba
url: astria.org
14 changes: 14 additions & 0 deletions charts/graph-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- define "graphnode.name" -}}
{{ .Release.Name }}
{{- end }}

{{- define "graphnode.fullname" -}}
{{ include "graphnode.name" . }}-graph-node
{{- end }}

{{/*
Namepsace to deploy elements into.
*/}}
{{- define "graphnode.namespace" -}}
{{- default .Release.Namespace .Values.global.namespaceOverride | trunc 63 | trimSuffix "-" -}}
{{- end }}
13 changes: 13 additions & 0 deletions charts/graph-node/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: graph-node-config
namespace: {{ .Values.global.namespaceOverride | default .Release.Namespace }}
data:
postgres_host: postgres
postgres_user: {{ .Values.postgres.user }}
postgres_pass: {{ .Values.postgres.password }}
postgres_db: {{ .Values.postgres.database }}
ipfs: ipfs:{{ .Values.ipfs.ports.api }}
ethereum: {{ .Values.environment.ethereumNetwork }}:{{ .Values.environment.ethereumRPC }}
GRAPH_LOG: info
28 changes: 28 additions & 0 deletions charts/graph-node/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: graph-node
namespace: {{ .Values.global.namespaceOverride | default .Release.Namespace }}
spec:
replicas: {{ .Values.graphNode.replicas }}
selector:
matchLabels:
app: graph-node
template:
metadata:
labels:
app: graph-node
spec:
containers:
- name: graph-node
envFrom:
- configMapRef:
name: graph-node-config
image: {{ .Values.graphNode.image }}:{{ .Values.graphNode.tag }}
ports:
- containerPort: {{ .Values.graphNode.ports.http }}
- containerPort: {{ .Values.graphNode.ports.jsonRpc }}
- containerPort: {{ .Values.graphNode.ports.indexNode }}
- containerPort: {{ .Values.graphNode.ports.metrics }}
- containerPort: {{ .Values.graphNode.ports.subgraphMetrics }}

35 changes: 35 additions & 0 deletions charts/graph-node/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: graph-node
annotations:
{{- with .Values.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
rules:
- host: {{ .Values.ingress.host | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: graph-node
port:
number: {{ .Values.graphNode.ports.http }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
36 changes: 36 additions & 0 deletions charts/graph-node/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if and .Values.serviceMonitor.enabled (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: graph-node-metrics
labels:
app: graph-node
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
jobLabel: graph-node-metrics
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: graph-node
endpoints:
- port: metrics
path: /metrics
{{- with .Values.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
- port: subgraph-metrics
path: /metrics
{{- with .Values.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- end }}
50 changes: 50 additions & 0 deletions charts/graph-node/templates/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: v1
kind: Service
metadata:
name: graph-node
namespace: {{ include "graphnode.namespace" . }}
spec:
selector:
app: graph-node
ports:
- name: http
port: {{ .Values.graphNode.ports.http }}
targetPort: {{ .Values.graphNode.ports.http }}
- name: json-rpc
port: {{ .Values.graphNode.ports.jsonRpc }}
targetPort: {{ .Values.graphNode.ports.jsonRpc }}
- name: index-node
port: {{ .Values.graphNode.ports.indexNode }}
targetPort: {{ .Values.graphNode.ports.indexNode }}
- name: metrics
port: {{ .Values.graphNode.ports.metrics }}
targetPort: {{ .Values.graphNode.ports.metrics }}
- name: subgraph-metrics
port: {{ .Values.graphNode.ports.subgraphMetrics }}
targetPort: {{ .Values.graphNode.ports.subgraphMetrics }}
---
apiVersion: v1
kind: Service
metadata:
name: ipfs
namespace: {{ include "graphnode.namespace" . }}
spec:
selector:
app: ipfs
ports:
- name: api
port: {{ .Values.ipfs.ports.api }}
targetPort: {{ .Values.ipfs.ports.api }}
---
apiVersion: v1
kind: Service
metadata:
name: postgres
namespace: {{ include "graphnode.namespace" . }}
spec:
selector:
app: postgres
ports:
- name: postgres
port: {{ .Values.postgres.ports.postgres }}
targetPort: {{ .Values.postgres.ports.postgres }}
88 changes: 88 additions & 0 deletions charts/graph-node/templates/statefulsets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ipfs
namespace: {{ include "graphnode.namespace" . }}
spec:
replicas: 1
selector:
matchLabels:
app: ipfs
template:
metadata:
labels:
app: ipfs
spec:
containers:
- name: ipfs
image: {{ .Values.ipfs.image }}:{{ .Values.ipfs.tag }}
ports:
- containerPort: {{ .Values.ipfs.ports.api }}
volumeMounts:
- name: ipfs-storage
mountPath: /data/ipfs
volumes:
- name: ipfs-storage
{{- if .Values.ipfs.storage.enabled }}
persistentVolumeClaim:
claimName: ipfs-pvc
{{- else }}
emptyDir: {}
{{- end }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
namespace: {{ include "graphnode.namespace" . }}
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
securityContext:
fsGroup: 999
containers:
- name: postgres
image: {{ .Values.postgres.image }}:{{ .Values.postgres.tag }}
ports:
- containerPort: {{ .Values.postgres.ports.postgres }}
env:
- name: POSTGRES_USER
value: {{ .Values.postgres.user }}
- name: POSTGRES_PASSWORD
value: {{ .Values.postgres.password }}
- name: POSTGRES_DB
value: {{ .Values.postgres.database }}
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
- name: POSTGRES_INITDB_ARGS
value: "--lc-collate=C --lc-ctype=C --encoding=UTF8"
securityContext:
runAsUser: 999
runAsGroup: 999
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data
readinessProbe:
exec:
command: ["pg_isready", "-U", "{{ .Values.postgres.user }}"]
initialDelaySeconds: 10
periodSeconds: 5
resources:
requests:
cpu: 100m
memory: 256Mi
volumes:
- name: postgres-storage
{{- if .Values.postgres.storage.enabled }}
persistentVolumeClaim:
claimName: postgres-pvc
{{- else }}
emptyDir: {}
{{- end }}
13 changes: 13 additions & 0 deletions charts/graph-node/templates/storageclasses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{/* We only want to create a storage class if we are local. */}}
{{/* For production, you need to create a StorageClass on GKE. */}}
{{- if or (and .Values.ipfs.storage.enabled .Values.ipfs.storage.local) (and .Values.postgres.storage.enabled .Values.postgres.storage.local) }}
{{- range $key, $value := .Values.storage.entities }}
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: {{ include "graphnode.name" $ }}-{{ $value.persistentVolumeName }}-graph-node-local
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Retain
{{- end }}
{{- end }}
Loading

0 comments on commit 77c70bf

Please sign in to comment.