Skip to content

Commit

Permalink
fix: Add persistent storage for aztec nodes in the spartan cluster (#…
Browse files Browse the repository at this point in the history
…8923)

This PR includes two changes:
- Adds persistent storage for Aztec nodes running the Spartan cluster
- Repairs previously merged load balancer configurations

# Persistent Storage

Nodes that were previously configured with mounted volumes are now
configured to use `volumeClaimTemplates`. Rather than directly
configuring a `PersistentVolumeClaim`, a `volumeClaimTemplate` will
automatically append index suffixes when replicas increase, so that
there is not a storage conflict.

## Persistent Storage for Grafana

The currently bundles Grafana instance uses a standard
`PersistentVolumeClaim` since it is not expected to be deployed with
replicas. Grafana also has an OS-level user defined it its container,
which assumes ownership of the volume once it is mounted. To allow
remounting, the user have to be defined in the helm chart. This is done
using a `securityContext` in Grafana yaml template.

# Repaired Load Balancer Config

PR #8786 previously made network interfaces *either* internal or
external. This meant that when the network was set as public, certain
references to internal network interfaces were no longer reachable.
Specifically items that address a node port
([bootNodeURL](https://github.com/AztecProtocol/aztec-packages/blob/master/spartan/aztec-network/templates/_helpers.tpl#L62)
for example).

This PR adds the load balancer as a second interface, without modifying
the original.

# Testing

Code in this PR has been tested by by deployed the updated helm
configurations to the Spartan cluster using command:

`helm upgrade --install staging . -n staging --set network.public=true`

As part of this change, replica counts have also validated to work
without causing conflict for volume mounts, network interfaces or other
resources.
  • Loading branch information
stevenplatt authored Oct 2, 2024
1 parent 81a4d74 commit 23786be
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 21 deletions.
23 changes: 22 additions & 1 deletion spartan/aztec-network/templates/anvil.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,25 @@ spec:
targetPort: {{ .Values.ethereum.service.targetPort }}
{{- if and (eq .Values.ethereum.service.type "NodePort") .Values.ethereum.service.nodePort }}
nodePort: {{ .Values.ethereum.service.nodePort }}
{{- end }}
{{- end }}
---
{{if .Values.network.public }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "aztec-network.fullname" . }}-ethereum-lb
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: LoadBalancer
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: ethereum
ports:
- protocol: TCP
port: {{ .Values.ethereum.service.port }}
targetPort: {{ .Values.ethereum.service.targetPort }}
{{- if and (eq .Values.ethereum.service.type "NodePort") .Values.ethereum.service.nodePort }}
nodePort: {{ .Values.ethereum.service.nodePort }}
{{- end }}
{{ end }}
35 changes: 31 additions & 4 deletions spartan/aztec-network/templates/boot-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,19 @@ spec:
resources:
{{- toYaml .Values.bootNode.resources | nindent 12 }}
volumes:
- name: shared-volume
emptyDir: {}
- name: scripts
configMap:
name: {{ include "aztec-network.fullname" . }}-deploy-contracts-script
volumeClaimTemplates:
- metadata:
name: shared-volume
labels:
{{- include "aztec-network.labels" . | nindent 8 }}
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.bootNode.storage }}
---
apiVersion: v1
kind: Service
Expand All @@ -136,12 +144,31 @@ metadata:
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: {{if .Values.network.public }}"LoadBalancer"{{ else }}"ClusterIP"{{ end }}
type: ClusterIP
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: boot-node
ports:
- port: {{ .Values.bootNode.service.p2pPort }}
name: p2p
- port: {{ .Values.bootNode.service.nodePort }}
name: node
---
{{if .Values.network.public }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "aztec-network.fullname" . }}-boot-node-lb
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: LoadBalancer
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: boot-node
ports:
- port: {{ .Values.bootNode.service.p2pPort }}
name: p2p
- port: {{ .Values.bootNode.service.nodePort }}
name: node
name: node
{{ end }}
22 changes: 19 additions & 3 deletions spartan/aztec-network/templates/metrics.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -17,6 +16,8 @@ spec:
{{- include "aztec-network.selectorLabels" . | nindent 8 }}
app: metrics
spec:
securityContext:
fsGroup: {{ .Values.metrics.fileSystemUser }} # required for Grafana write access to storage volume
containers:
- name: otel-collector
image: "{{ .Values.images.otelCollector.image }}"
Expand Down Expand Up @@ -58,6 +59,8 @@ spec:
subPath: grafana-sources.yaml
- name: grafana-storage
mountPath: /var/lib/grafana
securityContext:
runAsUser: {{ .Values.metrics.fileSystemUser }} # required for Grafana write access to storage volume

- name: jaeger
image: "{{ .Values.images.jaeger.image }}"
Expand All @@ -68,8 +71,21 @@ spec:
configMap:
name: {{ include "aztec-network.fullname" . }}-metrics
- name: grafana-storage
emptyDir: {}

persistentVolumeClaim:
claimName: {{ include "aztec-network.fullname" . }}-grafana-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "aztec-network.fullname" . }}-grafana-pvc
labels:
app: {{ include "aztec-network.name" . }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.metrics.storage }}
---
apiVersion: v1
kind: Service
Expand Down
34 changes: 29 additions & 5 deletions spartan/aztec-network/templates/prover-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,19 @@ spec:
resources:
{{- toYaml .Values.proverNode.resources | nindent 12 }}
volumes:
- name: shared-volume
emptyDir: {}
- name: scripts
configMap:
name: {{ include "aztec-network.fullname" . }}-configure-prover-env

volumeClaimTemplates:
- metadata:
name: shared-volume
labels:
{{- include "aztec-network.labels" . | nindent 8 }}
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.proverNode.storage }}
---
apiVersion: v1
kind: ConfigMap
Expand All @@ -106,10 +113,27 @@ metadata:
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: {{if .Values.network.public }}"LoadBalancer"{{ else }}"ClusterIP"{{ end }}
type: ClusterIP
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: prover-node
ports:
- port: {{ .Values.proverNode.service.nodePort }}
name: node
---
{{if .Values.network.public }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "aztec-network.fullname" . }}-prover-node-lb
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: LoadBalancer
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: prover-node
ports:
- port: {{ .Values.proverNode.service.nodePort }}
name: node
name: node
{{ end }}
23 changes: 22 additions & 1 deletion spartan/aztec-network/templates/pxe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ metadata:
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: {{if .Values.network.public }}"LoadBalancer"{{ else }}"ClusterIP"{{ end }}
type: ClusterIP
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: pxe
Expand All @@ -77,4 +77,25 @@ spec:
{{- if and (eq .Values.pxe.service.type "NodePort") .Values.pxe.service.nodePort }}
nodePort: {{ .Values.pxe.service.nodePort }}
{{- end }}
---
{{if .Values.network.public }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "aztec-network.fullname" . }}-pxe-lb
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: LoadBalancer
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: pxe
ports:
- protocol: TCP
port: {{ .Values.pxe.service.port }}
targetPort: {{ .Values.pxe.service.targetPort }}
{{- if and (eq .Values.pxe.service.type "NodePort") .Values.pxe.service.nodePort }}
nodePort: {{ .Values.pxe.service.nodePort }}
{{- end }}
{{ end }}
{{- end }}
36 changes: 31 additions & 5 deletions spartan/aztec-network/templates/validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,19 @@ spec:
resources:
{{- toYaml .Values.validator.resources | nindent 12 }}
volumes:
- name: shared-volume
emptyDir: {}
- name: scripts
configMap:
name: {{ include "aztec-network.fullname" . }}-configure-validator-env

volumeClaimTemplates:
- metadata:
name: shared-volume
labels:
{{- include "aztec-network.labels" . | nindent 8 }}
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.validator.storage }}
---
apiVersion: v1
kind: ConfigMap
Expand All @@ -115,12 +122,31 @@ metadata:
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: {{if .Values.network.public }}"LoadBalancer"{{ else }}"ClusterIP"{{ end }}
type: ClusterIP
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: validator
ports:
- port: {{ .Values.validator.service.p2pPort }}
name: p2p
- port: {{ .Values.validator.service.nodePort }}
name: node
---
{{if .Values.network.public }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "aztec-network.fullname" . }}-validator-lb
labels:
{{- include "aztec-network.labels" . | nindent 4 }}
spec:
type: LoadBalancer
selector:
{{- include "aztec-network.selectorLabels" . | nindent 4 }}
app: validator
ports:
- port: {{ .Values.validator.service.p2pPort }}
name: p2p
- port: {{ .Values.validator.service.nodePort }}
name: node
name: node
{{ end }}
9 changes: 7 additions & 2 deletions spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ bootNode:
limits:
memory: "4Gi"
cpu: "4"
storage: "8Gi"

validator:
replicas: 0
replicas: 1
service:
p2pPort: 40400
nodePort: 8080
Expand All @@ -68,6 +69,7 @@ validator:
limits:
memory: "28Gi"
cpu: "7"
storage: "8Gi"

proverNode:
replicas: 1
Expand All @@ -84,6 +86,7 @@ proverNode:
limits:
memory: "120Gi"
cpu: "15"
storage: "8Gi"

pxe:
logLevel: "debug"
Expand Down Expand Up @@ -176,4 +179,6 @@ metrics:
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
failureThreshold: 3
storage: "8Gi"
fileSystemUser: 472

0 comments on commit 23786be

Please sign in to comment.