Skip to content

Commit

Permalink
add serviceMonitor, dashboards, serviceAccount and rbacs
Browse files Browse the repository at this point in the history
  • Loading branch information
coutug committed Sep 18, 2024
1 parent c0ed0d1 commit ebafd52
Show file tree
Hide file tree
Showing 18 changed files with 278 additions and 156 deletions.
1 change: 1 addition & 0 deletions charts/erigon/dashboards/dashboards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Put grafana dashboards as JSON files.
10 changes: 10 additions & 0 deletions charts/erigon/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "erigon.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (printf "%s-%s" (include "erigon.fullname" .) .Release.Namespace) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/erigon/templates/dashboards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- $values := $.Values.grafana }}
{{- if $values.dashboards }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "erigon.fullname" . }}-dashboards
labels:
{{- include "erigon.labels" . | nindent 4 }}
{{ $values.dashboardsConfigMapLabel }}: {{ $values.dashboardsConfigMapLabelValue | quote }}
data:
{{- (.Files.Glob "dashboards/*").AsConfig | nindent 2 }}
{{- end }}
49 changes: 49 additions & 0 deletions charts/erigon/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- if .Values.rbac.create }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "erigon.serviceAccountName" . }}
labels:
{{- include "erigon.labels" . | nindent 4 }}
rules:
{{- toYaml .Values.rbac.rules | nindent 0 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "erigon.serviceAccountName" . }}
labels:
{{- include "erigon.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "erigon.serviceAccountName" . }}
subjects:
- kind: ServiceAccount
name: {{ include "erigon.serviceAccountName" . }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "erigon.serviceAccountName" . }}
labels:
{{- include "erigon.labels" . | nindent 4 }}
rules:
{{- toYaml .Values.rbac.clusterRules | nindent 0 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "erigon.serviceAccountName" . }}
labels:
{{- include "erigon.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "erigon.serviceAccountName" . }}
subjects:
- kind: ServiceAccount
name: {{ include "erigon.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/erigon/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "erigon.serviceAccountName" . }}
labels:
{{- include "erigon.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions charts/erigon/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if $.Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "erigon.fullname" . }}
labels:
{{- include "erigon.labels" . | nindent 4 }}
spec:
jobLabel: "{{ .Release.Name }}"
selector:
matchLabels:
{{- include "erigon.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
path: {{ .Values.serviceMonitor.path }}
{{- with .Values.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
honorLabels: true
{{- if .Values.serviceMonitor.relabelings }}
relabelings:
{{- toYaml .Values.serviceMonitor.relabelings | nindent 8 }}
{{- end }}
{{- end }}
12 changes: 6 additions & 6 deletions charts/erigon/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ spec:
{{- end }}
command: ["erigon"]
args:
# Basic erigon configs
- --chain={{ .Values.erigon.chain }}
- --datadir={{ .Values.erigon.datadir }}
- --txpool.gossip.disable={{ .Values.erigon.txpool.gossip.disable }}
- --rollup.sequencerhttp={{ .Values.erigon.rollup.sequencerhttp }}
# jwt
- --authrpc.jwtsecret=/jwt/{{ .Values.erigon.jwt.existingSecret.key | default "jwtSecret" }}

# Loop through erigon.ports values to set configs
# Basic args
{{- range $key, $value := .Values.erigon.args }}
- --{{ $key }}={{ $value }}
{{- end }}

# Ports configs
{{- range $key, $value := .Values.erigon.ports }}
{{- if or $value.enabled (eq $key "authrpc") }}
{{- range $config, $configValue := $value }}
Expand Down
104 changes: 0 additions & 104 deletions charts/erigon/values.old.yaml

This file was deleted.

32 changes: 20 additions & 12 deletions charts/erigon/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ rbac:
- "list"
- "watch"

#TODO: change for smon
prometheus:
pushGateway:
# Enable pushing metrics into Prometheus via PushGateway
enabled: false
# URL to your Prometheus PushGateway server
pushGatewayUrl: null
# Enable to scrape the metrics endpoint. [prometheus-operator](https://github.com/prometheus-operator/prometheus-operator)
serviceMonitor:
enabled: false
#TODO: check for proper path
path: /metrics
labels: {}
interval:
scrapeTimeout:
relabelings: []

grafana:
# Enable creation of Grafana dashboards. [Grafana chart](https://github.com/grafana/helm-charts/tree/main/charts/grafana#grafana-helm-chart) must be configured to search this namespace, see `sidecar.dashboards.searchNamespace`
Expand All @@ -61,10 +63,6 @@ grafana:
dashboardsConfigMapLabelValue: "1"

erigon:
chain: op-mainnet
datadir: /data
txpool.gossip.disable: true
rollup.sequencerhttp: https://mainnet-sequencer.optimism.io/
# JWT for clients to authenticate with the authrpc. Specify either `existingSecret` OR `fromLiteral`.
jwt:
# Load the JWT from an existing Kubernetes Secret. Takes precedence over `fromLiteral` if set.
Expand All @@ -75,6 +73,16 @@ erigon:
key: null
# Use this literal value for the JWT
fromLiteral: null

# Basic arguments
# For op-erigon specific configurations, see: [op-erigon](https://github.com/testinprod-io/op-erigon)
args:
chain: op-mainnet
datadir: /data
txpool.gossip.disable: true
rollup.sequencerhttp: https://mainnet-sequencer.optimism.io/

# Port configurations
ports:
# authrpc is required
authrpc:
Expand Down Expand Up @@ -111,7 +119,7 @@ volumeClaimSpec:
accessModes:
- "ReadWriteOnce"
# The storage class to use when provisioning a persistent volume, will use your default storage class if not specified
storageClassName:
# storageClassName:
resources:
requests:
# The amount of disk space to provision
Expand Down
1 change: 1 addition & 0 deletions charts/geth/dashboards/dashboards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Put grafana dashboards as JSON files.
12 changes: 1 addition & 11 deletions charts/geth/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
## Geth ##
Welcome to geth, an execution engine for EVM network.

## Network Config ##
Predefined Network: {{ .Values.geth.network | default "No" }}

## For local env ##
Please run the following command to have access to the geth.
$ kubectl port-forward service/{{ .Release.Name }} {{- if .Values.geth.http.enabled }} {{ .Values.geth.http.port }}{{- end }} {{- if .Values.geth.authrpc.enabled }} {{ .Values.geth.authrpc.port }} {{- end }} {{- if .Values.geth.ws.enabled }} {{ .Values.geth.ws.port }}{{- end }} {{- if .Values.geth.metrics.enabled }} {{ .Values.geth.metrics.port }}{{- end }}

## For logs ##
$ kubectl logs -f service/{{ include "geth.fullname" . }}
Welcome to geth, an execution engine for EVM network.
10 changes: 10 additions & 0 deletions charts/geth/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@ app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "geth.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (printf "%s-%s" (include "geth.fullname" .) .Release.Namespace) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/geth/templates/dashboards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- $values := $.Values.grafana }}
{{- if $values.dashboards }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "geth.fullname" . }}-dashboards
labels:
{{- include "geth.labels" . | nindent 4 }}
{{ $values.dashboardsConfigMapLabel }}: {{ $values.dashboardsConfigMapLabelValue | quote }}
data:
{{- (.Files.Glob "dashboards/*").AsConfig | nindent 2 }}
{{- end }}
Loading

0 comments on commit ebafd52

Please sign in to comment.