Skip to content

Commit

Permalink
pvc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sambukowski committed Sep 26, 2024
1 parent 6ace483 commit 2591c67
Show file tree
Hide file tree
Showing 9 changed files with 232 additions and 119 deletions.
13 changes: 10 additions & 3 deletions charts/graph-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{{- define "graph-node.name" -}}
{{- define "graphnode.name" -}}
{{ .Release.Name }}
{{- end }}

{{- define "graph-node.fullname" -}}
{{ include "graph-node.name" . }}-graph-node
{{- 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 }}
46 changes: 23 additions & 23 deletions charts/graph-node/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ spec:
app: graph-node
spec:
containers:
- name: graph-node
image: {{ .Values.graphNode.image }}:{{ .Values.graphNode.tag }}
ports:
- containerPort: {{ .Values.graphNode.ports.http | default 8000 }}
- containerPort: {{ .Values.graphNode.ports.jsonRpc | default 8001 }}
- containerPort: {{ .Values.graphNode.ports.indexNode | default 8020 }}
- containerPort: {{ .Values.graphNode.ports.metrics | default 8030 }}
- containerPort: {{ .Values.graphNode.ports.subgraphMetrics | default 8040 }}
env:
- name: postgres_host
value: postgres
- name: postgres_user
value: {{ .Values.postgres.user }}
- name: postgres_pass
value: {{ .Values.postgres.password }}
- name: postgres_db
value: {{ .Values.postgres.database }}
- name: ipfs
value: ipfs:5001
- name: ethereum
value: {{ .Values.environment.ethereumNetwork }}:{{ .Values.environment.ethereumRPC }}
- name: GRAPH_LOG
value: info
- name: graph-node
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 }}
env:
- name: postgres_host
value: postgres
- name: postgres_user
value: {{ .Values.postgres.user }}
- name: postgres_pass
value: {{ .Values.postgres.password }}
- name: postgres_db
value: {{ .Values.postgres.database }}
- name: ipfs
value: ipfs:{{ .Values.ipfs.ports.api }}
- name: ethereum
value: {{ .Values.environment.ethereumNetwork }}:{{ .Values.environment.ethereumRPC }}
- name: GRAPH_LOG
value: info
2 changes: 1 addition & 1 deletion charts/graph-node/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
service:
name: graph-node
port:
number: {{ .Values.graphNode.ports.http | default 8000 }}
number: {{ .Values.graphNode.ports.http }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
Expand Down
25 changes: 0 additions & 25 deletions charts/graph-node/templates/persistent-volume-claims.yaml

This file was deleted.

37 changes: 17 additions & 20 deletions charts/graph-node/templates/services.yaml
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@
---
apiVersion: v1
kind: Service
metadata:
name: graph-node
namespace: {{ .Values.global.namespaceOverride | default .Release.Namespace }}
namespace: {{ include "graphnode.namespace" . }}
spec:
selector:
app: graph-node
ports:
- name: http
port: {{ .Values.graphNode.ports.http | default 8000 }}
targetPort: {{ .Values.graphNode.ports.http | default 8000 }}
port: {{ .Values.graphNode.ports.http }}
targetPort: {{ .Values.graphNode.ports.http }}
- name: json-rpc
port: {{ .Values.graphNode.ports.jsonRpc | default 8001 }}
targetPort: {{ .Values.graphNode.ports.jsonRpc | default 8001 }}
port: {{ .Values.graphNode.ports.jsonRpc }}
targetPort: {{ .Values.graphNode.ports.jsonRpc }}
- name: index-node
port: {{ .Values.graphNode.ports.indexNode | default 8020 }}
targetPort: {{ .Values.graphNode.ports.indexNode | default 8020 }}
port: {{ .Values.graphNode.ports.indexNode }}
targetPort: {{ .Values.graphNode.ports.indexNode }}
- name: metrics
port: {{ .Values.graphNode.ports.metrics | default 8030 }}
targetPort: {{ .Values.graphNode.ports.metrics | default 8030 }}
port: {{ .Values.graphNode.ports.metrics }}
targetPort: {{ .Values.graphNode.ports.metrics }}
- name: subgraph-metrics
port: {{ .Values.graphNode.ports.subgraphMetrics | default 8040 }}
targetPort: {{ .Values.graphNode.ports.subgraphMetrics | default 8040 }}

port: {{ .Values.graphNode.ports.subgraphMetrics }}
targetPort: {{ .Values.graphNode.ports.subgraphMetrics }}
---
apiVersion: v1
kind: Service
metadata:
name: ipfs
namespace: {{ .Values.global.namespaceOverride | default .Release.Namespace }}
namespace: {{ include "graphnode.namespace" . }}
spec:
selector:
app: ipfs
ports:
- name: api
port: {{ .Values.ipfs.ports.api | default 5001 }}
targetPort: {{ .Values.ipfs.ports.api | default 5001 }}

port: {{ .Values.ipfs.ports.api }}
targetPort: {{ .Values.ipfs.ports.api }}
---
apiVersion: v1
kind: Service
metadata:
name: postgres
namespace: {{ .Values.global.namespaceOverride | default .Release.Namespace }}
namespace: {{ include "graphnode.namespace" . }}
spec:
selector:
app: postgres
ports:
- name: postgres
port: {{ .Values.postgres.ports.postgres | default 5432 }}
targetPort: {{ .Values.postgres.ports.postgres | default 5432 }}
port: {{ .Values.postgres.ports.postgres }}
targetPort: {{ .Values.postgres.ports.postgres }}
99 changes: 53 additions & 46 deletions charts/graph-node/templates/statefulsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ipfs
namespace: {{ .Values.global.namespaceOverride | default .Release.Namespace }}
namespace: {{ include "graphnode.namespace" . }}
spec:
replicas: 1
selector:
Expand All @@ -14,24 +14,27 @@ spec:
app: ipfs
spec:
containers:
- name: ipfs
image: {{ .Values.ipfs.image }}:{{ .Values.ipfs.tag }}
ports:
- containerPort: {{ .Values.ipfs.ports.api | default 5001 }}
volumeMounts:
- name: ipfs-storage
mountPath: /data/ipfs
- 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
persistentVolumeClaim:
claimName: ipfs-pvc

- name: ipfs-storage
{{- if .Values.ipfs.storage.enabled }}
persistentVolumeClaim:
claimName: ipfs-pvc
{{- else }}
emptyDir: {}
{{- end }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
namespace: {{ .Values.global.namespaceOverride | default .Release.Namespace }}
namespace: {{ include "graphnode.namespace" . }}
spec:
replicas: 1
selector:
Expand All @@ -45,37 +48,41 @@ spec:
securityContext:
fsGroup: 999
containers:
- name: postgres
image: {{ .Values.postgres.image }}:{{ .Values.postgres.tag }}
ports:
- containerPort: {{ .Values.postgres.ports.postgres | default 5432 }}
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
- 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
persistentVolumeClaim:
claimName: postgres-pvc
- 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 2591c67

Please sign in to comment.