Skip to content

Commit

Permalink
Merge pull request #2 from MakerOps/feature/add-graphprotocol-node
Browse files Browse the repository at this point in the history
add graphprotocol
  • Loading branch information
nickkounz authored Aug 14, 2022
2 parents 88b8c3e + 8a9d6fe commit 96e0930
Show file tree
Hide file tree
Showing 12 changed files with 800 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/helm-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Charts

on:
push:
branches:
- main

jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.8.1

- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
23 changes: 23 additions & 0 deletions charts/graphprotocol-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/
15 changes: 15 additions & 0 deletions charts/graphprotocol-node/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v2
name: graphprotocol-node
description: A Helm chart for Graph Protocol Nodes
type: application
version: 0.1.0
keywords:
- graphprotocol
- ethereum
home: https://thegraph.com/
sources:
- https://github.com/graphprotocol/graph-node
maintainers:
- email: [email protected]
name: dm3ch (original author)
appVersion: v0.24.1
42 changes: 42 additions & 0 deletions charts/graphprotocol-node/templates/_config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Config.toml based on https://github.com/graphprotocol/graph-node/blob/5613dca92213810b3cca57979f5facc2d670e34a/docs/config.md#configuring-multiple-databases
{{- define "graphprotocol-node.config" -}}
{{- $pgHost := required "postgres.host wasn't specified" .Values.postgres.host }}
{{- $pgDB := required "postgres.db wasn't specified" .Values.postgres.db }}
{{- $pgUser := required "postgres.user wasn't specified" .Values.postgres.user }}
[store]
[store.primary]
connection = "postgresql://{{ $pgUser }}:$PG_PASS@{{ $pgHost }}/{{ $pgDB }}"
weight = 1
pool_size = 10

{{- if .Values.postgres.replicaHost }}
[store.primary.replicas.replica]
connection = "postgresql://{{ $pgUser }}:$PG_PASS@{{ .Values.postgres.replicaHost }}/{{ $pgDB }}"
weight = 1
{{- end }}

[chains]
ingestor = "{{ .Values.blockIngestorNodeId }}"
{{- range $name, $conf := .Values.config.chains }}
[chains.{{ $name }}]
shard = "primary"
{{- range $conf.providers }}
[[chains.{{ $name }}.provider]]
label = {{ .label | quote }}
url = {{ .url | quote }}
features = {{ toJson .features }}
transport = {{ default "rpc" .transport | quote }}
{{- with .headers }}
[headers]
{{- range $k, $v := . }}
{{ $k }} = {{ $v | quote }}
{{- end }}
{{- end}}
{{- end }}
{{- end }}

[deployment]
[[deployment.rule]]
shard = "primary"
indexers = [ "{{ .Values.blockIngestorNodeId }}" ]
{{- end }}
52 changes: 52 additions & 0 deletions charts/graphprotocol-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "graphprotocol-node.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 "graphprotocol-node.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 "graphprotocol-node.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "graphprotocol-node.labels" -}}
helm.sh/chart: {{ include "graphprotocol-node.chart" . }}
{{ include "graphprotocol-node.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "graphprotocol-node.selectorLabels" -}}
app.kubernetes.io/name: {{ include "graphprotocol-node.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
130 changes: 130 additions & 0 deletions charts/graphprotocol-node/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "graphprotocol-node.fullname" . }}
labels:
{{- include "graphprotocol-node.labels" . | nindent 4 }}
spec:
{{/* There shouldn't be more than 1 index (ingest) graph-protocol node in installation */}}
{{- if eq .Values.role "index-node" -}}
replicas: 1
strategy:
type: Recreate
{{- else -}}
replicas: {{ .Values.replicaCount }}
strategy:
type: RollingUpdate
{{- end }}
selector:
matchLabels:
{{- include "graphprotocol-node.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/secret.yaml: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "graphprotocol-node.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: wait-for-rta
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/bin/sh", "-c"]
args:
- "until nc -z -w2 {{ .Values.postgres.host }} 5432; do echo 'waiting for postgres'; sleep 2; done;"
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{ if eq .Values.role "index-node" }}
{{- /* Index (ingest) node_id should equal BLOCK_INGESTOR env value to work in this mode */}}
- name: BLOCK_INGESTOR
value: {{ .Values.blockIngestorNodeId | quote }}
- name: node_id
value: {{ .Values.blockIngestorNodeId | quote }}
{{- else -}}
- name: node_id
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- end }}
- name: node_role
value: {{ .Values.role | quote }}
- name: GRAPH_KILL_IF_UNRESPONSIVE
value: "false"
- name: ipfs
value: {{ required "config.ipfs wasn't specified" .Values.config.ipfs | quote }}
- name: GRAPH_ALLOW_NON_DETERMINISTIC_FULLTEXT_SEARCH
value: "true"
- name: GRAPH_NODE_CONFIG
value: "/etc/graph-node/config.toml"
- name: PG_PASS
valueFrom:
secretKeyRef:
{{- if hasKey .Values.postgres.password "fromSecret" }}
name: {{ .Values.postgres.password.fromSecret.name }}
key: {{ .Values.postgres.password.fromSecret.key }}
{{- else }}
name: {{ include "graphprotocol-node.fullname" . }}
key: pgPass
{{- end }}
ports:
- name: metrics
containerPort: 8040
protocol: TCP
- name: json-rpc
containerPort: 8020
protocol: TCP
- name: graphql
containerPort: 8000
protocol: TCP
- name: graphql-ws
containerPort: 8001
protocol: TCP
{{- if eq .Values.role "index-node" }}
- name: index
containerPort: 8030
protocol: TCP
{{- end }}
livenessProbe:
httpGet:
path: /
port: metrics
readinessProbe:
httpGet:
path: /
port: metrics
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: "/etc/graph-node"
readOnly: true
volumes:
- name: config
secret:
secretName: {{ include "graphprotocol-node.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
71 changes: 71 additions & 0 deletions charts/graphprotocol-node/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "graphprotocol-node.fullname" . }}
labels:
{{- include "graphprotocol-node.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "graphprotocol-node.fullname" $ }}
port:
number: 8000
{{- end }}
{{- end }}
---
{{- if .Values.ingressWebsocket.enabled -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: {{ include "graphprotocol-node.fullname" . }}-ws
labels:
{{- include "graphprotocol-node.labels" . | nindent 4 }}
{{- with .Values.ingressWebsocket.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingressWebsocket.tls }}
tls:
{{- range .Values.ingressWebsocket.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingressWebsocket.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
serviceName: {{ include "graphprotocol-node.fullname" $ }}
servicePort: graphql-ws
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/graphprotocol-node/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "graphprotocol-node.fullname" . }}
labels:
{{- include "graphprotocol-node.labels" . | nindent 4 }}
data:
config.toml: {{ include "graphprotocol-node.config" . | b64enc }}
{{- if not (hasKey .Values.postgres.password "fromSecret") }}
pgPass: {{ .Values.postgres.password.value | b64enc | quote }}
{{- end }}
Loading

0 comments on commit 96e0930

Please sign in to comment.