Skip to content

Commit

Permalink
Allow custom db configuration from secrets or parameters (#183)
Browse files Browse the repository at this point in the history
* restored SCHEMA env var
* allow to configure DB from a combination of non-sensitive plain data (host, port) and secrets read from user defined pre-existing secrets
* add sleep for node in order to allow maintenance
* split into indexer/aggregation helm params
  • Loading branch information
nemo83 committed May 7, 2024
1 parent 05e220b commit 9398845
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 27 deletions.
3 changes: 3 additions & 0 deletions deploy/cf-ledger-sync/templates/cardano-node-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
containers:
- name: cardano-node
image: "{{ .image.repository }}:{{ .image.tag }}"
{{- if .sleep | default false }}
command: ["bash", "-c", "sleep infinity"]
{{- end }}
env:
- name: RESTORE_SNAPSHOT
value: "{{ .mithrilRestore | default true }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
{{- include "cf-ledger-sync-aggregation.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
replicas: {{ .Values.aggregation.replicaCount }}
selector:
matchLabels:
{{- include "cf-ledger-sync-aggregation.selectorLabels" . | nindent 6 }}
Expand Down Expand Up @@ -56,40 +56,82 @@ spec:
- name: STORE_CARDANO_PROTOCOL_MAGIC
value: {{ .Values.storeCardanoProtocolMagic | default "1" | quote }}
{{- end }}

## Postgres
{{- with .Values.aggregation.postgres }}
- name: POSTGRES_HOST
{{- if .host }}
value: {{ .host }}
{{- else }}
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_HOST
name: {{ .secretName }}
key: {{ .hostKey }}
{{- end }}
- name: POSTGRES_PORT
{{- if .port }}
value: {{ .port | quote }}
{{- else }}
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_PORT
name: {{ .secretName }}
key: {{ .portKey }}
{{- end }}
- name: POSTGRES_DB
{{- if .db }}
value: {{ .db }}
{{- else }}
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_DB
name: {{ .secretName }}
key: {{ .dbKey }}
{{- end }}
- name: SCHEMA
value: {{ .Values.dbSchema | default "public" }}
value: {{ .dbSchema | default "aggregation" }}
- name: SPRING_DATASOURCE_URL
value: jdbc:postgresql://$(POSTGRES_HOST):$(POSTGRES_PORT)/$(POSTGRES_DB)?currentSchema=$(SCHEMA)
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_USER
name: {{ .secretName }}
key: {{ .userKey }}
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_PASSWORD
name: {{ .secretName }}
key: {{ .passwordKey }}
{{- end }}

- name: HEALTH_CHECK_ENABLED
value: "true"
- name: EVENT_TIME_THRESHOLD_IN_SECOND
value: "600"
- name: BLOCK_TIME_CHECK_ENABLED
value: "true"
- name: BLOCK_TIME_THRESHOLD_IN_SECOND
value: "180"

- name: STORE_ACCOUNT_HISTORYCLEANUPENABLED
value: {{ .Values.aggregation.store.account.history_cleanup_enabled | quote }}
- name: STORE_ACCOUNT_INITIALBALANCESNAPSHOTBLOCK
value: "0"
- name: STORE_ACCOUNT_BALANCECALCJOBBATCHSIZE
value: "500"
- name: STORE_ACCOUNT_BALANCECALCJOBPARTITIONSIZE
value: "5"
- name: STORE_ADMIN_HEALTHCHECKINTERVAL
value: "120"
- name: STORE_ADMIN_AUTORECOVERYENABLED
value: "true"
- name: STORE_EXECUTOR_BLOCKPROCESSINGTHREADS
value: {{ .Values.aggregation.store.executor.block_processing_threads | default 15 | quote }}
- name: STORE_EXECUTOR_USEVIRTUALTHREADFORBATCHPROCESSING
value: {{ .Values.aggregation.store.executor.use_virtual_thread_for_batch_processing | default "false" | quote }}
- name: STORE_EXECUTOR_ENABLEPARALLELPROCESSING
value: {{ .Values.aggregation.store.executor.enable_parallel_processing | default "true" | quote }}

resources:
{{- toYaml .Values.aggregation.resources | nindent 12 }}
strategy:
type: Recreate
{{ end }}
40 changes: 28 additions & 12 deletions deploy/cf-ledger-sync/templates/ledger-sync-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
{{- include "cf-ledger-sync.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
replicas: {{ .Values.indexer.replicaCount }}
strategy:
type: Recreate
selector:
Expand Down Expand Up @@ -77,35 +77,49 @@ spec:
value: {{ .Values.blocks.commitThreshold | default "3000" | quote }}

## Postgres
{{- with .Values.indexer.postgres }}
- name: POSTGRES_HOST
{{- if .host }}
value: {{ .host }}
{{- else }}
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_HOST
name: {{ .secretName }}
key: {{ .hostKey }}
{{- end }}
- name: POSTGRES_PORT
{{- if .port }}
value: {{ .port | quote }}
{{- else }}
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_PORT
name: {{ .secretName }}
key: {{ .portKey }}
{{- end }}
- name: POSTGRES_DB
{{- if .db }}
value: {{ .db }}
{{- else }}
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_DB
name: {{ .secretName }}
key: {{ .dbKey }}
{{- end }}
- name: SCHEMA
value: {{ .Values.dbSchema | default "public" }}
value: {{ .dbSchema | default "aggregation" }}
- name: SPRING_DATASOURCE_URL
value: jdbc:postgresql://$(POSTGRES_HOST):$(POSTGRES_PORT)/$(POSTGRES_DB)?currentSchema=$(SCHEMA)
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_USER
name: {{ .secretName }}
key: {{ .userKey }}
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secrets
key: POSTGRES_PASSWORD
name: {{ .secretName }}
key: {{ .passwordKey }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
Expand All @@ -131,3 +145,5 @@ spec:
timeoutSeconds: 1
resources:
{{- toYaml .Values.resources | nindent 12 }}
strategy:
type: Recreate
8 changes: 8 additions & 0 deletions deploy/cf-ledger-sync/values-mainnet.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
indexer:
postgres:
dbSchema: mainnet

aggregation:
postgres:
dbSchema: mainnet_aggregation

dbSchema: mainnet
network: mainnet
localCardanoNode:
Expand Down
8 changes: 8 additions & 0 deletions deploy/cf-ledger-sync/values-preprod.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
indexer:
postgres:
dbSchema: preprod

aggregation:
postgres:
dbSchema: preprod_aggregation

domain: dev-sranjan.cf-explorer-preprod.eu-west-1.metadata.dev.cf-deployments.org
dbSchema: preprod
localCardanoNode:
Expand Down
11 changes: 11 additions & 0 deletions deploy/cf-ledger-sync/values-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@ localCardanoNode:
storeCardanoHost: preview-node.play.dev.cardano.org
storeCardanoPort: 3001
storeCardanoProtocolMagic: 2

indexer:
postgres:
dbSchema: preview

aggregation:
postgres:
dbSchema: preview_aggregation
store:
executor:
use_virtual_thread_for_batch_processing: "true"
8 changes: 8 additions & 0 deletions deploy/cf-ledger-sync/values-sanchonet.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
indexer:
postgres:
dbSchema: sanchonet

aggregation:
postgres:
dbSchema: sanchonet_aggregation

dbSchema: sanchonet
network: sanchonet
localCardanoNode:
Expand Down
32 changes: 30 additions & 2 deletions deploy/cf-ledger-sync/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,42 @@ blocks:

dbSchema: public

indexer:
enabled: true
replicaCount: 1
postgres:
# dbSchema: public
secretName: postgres-secrets
hostKey: POSTGRES_HOST
portKey: POSTGRES_PORT
dbKey: POSTGRES_DB
userKey: POSTGRES_USER
passwordKey: POSTGRES_PASSWORD


aggregation:
enabled: false
replicaCount: 1
image:
repository: cardanofoundation/cf-ledger-sync-aggregation
repository: pro.registry.gitlab.metadata.dev.cf-deployments.org/base-infrastructure/docker-registry/cf-ledger-sync-aggregation
tag: "7b05530"
pullPolicy: Always
dbSchema: public
postgres:
# dbSchema: aggregation
secretName: postgres-secrets
hostKey: POSTGRES_HOST
portKey: POSTGRES_PORT
dbKey: POSTGRES_DB
userKey: POSTGRES_USER
passwordKey: POSTGRES_PASSWORD
store:
account:
history_cleanup_enabled: "true"
executor:
# Whether to use parallel processing. This greatly reduces DB computation requirements
enable_parallel_processing: "true"
# Whether to use virtual threads. True recommended for multi-CPU architecture, false for VMs
use_virtual_thread_for_batch_processing: "true"
# Number of concurrent batching threads
block_processing_threads: 15
resources: {}

0 comments on commit 9398845

Please sign in to comment.