Skip to content

Commit db6ed13

Browse files
committed
Add block explorer to net up --kubernetes
1 parent 4b8ce28 commit db6ed13

File tree

15 files changed

+675
-93
lines changed

15 files changed

+675
-93
lines changed

docker/Dockerfile.indexer-test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ARG binaries=
2525
ARG copy=${binaries:+_copy}
2626
# ARG build_flag=--release
2727
ARG build_folder=debug
28-
ARG build_features=metrics
28+
ARG build_features=scylladb,metrics
2929
ARG rustflags="-C force-frame-pointers=yes"
3030

3131
FROM rust:1.74-slim-bookworm AS builder
@@ -84,11 +84,11 @@ RUN cargo build ${build_flag:+"$build_flag"} \
8484
RUN cargo build ${build_flag:+"$build_flag"} \
8585
-p linera-storage-service
8686

87-
# Build block exporter with metrics feature only
87+
# Build block exporter with scylladb and metrics features
8888
RUN cargo build ${build_flag:+"$build_flag"} \
8989
-p linera-service \
9090
--bin linera-exporter \
91-
--features metrics
91+
--features $build_features
9292

9393
# Build indexer binaries (no scylladb needed for testing)
9494
RUN cargo build ${build_flag:+"$build_flag"} \
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
id = {{ .exporterId }}
2+
3+
metrics_port = {{ .Values.blockExporter.metricsPort }}
4+
5+
[service_config]
6+
host = "0.0.0.0"
7+
port = {{ .Values.blockExporter.port }}
8+
9+
[destination_config]
10+
committee_destination = true
11+
12+
[[destination_config.destinations]]
13+
file_name = "/data/linera-exporter.log"
14+
kind = "Logging"
15+
16+
[[destination_config.destinations]]
17+
kind = "Indexer"
18+
tls = "ClearText"
19+
port = {{ .Values.indexer.port }}
20+
endpoint = "linera-indexer"
21+
22+
[limits]
23+
persistence_period_ms = 299000
24+
work_queue_size = 256
25+
blob_cache_weight_mb = 1024
26+
blob_cache_items_capacity = 8192
27+
block_cache_weight_mb = 1024
28+
block_cache_items_capacity = 8192
29+
auxiliary_cache_size_mb = 1024
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{{- if .Values.blockExporter.enabled }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: block-exporter-config
6+
data:
7+
{{- range $i := until (int .Values.blockExporter.replicas) }}
8+
exporter-config-{{ $i }}.toml: |
9+
{{ tpl ($.Files.Get "exporter-config.toml.tpl") (dict "exporterId" $i "Values" $.Values) | indent 4 }}
10+
{{- end }}
11+
---
12+
apiVersion: v1
13+
kind: Service
14+
metadata:
15+
name: linera-block-exporter
16+
labels:
17+
app: linera-block-exporter
18+
spec:
19+
ports:
20+
- port: {{ .Values.blockExporter.port }}
21+
name: http
22+
- port: {{ .Values.blockExporter.metricsPort }}
23+
name: metrics
24+
selector:
25+
app: linera-block-exporter
26+
---
27+
apiVersion: apps/v1
28+
kind: StatefulSet
29+
metadata:
30+
name: linera-block-exporter
31+
spec:
32+
serviceName: linera-block-exporter
33+
replicas: {{ .Values.blockExporter.replicas }}
34+
selector:
35+
matchLabels:
36+
app: linera-block-exporter
37+
template:
38+
metadata:
39+
labels:
40+
app: linera-block-exporter
41+
spec:
42+
{{- if eq .Values.environment "GCP" }}
43+
nodeSelector:
44+
workload: system
45+
tolerations:
46+
- key: system
47+
value: "true"
48+
effect: NoSchedule
49+
{{- end }}
50+
initContainers:
51+
- name: config-selector
52+
image: busybox
53+
command:
54+
- sh
55+
- -c
56+
- |
57+
ORDINAL=$(echo $HOSTNAME | sed 's/.*-//')
58+
cp /configmap/exporter-config-${ORDINAL}.toml /config/exporter-config.toml
59+
volumeMounts:
60+
- name: configmap
61+
mountPath: /configmap
62+
- name: config
63+
mountPath: /config
64+
containers:
65+
- name: linera-block-exporter
66+
image: {{ .Values.indexer.image }}
67+
imagePullPolicy: {{ .Values.indexer.imagePullPolicy }}
68+
command:
69+
- "./linera-exporter"
70+
- "--storage"
71+
- "{{ .Values.storage }}"
72+
- "--config-path"
73+
- "/config/exporter-config.toml"
74+
- "--metrics-port"
75+
- "{{ .Values.blockExporter.metricsPort }}"
76+
ports:
77+
- containerPort: {{ .Values.blockExporter.port }}
78+
name: http
79+
- containerPort: {{ .Values.blockExporter.metricsPort }}
80+
name: metrics
81+
env:
82+
- name: RUST_LOG
83+
value: {{ .Values.blockExporter.logLevel }}
84+
- name: RUST_BACKTRACE
85+
value: "1"
86+
volumeMounts:
87+
- name: config
88+
mountPath: /config
89+
readOnly: true
90+
- name: exporter-data
91+
mountPath: /data
92+
livenessProbe:
93+
tcpSocket:
94+
port: {{ .Values.blockExporter.port }}
95+
initialDelaySeconds: 30
96+
periodSeconds: 10
97+
readinessProbe:
98+
tcpSocket:
99+
port: {{ .Values.blockExporter.port }}
100+
initialDelaySeconds: 5
101+
periodSeconds: 5
102+
volumes:
103+
- name: configmap
104+
configMap:
105+
name: block-exporter-config
106+
- name: config
107+
emptyDir: {}
108+
- name: exporter-data
109+
persistentVolumeClaim:
110+
claimName: exporter-data
111+
---
112+
apiVersion: v1
113+
kind: PersistentVolumeClaim
114+
metadata:
115+
name: exporter-data
116+
spec:
117+
accessModes:
118+
- ReadWriteOnce
119+
resources:
120+
requests:
121+
storage: {{ .Values.blockExporter.storageSize }}
122+
{{- if .Values.blockExporter.serviceMonitor.enabled }}
123+
---
124+
apiVersion: monitoring.coreos.com/v1
125+
kind: ServiceMonitor
126+
metadata:
127+
name: linera-block-exporter
128+
labels:
129+
app: linera-block-exporter
130+
spec:
131+
selector:
132+
matchLabels:
133+
app: linera-block-exporter
134+
endpoints:
135+
- port: metrics
136+
path: /metrics
137+
{{- end }}
138+
{{- end }}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{{- if .Values.explorer.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: linera-explorer
6+
labels:
7+
app: linera-explorer
8+
spec:
9+
ports:
10+
- port: {{ .Values.explorer.frontendPort }}
11+
name: frontend
12+
- port: {{ .Values.explorer.apiPort }}
13+
name: api
14+
selector:
15+
app: linera-explorer
16+
---
17+
apiVersion: apps/v1
18+
kind: Deployment
19+
metadata:
20+
name: linera-explorer
21+
spec:
22+
replicas: 1
23+
selector:
24+
matchLabels:
25+
app: linera-explorer
26+
template:
27+
metadata:
28+
labels:
29+
app: linera-explorer
30+
spec:
31+
{{- if eq .Values.environment "GCP" }}
32+
nodeSelector:
33+
workload: system
34+
tolerations:
35+
- key: system
36+
value: "true"
37+
effect: NoSchedule
38+
{{- end }}
39+
containers:
40+
- name: linera-explorer
41+
image: {{ .Values.explorer.image }}
42+
imagePullPolicy: {{ .Values.explorer.imagePullPolicy }}
43+
ports:
44+
- containerPort: {{ .Values.explorer.frontendPort }}
45+
name: frontend
46+
- containerPort: {{ .Values.explorer.apiPort }}
47+
name: api
48+
env:
49+
- name: NODE_ENV
50+
value: "production"
51+
- name: DB_PATH
52+
value: "/data/indexer.db"
53+
- name: EXPLORER_FRONTEND_PORT
54+
value: "{{ .Values.explorer.frontendPort }}"
55+
- name: EXPLORER_API_PORT
56+
value: "{{ .Values.explorer.apiPort }}"
57+
- name: LOG_LEVEL
58+
value: {{ .Values.explorer.logLevel }}
59+
volumeMounts:
60+
- name: indexer-data
61+
mountPath: /data
62+
readOnly: true
63+
livenessProbe:
64+
httpGet:
65+
path: /api/health
66+
port: {{ .Values.explorer.apiPort }}
67+
initialDelaySeconds: 30
68+
periodSeconds: 30
69+
readinessProbe:
70+
httpGet:
71+
path: /api/health
72+
port: {{ .Values.explorer.apiPort }}
73+
initialDelaySeconds: 10
74+
periodSeconds: 10
75+
volumes:
76+
- name: indexer-data
77+
persistentVolumeClaim:
78+
claimName: indexer-data
79+
{{- if .Values.explorer.ingress.enabled }}
80+
---
81+
apiVersion: networking.k8s.io/v1
82+
kind: Ingress
83+
metadata:
84+
name: linera-explorer
85+
labels:
86+
app: linera-explorer
87+
{{- with .Values.explorer.ingress.annotations }}
88+
annotations:
89+
{{- toYaml . | nindent 4 }}
90+
{{- end }}
91+
spec:
92+
{{- if .Values.explorer.ingress.tls }}
93+
tls:
94+
{{- range .Values.explorer.ingress.tls }}
95+
- hosts:
96+
{{- range .hosts }}
97+
- {{ . | quote }}
98+
{{- end }}
99+
secretName: {{ .secretName }}
100+
{{- end }}
101+
{{- end }}
102+
rules:
103+
{{- range .Values.explorer.ingress.hosts }}
104+
- host: {{ .host | quote }}
105+
http:
106+
paths:
107+
{{- range .paths }}
108+
- path: {{ .path }}
109+
pathType: {{ .pathType }}
110+
backend:
111+
service:
112+
name: linera-explorer
113+
port:
114+
number: {{ $.Values.explorer.frontendPort }}
115+
{{- end }}
116+
{{- end }}
117+
{{- end }}
118+
{{- end }}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{{- if .Values.indexer.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: linera-indexer
6+
labels:
7+
app: linera-indexer
8+
spec:
9+
ports:
10+
- port: {{ .Values.indexer.port }}
11+
name: grpc
12+
selector:
13+
app: linera-indexer
14+
---
15+
apiVersion: apps/v1
16+
kind: Deployment
17+
metadata:
18+
name: linera-indexer
19+
spec:
20+
replicas: 1
21+
selector:
22+
matchLabels:
23+
app: linera-indexer
24+
template:
25+
metadata:
26+
labels:
27+
app: linera-indexer
28+
spec:
29+
{{- if eq .Values.environment "GCP" }}
30+
nodeSelector:
31+
workload: system
32+
tolerations:
33+
- key: system
34+
value: "true"
35+
effect: NoSchedule
36+
{{- end }}
37+
containers:
38+
- name: linera-indexer
39+
image: {{ .Values.indexer.image }}
40+
imagePullPolicy: {{ .Values.indexer.imagePullPolicy }}
41+
command:
42+
- "./linera-indexer-grpc"
43+
- "--port"
44+
- "{{ .Values.indexer.port }}"
45+
- "--database-path"
46+
- "{{ .Values.indexer.databasePath }}"
47+
ports:
48+
- containerPort: {{ .Values.indexer.port }}
49+
name: grpc
50+
env:
51+
- name: RUST_LOG
52+
value: {{ .Values.indexer.logLevel }}
53+
- name: RUST_BACKTRACE
54+
value: "1"
55+
volumeMounts:
56+
- name: indexer-data
57+
mountPath: /data
58+
livenessProbe:
59+
tcpSocket:
60+
port: {{ .Values.indexer.port }}
61+
initialDelaySeconds: 30
62+
periodSeconds: 10
63+
readinessProbe:
64+
tcpSocket:
65+
port: {{ .Values.indexer.port }}
66+
initialDelaySeconds: 5
67+
periodSeconds: 5
68+
volumes:
69+
- name: indexer-data
70+
persistentVolumeClaim:
71+
claimName: indexer-data
72+
---
73+
apiVersion: v1
74+
kind: PersistentVolumeClaim
75+
metadata:
76+
name: indexer-data
77+
spec:
78+
accessModes:
79+
- ReadWriteOnce
80+
resources:
81+
requests:
82+
storage: {{ .Values.indexer.storageSize }}
83+
{{- end }}

0 commit comments

Comments
 (0)