From 42a174d535d31bde51d89a4401029556bb5ca22d Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 23 Mar 2021 20:17:36 -0700 Subject: [PATCH 01/35] add Nomadic's and BCD tezos indexers Both indexers are able to index a private chain. BCD indexer needs private images with env variables to set the hostname for elastic/db/rabbitmq. Next release of BCD hub will have them, until then it is necessary to build your own containers: baking-bad/bcdhub#554 The indexer need to be activated in values.yaml and does not run by default. The default values.yaml has an explanation in comments. --- charts/tezos/templates/_helpers.tpl | 14 ++ charts/tezos/templates/bcd_indexer.yaml | 146 ++++++++++++++++++++ charts/tezos/templates/nomadic_indexer.yaml | 63 +++++++++ charts/tezos/values.yaml | 16 +++ config-generator/entrypoint.py | 1 + devspace.yaml | 8 ++ 6 files changed, 248 insertions(+) create mode 100644 charts/tezos/templates/bcd_indexer.yaml create mode 100644 charts/tezos/templates/nomadic_indexer.yaml diff --git a/charts/tezos/templates/_helpers.tpl b/charts/tezos/templates/_helpers.tpl index 5f8aaa689..45bf63654 100644 --- a/charts/tezos/templates/_helpers.tpl +++ b/charts/tezos/templates/_helpers.tpl @@ -52,3 +52,17 @@ {{- "" }} {{- end }} {{- end }} + +{{/* + Checks if indexer config has an indexer type and target set. + This is to make helm linter happy. + Returns the indexer type or empty string which is falsey. +*/}} +{{- define "tezos.indexer" -}} +{{- $index_config := .Values.index | default dict }} +{{- if $index_config.indexer }} +{{- $index_config.indexer }} +{{- else }} +{{- "" }} +{{- end }} +{{- end }} diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml new file mode 100644 index 000000000..a97dd7cc2 --- /dev/null +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -0,0 +1,146 @@ +{{- if eq (include "tezos.indexer" .) "bcd" }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Values.bcd_indexer_statefulset.name }} + namespace: {{ .Release.Namespace }} +spec: + podManagementPolicy: Parallel + selector: + matchLabels: + app: {{ .Values.bcd_indexer_statefulset.name }} + serviceName: tezos-node + template: + metadata: + labels: + app: {{ .Values.bcd_indexer_statefulset.name }} + appType: tezos + spec: + containers: + - image: "{{ .Values.tezos_k8s_images.bcd_api }}" + name: api + env: + - name: BCD_ENV + value: sandbox + - name: GIN_MODE + value: debug + - name: POSTGRES_USER + value: root + - name: POSTGRES_PASSWORD + value: root + - name: POSTGRES_DB + value: bcd + - name: ELASTIC_HOSTNAME + value: localhost + - name: RABBITMQ_HOSTNAME + value: localhost + - name: DB_HOSTNAME + value: 127.0.0.1 + - name: RABBITMQ_DEFAULT_USER + value: guest + - name: RABBITMQ_DEFAULT_PASS + value: guest + - name: SANDBOX_NODE_URI + value: http://{{ .Values.index.target }}:8732 + - image: "{{ .Values.tezos_k8s_images.bcd_indexer }}" + name: indexer + env: + - name: BCD_ENV + value: sandbox + - name: GIN_MODE + value: debug + - name: POSTGRES_USER + value: root + - name: POSTGRES_PASSWORD + value: root + - name: POSTGRES_DB + value: bcd + - name: ELASTIC_HOSTNAME + value: localhost + - name: RABBITMQ_HOSTNAME + value: localhost + - name: DB_HOSTNAME + value: 127.0.0.1 + - name: RABBITMQ_DEFAULT_USER + value: guest + - name: RABBITMQ_DEFAULT_PASS + value: guest + - name: SANDBOX_NODE_URI + value: http://tezos-node-0.tezos-node:8732 + - image: postgres:alpine + name: db + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: indexer-db + env: + - name: POSTGRES_USER + value: root + - name: POSTGRES_DB + value: bcd + - name: POSTGRES_PASSWORD + value: root + - image: rabbitmq:latest + name: mq + volumeMounts: + - mountPath: /var/lib/rabbitmq + name: mq-data + env: + - name: RABBITMQ_DEFAULT_USER + value: guest + - name: RABBITMQ_DEFAULT_PASS + value: guest + - image: bakingbad/bcdhub-elastic:3.4 + name: elastic + volumeMounts: + - mountPath: /usr/share/elasticsearch/data + name: esdata + env: + - name: "bootstrap.memory_lock" + value: "true" + - name: "discovery.type" + value: single-node + - name: ES_JAVA_OPTS + value: "-Xms256m -Xmx256m" + volumeClaimTemplates: + - metadata: + name: esdata + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "5Gi" + - metadata: + name: mq-data + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "5Gi" + - metadata: + name: indexer-db + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "5Gi" +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: bcd-config +data: + bcd_config.yml: |- + storage: + uri: + - http://localhost:9200 + timeout: 10 + rabbitmq: + uri: "amqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@localhost:5672/" + timeout: 10 + db: + conn_string: "host=127.0.0.1 port=5432 user=${POSTGRES_USER} dbname=${POSTGRES_DB} password=${POSTGRES_PASSWORD} sslmode=disable" + timeout: 10 +{{- end }} diff --git a/charts/tezos/templates/nomadic_indexer.yaml b/charts/tezos/templates/nomadic_indexer.yaml new file mode 100644 index 000000000..be9677973 --- /dev/null +++ b/charts/tezos/templates/nomadic_indexer.yaml @@ -0,0 +1,63 @@ +{{- if eq (include "tezos.indexer" .) "nomadic" }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Values.nomadic_indexer_statefulset.name }} + namespace: {{ .Release.Namespace }} +spec: + podManagementPolicy: Parallel + replicas: 1 + selector: + matchLabels: + app: {{ .Values.nomadic_indexer_statefulset.name }} + serviceName: tezos-node + template: + metadata: + labels: + app: {{ .Values.nomadic_indexer_statefulset.name }} + appType: tezos + spec: + initContainers: + - image: registry.gitlab.com/nomadic-labs/tezos-indexer/tezos-indexer:v9.1.0 + command: ["/bin/bash","-c"] + args: [ "/home/tezos/tezos-indexer --db-schema | tee /docker-entrypoint-initdb.d/tezos-indexer-schema.sql" ] + name: schema-extractor + volumeMounts: + - mountPath: /docker-entrypoint-initdb.d/ + name: schema-volume + containers: + - image: registry.gitlab.com/nomadic-labs/tezos-indexer/tezos-indexer:v9.1.0 + name: tezos-indexer + args: + - --debug + - --verbosity=1 + - --no-contract-balances + - --db=postgresql://localhost/tezos + - --tezos-url=http://{{ .Values.index.target }}:8732 + - image: postgres:alpine + name: postgres + volumeMounts: + - mountPath: /docker-entrypoint-initdb.d/ + name: schema-volume + - mountPath: /var/lib/postgresql/data + name: indexer-db + env: + - name: POSTGRES_USER + value: tezos + - name: POSTGRES_DB + value: tezos + - name: POSTGRES_PASSWORD + value: tezosrocks + volumes: + - emptyDir: {} + name: schema-volume + volumeClaimTemplates: + - metadata: + name: indexer-db + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "5Gi" +{{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 0b9840d14..915590129 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -20,6 +20,8 @@ tezos_k8s_images: snapshot_downloader: tezos-k8s-snapshot-downloader:dev wait_for_bootstrap: tezos-k8s-wait-for-bootstrap:dev zerotier: tezos-k8s-zerotier:dev + bcd_api: tezos-k8s-bcd-api:dev + bcd_indexer: tezos-k8s-bcd-indexer:dev # Properties that are templated in Helm template files baker_statefulset: # charts/tezos/templates/baker.yaml @@ -28,6 +30,10 @@ baker_statefulset: # charts/tezos/templates/baker.yaml regular_node_statefulset: # charts/tezos/templates/node.yaml name: tezos-node node_type: regular +nomadic_indexer_statefulset: + name: nomadic-indexer +bcd_indexer_statefulset: + name: bcd-indexer # For non-public chains the defualt mutez given to an account if the # account is not explicitly set below. @@ -177,3 +183,13 @@ protocol: # initial_endorsers: 1 # delay_per_missing_endorsement: "1" # baking_reward_per_endorsement: ["200000"] +# + +# Deploy an indexer with the chain. An indexer puts the chain +# contents in a database for efficient indexing. Most dapps need it. +# Supports two types of indexers: +# * "nomadic": Tezos nomadic indexer: https://gitlab.com/nomadic-labs/tezos-indexer +# * "bcd": Better Call Dev indexer: https://better-call.dev/ +#index: +# indexer: nomadic +# target: tezos-baking-node-0.tezos-baking-node diff --git a/config-generator/entrypoint.py b/config-generator/entrypoint.py index a9119a738..09a689526 100644 --- a/config-generator/entrypoint.py +++ b/config-generator/entrypoint.py @@ -34,6 +34,7 @@ # If there are no genesis params, this is a public chain. THIS_IS_A_PUBLIC_NET = True if not NETWORK_CONFIG.get("genesis") else False + def main(): all_accounts = ACCOUNTS diff --git a/devspace.yaml b/devspace.yaml index 74c9d3a5f..394be6b89 100755 --- a/devspace.yaml +++ b/devspace.yaml @@ -36,6 +36,14 @@ images: image: tezos-k8s-config-generator dockerfile: ./config-generator/Dockerfile context: ./config-generator + bcd-api: + image: tezos-k8s-bcd-api + dockerfile: ../bcdhub/build/api/Dockerfile + context: ../bcdhub/ + bcd-indexer: + image: tezos-k8s-bcd-indexer + dockerfile: ../bcdhub/build/indexer/Dockerfile + context: ../bcdhub/ dev: ports: From 9ff649e96ab9861773ae4afda176eff5c592ce47 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Wed, 24 Mar 2021 18:58:33 -0700 Subject: [PATCH 02/35] restore to upstream version of bcd in anticipation for the release --- charts/tezos/templates/bcd_indexer.yaml | 4 ++-- charts/tezos/values.yaml | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index a97dd7cc2..4747212cc 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -17,7 +17,7 @@ spec: appType: tezos spec: containers: - - image: "{{ .Values.tezos_k8s_images.bcd_api }}" + - image: bakingbad/bcdhub-api:3.4 name: api env: - name: BCD_ENV @@ -42,7 +42,7 @@ spec: value: guest - name: SANDBOX_NODE_URI value: http://{{ .Values.index.target }}:8732 - - image: "{{ .Values.tezos_k8s_images.bcd_indexer }}" + - image: bakingbad/bcdhub-indexer:3.4 name: indexer env: - name: BCD_ENV diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 915590129..94effda11 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -20,8 +20,6 @@ tezos_k8s_images: snapshot_downloader: tezos-k8s-snapshot-downloader:dev wait_for_bootstrap: tezos-k8s-wait-for-bootstrap:dev zerotier: tezos-k8s-zerotier:dev - bcd_api: tezos-k8s-bcd-api:dev - bcd_indexer: tezos-k8s-bcd-indexer:dev # Properties that are templated in Helm template files baker_statefulset: # charts/tezos/templates/baker.yaml From c1b17c53e172da2352ddfcac10db62df71649635 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 25 Mar 2021 15:06:14 -0700 Subject: [PATCH 03/35] remove dep for now --- charts/tezos/Chart.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/charts/tezos/Chart.yaml b/charts/tezos/Chart.yaml index b53fdced9..cab433c9e 100644 --- a/charts/tezos/Chart.yaml +++ b/charts/tezos/Chart.yaml @@ -7,7 +7,3 @@ keywords: - tezos - blockchain home: https://github.com/tqtezos/tezos-k8s -dependencies: - - name: authenticated-rpc-tezos-chain - repository: file://../rpc-auth - condition: rpc_auth From 3910c59f93621e8a711ccef5db03b130492d7844 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 25 Mar 2021 15:06:44 -0700 Subject: [PATCH 04/35] bump bcdhub version --- charts/tezos/templates/bcd_indexer.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 4747212cc..6390e19d3 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -17,7 +17,7 @@ spec: appType: tezos spec: containers: - - image: bakingbad/bcdhub-api:3.4 + - image: bakingbad/bcdhub-api:3.5 name: api env: - name: BCD_ENV @@ -42,7 +42,7 @@ spec: value: guest - name: SANDBOX_NODE_URI value: http://{{ .Values.index.target }}:8732 - - image: bakingbad/bcdhub-indexer:3.4 + - image: bakingbad/bcdhub-indexer:3.5 name: indexer env: - name: BCD_ENV @@ -89,7 +89,7 @@ spec: value: guest - name: RABBITMQ_DEFAULT_PASS value: guest - - image: bakingbad/bcdhub-elastic:3.4 + - image: bakingbad/bcdhub-elastic:3.5 name: elastic volumeMounts: - mountPath: /usr/share/elasticsearch/data From 8181980fa0cf03c3c0be62fcc5d5f022af97d08a Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 25 Mar 2021 15:46:18 -0700 Subject: [PATCH 05/35] make storage size parametrizable My immediate need is to deploy an archive node; I need 300Gi of storage. --- charts/tezos/templates/baker.yaml | 2 +- charts/tezos/templates/node.yaml | 2 +- charts/tezos/values.yaml | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/charts/tezos/templates/baker.yaml b/charts/tezos/templates/baker.yaml index 1b7af5680..dabdb1dd3 100644 --- a/charts/tezos/templates/baker.yaml +++ b/charts/tezos/templates/baker.yaml @@ -103,5 +103,5 @@ spec: - ReadWriteOnce resources: requests: - storage: "15Gi" + storage: {{ .Values.baker_statefulset.storage_size }} {{- end }} diff --git a/charts/tezos/templates/node.yaml b/charts/tezos/templates/node.yaml index ccaabb1e9..ad309df9c 100644 --- a/charts/tezos/templates/node.yaml +++ b/charts/tezos/templates/node.yaml @@ -42,4 +42,4 @@ spec: - ReadWriteOnce resources: requests: - storage: "15Gi" + storage: {{ .Values.regular_node_statefulset.storage_size }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 0b9840d14..6e0fc47da 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -25,9 +25,11 @@ tezos_k8s_images: baker_statefulset: # charts/tezos/templates/baker.yaml name: tezos-baking-node node_type: baking + storage_size: 15Gi regular_node_statefulset: # charts/tezos/templates/node.yaml name: tezos-node node_type: regular + storage_size: 15Gi # For non-public chains the defualt mutez given to an account if the # account is not explicitly set below. From c60057d2246b0e37616d1ba9113684092d5ec5b2 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 25 Mar 2021 16:25:30 -0700 Subject: [PATCH 06/35] hardcode space requirements for indexing mainnet for now --- charts/tezos/templates/bcd_indexer.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 6390e19d3..4fb3b5e81 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -109,7 +109,7 @@ spec: - ReadWriteOnce resources: requests: - storage: "5Gi" + storage: "300Gi" - metadata: name: mq-data spec: @@ -125,7 +125,7 @@ spec: - ReadWriteOnce resources: requests: - storage: "5Gi" + storage: "300Gi" --- apiVersion: v1 kind: ConfigMap From 2e8697e6fbd320c94d6395c0f5111b4968a28863 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 25 Mar 2021 17:26:32 -0700 Subject: [PATCH 07/35] postgres does not want data folder to be an entire mount point: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit │ The files belonging to this database system will be owned by user "postgres". │ This user must also own the server process. │ The database cluster will be initialized with locale "en_US.utf8". │ The default database encoding has accordingly been set to "UTF8". │ The default text search configuration will be set to "english". │ Data page checksums are disabled. │ initdb: error: directory "/var/lib/postgresql/data" exists but is not empty │ It contains a lost+found directory, perhaps due to it being a mount point. │ Using a mount point directly as the data directory is not recommended. │ Create a subdirectory under the mount point. │ stream closed --- charts/tezos/templates/bcd_indexer.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 4fb3b5e81..f5e2eccad 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -70,7 +70,7 @@ spec: - image: postgres:alpine name: db volumeMounts: - - mountPath: /var/lib/postgresql/data + - mountPath: /var/lib/postgresql/ name: indexer-db env: - name: POSTGRES_USER From eee2ac1f5e9ee81a473e2493e00b41312bdd4b35 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 1 Apr 2021 12:59:39 -0700 Subject: [PATCH 08/35] after last bcd release, it's no longer needed to rebuild --- devspace.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/devspace.yaml b/devspace.yaml index 394be6b89..74c9d3a5f 100755 --- a/devspace.yaml +++ b/devspace.yaml @@ -36,14 +36,6 @@ images: image: tezos-k8s-config-generator dockerfile: ./config-generator/Dockerfile context: ./config-generator - bcd-api: - image: tezos-k8s-bcd-api - dockerfile: ../bcdhub/build/api/Dockerfile - context: ../bcdhub/ - bcd-indexer: - image: tezos-k8s-bcd-indexer - dockerfile: ../bcdhub/build/indexer/Dockerfile - context: ../bcdhub/ dev: ports: From 9ce5ebcc1c8b6c176f2b5f9ea8110ca8dddd5958 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 6 Apr 2021 09:58:27 -0700 Subject: [PATCH 09/35] templatize and remove hardcoding --- charts/tezos/templates/bcd_indexer.yaml | 89 ++++++++------------- charts/tezos/templates/nomadic_indexer.yaml | 21 +++-- 2 files changed, 48 insertions(+), 62 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index f5e2eccad..e7d99468c 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -9,7 +9,7 @@ spec: selector: matchLabels: app: {{ .Values.bcd_indexer_statefulset.name }} - serviceName: tezos-node + serviceName: {{ .Values.bcd_indexer_statefulset.name }} template: metadata: labels: @@ -19,66 +19,24 @@ spec: containers: - image: bakingbad/bcdhub-api:3.5 name: api - env: - - name: BCD_ENV - value: sandbox - - name: GIN_MODE - value: debug - - name: POSTGRES_USER - value: root - - name: POSTGRES_PASSWORD - value: root - - name: POSTGRES_DB - value: bcd - - name: ELASTIC_HOSTNAME - value: localhost - - name: RABBITMQ_HOSTNAME - value: localhost - - name: DB_HOSTNAME - value: 127.0.0.1 - - name: RABBITMQ_DEFAULT_USER - value: guest - - name: RABBITMQ_DEFAULT_PASS - value: guest - - name: SANDBOX_NODE_URI - value: http://{{ .Values.index.target }}:8732 + envFrom: + - configMapRef: + name: bcd-env + - configMapRef: + name: db-creds - image: bakingbad/bcdhub-indexer:3.5 name: indexer - env: - - name: BCD_ENV - value: sandbox - - name: GIN_MODE - value: debug - - name: POSTGRES_USER - value: root - - name: POSTGRES_PASSWORD - value: root - - name: POSTGRES_DB - value: bcd - - name: ELASTIC_HOSTNAME - value: localhost - - name: RABBITMQ_HOSTNAME - value: localhost - - name: DB_HOSTNAME - value: 127.0.0.1 - - name: RABBITMQ_DEFAULT_USER - value: guest - - name: RABBITMQ_DEFAULT_PASS - value: guest - - name: SANDBOX_NODE_URI - value: http://tezos-node-0.tezos-node:8732 + envFrom: + - configMapRef: + name: bcd-env - image: postgres:alpine name: db volumeMounts: - mountPath: /var/lib/postgresql/ name: indexer-db - env: - - name: POSTGRES_USER - value: root - - name: POSTGRES_DB - value: bcd - - name: POSTGRES_PASSWORD - value: root + envFrom: + - configMapRef: + name: db-creds - image: rabbitmq:latest name: mq volumeMounts: @@ -143,4 +101,27 @@ data: db: conn_string: "host=127.0.0.1 port=5432 user=${POSTGRES_USER} dbname=${POSTGRES_DB} password=${POSTGRES_PASSWORD} sslmode=disable" timeout: 10 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: bcd-env +data: + BCD_ENV: sandbox + GIN_MODE: debug + ELASTIC_HOSTNAME: localhost + RABBITMQ_HOSTNAME: localhost + DB_HOSTNAME: 127.0.0.1 + RABBITMQ_DEFAULT_USER: guest + RABBITMQ_DEFAULT_PASS: guest + SANDBOX_NODE_URI: "http://{{ .Values.index.target }}:8732" +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: db-creds +data: + POSTGRES_USER: root + POSTGRES_PASSWORD: root + POSTGRES_DB: bcd {{- end }} diff --git a/charts/tezos/templates/nomadic_indexer.yaml b/charts/tezos/templates/nomadic_indexer.yaml index be9677973..9678dc37c 100644 --- a/charts/tezos/templates/nomadic_indexer.yaml +++ b/charts/tezos/templates/nomadic_indexer.yaml @@ -10,7 +10,7 @@ spec: selector: matchLabels: app: {{ .Values.nomadic_indexer_statefulset.name }} - serviceName: tezos-node + serviceName: {{ .Values.nomadic_indexer_statefulset.name }} template: metadata: labels: @@ -41,13 +41,9 @@ spec: name: schema-volume - mountPath: /var/lib/postgresql/data name: indexer-db - env: - - name: POSTGRES_USER - value: tezos - - name: POSTGRES_DB - value: tezos - - name: POSTGRES_PASSWORD - value: tezosrocks + envFrom: + - configMapRef: + name: db-creds volumes: - emptyDir: {} name: schema-volume @@ -60,4 +56,13 @@ spec: resources: requests: storage: "5Gi" +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: db-creds +data: + POSTGRES_USER: tezos + POSTGRES_PASSWORD: tezosrocks + POSTGRES_DB: tezos {{- end }} From 14e0491cc820bb81d5ea3ae131dad6023fddfea4 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 6 Apr 2021 11:39:38 -0700 Subject: [PATCH 10/35] hardcode v9.0-rc1 for edo2 --- baker-endorser/Dockerfile | 2 +- chain-initiator/Dockerfile | 2 +- charts/tezos/Chart.lock | 6 ------ charts/tezos/values.yaml | 6 +++--- config-generator/Dockerfile | 2 +- mkchain/README.md | 2 +- mkchain/tqchain/mkchain.py | 2 +- rpc-auth/README.md | 2 +- snapshot-downloader/Dockerfile | 2 +- wait-for-bootstrap/Dockerfile | 2 +- 10 files changed, 11 insertions(+), 17 deletions(-) delete mode 100644 charts/tezos/Chart.lock diff --git a/baker-endorser/Dockerfile b/baker-endorser/Dockerfile index 38325f207..98a7975d7 100644 --- a/baker-endorser/Dockerfile +++ b/baker-endorser/Dockerfile @@ -1,4 +1,4 @@ -FROM tezos/tezos:v8-release +FROM tezos/tezos:v9.0-rc1 RUN sudo apk add jq bash COPY entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] diff --git a/chain-initiator/Dockerfile b/chain-initiator/Dockerfile index 05c0cbd09..b4b377df0 100644 --- a/chain-initiator/Dockerfile +++ b/chain-initiator/Dockerfile @@ -1,4 +1,4 @@ -FROM tezos/tezos:v8-release +FROM tezos/tezos:v9.0-rc1 RUN sudo apk add jq COPY entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] diff --git a/charts/tezos/Chart.lock b/charts/tezos/Chart.lock deleted file mode 100644 index 6a1bd656f..000000000 --- a/charts/tezos/Chart.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: authenticated-rpc-tezos-chain - repository: file://../rpc-auth - version: 0.0.0 -digest: sha256:359e854ddadc434084a5894da498d9170a778a6aa345414f97d4c570eaf9b99b -generated: "2021-01-11T16:20:15.112419-05:00" diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 1a8f375ca..58ac07733 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -11,7 +11,7 @@ rpc_auth: false # Images not part of the tezos-k8s repo go here images: - tezos: tezos/tezos:v8-release + tezos: tezos/tezos:v9.0-rc1 # Images that are part of the tezos-k8s repo go here with 'dev' tag tezos_k8s_images: baker_endorser: tezos-k8s-baker-endorser:dev @@ -138,13 +138,13 @@ expected_proof_of_work: 26 # activation_account_name: tqtezos_baker_0 # # For joining a public network. The network must be recognized by the -# tezos/tezos:v8-release docker image. +# tezos/tezos:v9.0-rc1 docker image. node_config_network: chain_name: mainnet protocol: # Set the protocol binary. The protocol must be recognized by the - # tezos/tezos:v8-release docker image. + # tezos/tezos:v9.0-rc1 docker image. command: 008-PtEdo2Zk # # Activate a new chain from genesis. Note, this is only for when your chain does diff --git a/config-generator/Dockerfile b/config-generator/Dockerfile index 34827f276..a38d347ab 100644 --- a/config-generator/Dockerfile +++ b/config-generator/Dockerfile @@ -1,4 +1,4 @@ -FROM tezos/tezos:v8-release +FROM tezos/tezos:v9.0-rc1 ENV PYTHONUNBUFFERED=1 # Note: we install build deps for pip, then remove everything after pip install. diff --git a/mkchain/README.md b/mkchain/README.md index 73cc0acc8..aef2d6ca2 100644 --- a/mkchain/README.md +++ b/mkchain/README.md @@ -68,7 +68,7 @@ You can explicitly specify some values by: | | --number-of-nodes | Number of non-baking nodes in the cluster | 0 | | bootstrap_peers | --bootstrap-peers | Peer ips to connect to | [] | | expected_proof_of_work | --expected-proof-of-work | Node identity generation difficulty | 0 | -| images.tezos | --tezos-docker-image | Version of the Tezos docker image to run | tezos/tezos:v8-release | +| images.tezos | --tezos-docker-image | Version of the Tezos docker image to run | tezos/tezos:v9.0-rc1 | | rpc_auth | --rpc-auth | Whether or not an [RPC auth](../rpc-auth/README.md) backend will be spun up | False | | zerotier_config.zerotier_network | --zerotier-network | Zerotier network id for external chain access | | | zerotier_config.zerotier_token | --zerotier-token | Zerotier token for external chain access | | diff --git a/mkchain/tqchain/mkchain.py b/mkchain/tqchain/mkchain.py index 4a81b0205..75c937807 100644 --- a/mkchain/tqchain/mkchain.py +++ b/mkchain/tqchain/mkchain.py @@ -102,7 +102,7 @@ def get_genesis_vanity_chain_id(docker_image, seed_len=16): }, "tezos_docker_image": { "help": "Version of the Tezos docker image", - "default": "tezos/tezos:v8-release", + "default": "tezos/tezos:v9.0-rc1", }, "rpc_auth": { "help": "Should spin up an RPC authentication server", diff --git a/rpc-auth/README.md b/rpc-auth/README.md index b14b8862c..d54c4eeec 100644 --- a/rpc-auth/README.md +++ b/rpc-auth/README.md @@ -83,7 +83,7 @@ helm upgrade $CHAIN_NAME tqtezos/tezos-chain \ 5. Client can then make RPC requests: - `curl http://192.168.64.51/tezos-node-rpc/ffff3eb3d7dd4f6bbff3f2fd096722ae/chains/main/chain_id` - - As of docker image `tezos/tezos:v8-release`: + - As of docker image `tezos/tezos:v9.0-rc1`: ```shell tezos-client --endpoint http://192.168.64.51/tezos-node-rpc/ffff3eb3d7dd4f6bbff3f2fd096722ae/ rpc get chains/main/chain_id ``` diff --git a/snapshot-downloader/Dockerfile b/snapshot-downloader/Dockerfile index 71ca59bc6..9f7fc50ce 100644 --- a/snapshot-downloader/Dockerfile +++ b/snapshot-downloader/Dockerfile @@ -1,4 +1,4 @@ -FROM tezos/tezos:v8-release +FROM tezos/tezos:v9.0-rc1 RUN sudo apk add curl lz4 xz jq COPY entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] diff --git a/wait-for-bootstrap/Dockerfile b/wait-for-bootstrap/Dockerfile index 7bf21b0cc..ac54e1aa9 100644 --- a/wait-for-bootstrap/Dockerfile +++ b/wait-for-bootstrap/Dockerfile @@ -1,4 +1,4 @@ -FROM tezos/tezos:v8-release +FROM tezos/tezos:v9.0-rc1 RUN sudo apk add jq netcat-openbsd COPY entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] From 15d255be54269f2907de7aa821d6369b7e5c60cd Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 8 Apr 2021 15:36:40 -0700 Subject: [PATCH 11/35] name rpc port --- charts/tezos/templates/static.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/tezos/templates/static.yaml b/charts/tezos/templates/static.yaml index c9bf34757..de26a8b20 100644 --- a/charts/tezos/templates/static.yaml +++ b/charts/tezos/templates/static.yaml @@ -6,6 +6,7 @@ metadata: spec: ports: - port: 8732 + name: rpc selector: app: tezos-baking-node type: NodePort From 4053ca518b180bd7f3dde83d933fc9efe848615b Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 8 Apr 2021 16:40:55 -0700 Subject: [PATCH 12/35] target node for rpc service --- charts/tezos/templates/static.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/templates/static.yaml b/charts/tezos/templates/static.yaml index de26a8b20..943c6177d 100644 --- a/charts/tezos/templates/static.yaml +++ b/charts/tezos/templates/static.yaml @@ -8,7 +8,7 @@ spec: - port: 8732 name: rpc selector: - app: tezos-baking-node + app: tezos-node type: NodePort --- apiVersion: v1 From 29a2013fa22fa42ee0905bc2258fabb50de88607 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 8 Apr 2021 17:05:05 -0700 Subject: [PATCH 13/35] set uid/gid to 1000 to make elastic work on eks --- charts/tezos/templates/bcd_indexer.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index e7d99468c..454d71462 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -16,6 +16,8 @@ spec: app: {{ .Values.bcd_indexer_statefulset.name }} appType: tezos spec: + securityContext: + fsGroup: 1000 containers: - image: bakingbad/bcdhub-api:3.5 name: api From 56989c563629abd24ac4ff3073744dc74e63fb9d Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 8 Apr 2021 17:20:25 -0700 Subject: [PATCH 14/35] fix rabbit perm issue on eks https://github.com/docker-library/rabbitmq/issues/171#issuecomment-316302131 --- charts/tezos/templates/bcd_indexer.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 454d71462..1755e6519 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -42,7 +42,7 @@ spec: - image: rabbitmq:latest name: mq volumeMounts: - - mountPath: /var/lib/rabbitmq + - mountPath: /var/lib/rabbitmq/mnesia name: mq-data env: - name: RABBITMQ_DEFAULT_USER From 02a4bb3da4a69e1ba00186a1a779089367c4be15 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 8 Apr 2021 17:46:31 -0700 Subject: [PATCH 15/35] bump bcd to latest version 3.5.2 --- charts/tezos/templates/bcd_indexer.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 1755e6519..9264dbc2d 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -19,14 +19,14 @@ spec: securityContext: fsGroup: 1000 containers: - - image: bakingbad/bcdhub-api:3.5 + - image: bakingbad/bcdhub-api:3.5.2 name: api envFrom: - configMapRef: name: bcd-env - configMapRef: name: db-creds - - image: bakingbad/bcdhub-indexer:3.5 + - image: bakingbad/bcdhub-indexer:3.5.2 name: indexer envFrom: - configMapRef: @@ -49,7 +49,7 @@ spec: value: guest - name: RABBITMQ_DEFAULT_PASS value: guest - - image: bakingbad/bcdhub-elastic:3.5 + - image: bakingbad/bcdhub-elastic:3.5.2 name: elastic volumeMounts: - mountPath: /usr/share/elasticsearch/data From f2723a6d1c42a6ab05784993ccb27de7ea6c0711 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Thu, 8 Apr 2021 18:04:09 -0700 Subject: [PATCH 16/35] Revert "bump bcd to latest version 3.5.2" There is no version 3.5.2 of containers. --- charts/tezos/templates/bcd_indexer.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 9264dbc2d..1755e6519 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -19,14 +19,14 @@ spec: securityContext: fsGroup: 1000 containers: - - image: bakingbad/bcdhub-api:3.5.2 + - image: bakingbad/bcdhub-api:3.5 name: api envFrom: - configMapRef: name: bcd-env - configMapRef: name: db-creds - - image: bakingbad/bcdhub-indexer:3.5.2 + - image: bakingbad/bcdhub-indexer:3.5 name: indexer envFrom: - configMapRef: @@ -49,7 +49,7 @@ spec: value: guest - name: RABBITMQ_DEFAULT_PASS value: guest - - image: bakingbad/bcdhub-elastic:3.5.2 + - image: bakingbad/bcdhub-elastic:3.5 name: elastic volumeMounts: - mountPath: /usr/share/elasticsearch/data From bd1c8cf49d79c29bb015c875eeee092ed5bdde84 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Fri, 9 Apr 2021 17:18:43 -0400 Subject: [PATCH 17/35] Make serviceName of indexer yamls empty str There is currently no headless service for them. --- charts/tezos/templates/bcd_indexer.yaml | 2 +- charts/tezos/templates/nomadic_indexer.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 1755e6519..1dc01be85 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -9,7 +9,7 @@ spec: selector: matchLabels: app: {{ .Values.bcd_indexer_statefulset.name }} - serviceName: {{ .Values.bcd_indexer_statefulset.name }} + serviceName: "" template: metadata: labels: diff --git a/charts/tezos/templates/nomadic_indexer.yaml b/charts/tezos/templates/nomadic_indexer.yaml index 9678dc37c..22207c64a 100644 --- a/charts/tezos/templates/nomadic_indexer.yaml +++ b/charts/tezos/templates/nomadic_indexer.yaml @@ -10,7 +10,7 @@ spec: selector: matchLabels: app: {{ .Values.nomadic_indexer_statefulset.name }} - serviceName: {{ .Values.nomadic_indexer_statefulset.name }} + serviceName: "" template: metadata: labels: From 5643fe3cb52ab3711f8833167b5fa0df931424ec Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Fri, 9 Apr 2021 18:37:09 -0400 Subject: [PATCH 18/35] Don't create statefulsets and headless svc if replicas = 0 --- charts/tezos/templates/_helpers.tpl | 28 ++++++++++++++++++++++++++++ charts/tezos/templates/baker.yaml | 2 +- charts/tezos/templates/node.yaml | 2 ++ charts/tezos/templates/static.yaml | 5 +++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/charts/tezos/templates/_helpers.tpl b/charts/tezos/templates/_helpers.tpl index 45bf63654..c56c6b910 100644 --- a/charts/tezos/templates/_helpers.tpl +++ b/charts/tezos/templates/_helpers.tpl @@ -26,6 +26,34 @@ {{- end }} {{- end }} +{{/* + Don't deploy the baker statefulset and its headless service if + there are no bakers specified. + Returns a string "true" or empty string which is falsey. +*/}} +{{- define "tezos.shouldDeployBakerStatefulset" -}} +{{- $baking_nodes := .Values.nodes.baking | default dict }} +{{- if and (not .Values.is_invitation) ($baking_nodes | len) }} +{{- "true" }} +{{- else }} +{{- "" }} +{{- end }} +{{- end }} + +{{/* + Don't deploy the regular node statefulset and its headless service if + there are no regular nodes specified. + Returns a string "true" or empty string which is falsey. +*/}} +{{- define "tezos.shouldDeployRegularNodeStatefulset" -}} +{{- $regular_nodes := .Values.nodes.regular | default dict }} +{{- if ($regular_nodes | len) }} +{{- "true" }} +{{- else }} +{{- "" }} +{{- end }} +{{- end }} + {{/* Checks if a protocol should be activated. There needs to be a protocol_hash and protocol_parameters. diff --git a/charts/tezos/templates/baker.yaml b/charts/tezos/templates/baker.yaml index dabdb1dd3..9e1cb0b16 100644 --- a/charts/tezos/templates/baker.yaml +++ b/charts/tezos/templates/baker.yaml @@ -57,7 +57,7 @@ spec: name: var-volume {{ end }} --- -{{- if not .Values.is_invitation }} +{{- if (include "tezos.shouldDeployBakerStatefulset" .) }} apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/charts/tezos/templates/node.yaml b/charts/tezos/templates/node.yaml index ad309df9c..b458a1c5b 100644 --- a/charts/tezos/templates/node.yaml +++ b/charts/tezos/templates/node.yaml @@ -1,3 +1,4 @@ +{{- if (include "tezos.shouldDeployRegularNodeStatefulset" .) }} apiVersion: apps/v1 kind: StatefulSet metadata: @@ -43,3 +44,4 @@ spec: resources: requests: storage: {{ .Values.regular_node_statefulset.storage_size }} +{{- end }} diff --git a/charts/tezos/templates/static.yaml b/charts/tezos/templates/static.yaml index 943c6177d..7e3364dd6 100644 --- a/charts/tezos/templates/static.yaml +++ b/charts/tezos/templates/static.yaml @@ -11,6 +11,7 @@ spec: app: tezos-node type: NodePort --- +{{- if (include "tezos.shouldDeployRegularNodeStatefulset" .) }} apiVersion: v1 kind: Service metadata: @@ -19,6 +20,9 @@ spec: clusterIP: None selector: app: {{ .Values.regular_node_statefulset.name }} +{{- end }} + +{{- if (include "tezos.shouldDeployBakerStatefulset" .) }} --- apiVersion: v1 kind: Service @@ -28,3 +32,4 @@ spec: clusterIP: None selector: app: {{ .Values.baker_statefulset.name }} +{{- end }} From 1dda418cb01569dc437bf3dcea74cd6419efa174 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Tue, 20 Apr 2021 16:31:34 -0400 Subject: [PATCH 19/35] Expose bcd api port --- charts/tezos/templates/bcd_indexer.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 1dc01be85..ed0134877 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -21,6 +21,9 @@ spec: containers: - image: bakingbad/bcdhub-api:3.5 name: api + ports: + - containerPort: 14000 + name: bcd envFrom: - configMapRef: name: bcd-env From d85ebf9cab895ddd56d2e16e1b6fa00c987ac85e Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Tue, 20 Apr 2021 16:35:19 -0400 Subject: [PATCH 20/35] Add bcd metrics container to indexer pod --- charts/tezos/templates/bcd_indexer.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index ed0134877..a1dee0bad 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -34,6 +34,13 @@ spec: envFrom: - configMapRef: name: bcd-env + - image: bakingbad/bcdhub-metrics:3.5 + name: metrics + envFrom: + - configMapRef: + name: bcd-env + - configMapRef: + name: db-creds - image: postgres:alpine name: db volumeMounts: From 3a7a7b2d4b849751fb1686fc4a76774e8bc69744 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Tue, 20 Apr 2021 16:41:56 -0400 Subject: [PATCH 21/35] Create a shared volume used by some bcd indexer containers --- charts/tezos/templates/bcd_indexer.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index a1dee0bad..52065009c 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -24,6 +24,9 @@ spec: ports: - containerPort: 14000 name: bcd + volumeMounts: + - mountPath: /etc/bcd + name: shared-volume envFrom: - configMapRef: name: bcd-env @@ -31,11 +34,17 @@ spec: name: db-creds - image: bakingbad/bcdhub-indexer:3.5 name: indexer + volumeMounts: + - mountPath: /etc/bcd + name: shared-volume envFrom: - configMapRef: name: bcd-env - image: bakingbad/bcdhub-metrics:3.5 name: metrics + volumeMounts: + - mountPath: /etc/bcd + name: shared-volume envFrom: - configMapRef: name: bcd-env @@ -96,6 +105,15 @@ spec: resources: requests: storage: "300Gi" + - metadata: + name: shared-volume + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "1Gi" + --- apiVersion: v1 kind: ConfigMap From fe9b4f8e4f4bc13ee1e7fccf56d2d3727b35bcb7 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Tue, 20 Apr 2021 17:08:37 -0400 Subject: [PATCH 22/35] Remove unused configmap --- charts/tezos/templates/bcd_indexer.yaml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 52065009c..c3c440380 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -117,23 +117,6 @@ spec: --- apiVersion: v1 kind: ConfigMap -metadata: - name: bcd-config -data: - bcd_config.yml: |- - storage: - uri: - - http://localhost:9200 - timeout: 10 - rabbitmq: - uri: "amqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@localhost:5672/" - timeout: 10 - db: - conn_string: "host=127.0.0.1 port=5432 user=${POSTGRES_USER} dbname=${POSTGRES_DB} password=${POSTGRES_PASSWORD} sslmode=disable" - timeout: 10 ---- -apiVersion: v1 -kind: ConfigMap metadata: name: bcd-env data: From 6994b507d7b45716d9a4b84d1bb05f33bf4dd690 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Tue, 20 Apr 2021 17:25:49 -0400 Subject: [PATCH 23/35] Change naming of indexer props in values.yaml --- charts/tezos/templates/_helpers.tpl | 6 +++--- charts/tezos/templates/bcd_indexer.yaml | 2 +- charts/tezos/templates/nomadic_indexer.yaml | 2 +- charts/tezos/values.yaml | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/tezos/templates/_helpers.tpl b/charts/tezos/templates/_helpers.tpl index c56c6b910..14a7ce04f 100644 --- a/charts/tezos/templates/_helpers.tpl +++ b/charts/tezos/templates/_helpers.tpl @@ -87,9 +87,9 @@ Returns the indexer type or empty string which is falsey. */}} {{- define "tezos.indexer" -}} -{{- $index_config := .Values.index | default dict }} -{{- if $index_config.indexer }} -{{- $index_config.indexer }} +{{- $index_config := .Values.indexer | default dict }} +{{- if and $index_config.name $index_config.rpc_url }} +{{- $index_config.name }} {{- else }} {{- "" }} {{- end }} diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index c3c440380..30e856b4c 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -127,7 +127,7 @@ data: DB_HOSTNAME: 127.0.0.1 RABBITMQ_DEFAULT_USER: guest RABBITMQ_DEFAULT_PASS: guest - SANDBOX_NODE_URI: "http://{{ .Values.index.target }}:8732" + SANDBOX_NODE_URI: {{ .Values.indexer.rpc_url }} --- apiVersion: v1 kind: ConfigMap diff --git a/charts/tezos/templates/nomadic_indexer.yaml b/charts/tezos/templates/nomadic_indexer.yaml index 22207c64a..700e9783b 100644 --- a/charts/tezos/templates/nomadic_indexer.yaml +++ b/charts/tezos/templates/nomadic_indexer.yaml @@ -33,7 +33,7 @@ spec: - --verbosity=1 - --no-contract-balances - --db=postgresql://localhost/tezos - - --tezos-url=http://{{ .Values.index.target }}:8732 + - --tezos-url={{ .Values.indexer.rpc_url }} - image: postgres:alpine name: postgres volumeMounts: diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 58ac07733..a49719c52 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -190,6 +190,6 @@ protocol: # Supports two types of indexers: # * "nomadic": Tezos nomadic indexer: https://gitlab.com/nomadic-labs/tezos-indexer # * "bcd": Better Call Dev indexer: https://better-call.dev/ -#index: -# indexer: nomadic -# target: tezos-baking-node-0.tezos-baking-node +# indexer: +# name: nomadic +# rpc_url: http://tezos-node-0.tezos-node:8732 From cca2e0b3fc6eef74fc05e0a0a02baf6e27d6fb93 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Wed, 21 Apr 2021 21:32:02 -0400 Subject: [PATCH 24/35] Make default indexer bcd --- charts/tezos/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index a49719c52..a0a372d2f 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -191,5 +191,5 @@ protocol: # * "nomadic": Tezos nomadic indexer: https://gitlab.com/nomadic-labs/tezos-indexer # * "bcd": Better Call Dev indexer: https://better-call.dev/ # indexer: -# name: nomadic +# name: bcd # rpc_url: http://tezos-node-0.tezos-node:8732 From 6ef7354290a997c076f543ef68eafa16b7e8f16f Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Tue, 20 Apr 2021 17:32:49 -0400 Subject: [PATCH 25/35] Remove appType label from indexer statefulsets --- charts/tezos/templates/bcd_indexer.yaml | 1 - charts/tezos/templates/nomadic_indexer.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 30e856b4c..29734e416 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -14,7 +14,6 @@ spec: metadata: labels: app: {{ .Values.bcd_indexer_statefulset.name }} - appType: tezos spec: securityContext: fsGroup: 1000 diff --git a/charts/tezos/templates/nomadic_indexer.yaml b/charts/tezos/templates/nomadic_indexer.yaml index 700e9783b..b76b9f676 100644 --- a/charts/tezos/templates/nomadic_indexer.yaml +++ b/charts/tezos/templates/nomadic_indexer.yaml @@ -15,7 +15,6 @@ spec: metadata: labels: app: {{ .Values.nomadic_indexer_statefulset.name }} - appType: tezos spec: initContainers: - image: registry.gitlab.com/nomadic-labs/tezos-indexer/tezos-indexer:v9.1.0 From c8420acaa9b8431dbfa38c4816237ca5a0918370 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Tue, 20 Apr 2021 17:37:40 -0400 Subject: [PATCH 26/35] Make rpc service select on appType=tezos-node --- README.md | 12 ++++++------ charts/tezos/templates/baker.yaml | 2 +- charts/tezos/templates/node.yaml | 2 +- charts/tezos/templates/static.yaml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b1f122f7c..187a49a4d 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ Running either of these commands results in: You can find your node in the tqtezos namespace with some status information using `kubectl`. ```shell -kubectl -n tqtezos get pods -l appType=tezos +kubectl -n tqtezos get pods -l appType=tezos-node ``` You can monitor (and follow using the `-f` flag) the logs of the snapshot downloader/import container: @@ -172,7 +172,7 @@ kubectl logs -n tqtezos statefulset/tezos-node -c snapshot-downloader -f You can view logs for your node using the following command: ```shell -kubectl -n tqtezos logs -l appType=tezos -c tezos-node -f --prefix +kubectl -n tqtezos logs -l appType=tezos-node -c tezos-node -f --prefix ``` IMPORTANT: @@ -281,13 +281,13 @@ perform the following tasks: You can find your node in the tqtezos namespace with some status information using kubectl. ```shell -kubectl -n tqtezos get pods -l appType=tezos +kubectl -n tqtezos get pods -l appType=tezos-node ``` You can view (and follow using the `-f` flag) logs for your node using the following command: ```shell -kubectl -n tqtezos logs -l appType=tezos -c tezos-node -f --prefix +kubectl -n tqtezos logs -l appType=tezos-node -c tezos-node -f --prefix ``` Congratulations! You now have an operational Tezos based permissioned @@ -325,7 +325,7 @@ helm upgrade $CHAIN_NAME tqtezos/tezos-chain \ The nodes will start up and establish peer-to-peer connections in a full mesh topology. -List all of your running nodes: `kubectl -n tqtezos get pods -l appType=tezos` +List all of your running nodes: `kubectl -n tqtezos get pods -l appType=tezos-node` ## Adding external nodes to the cluster @@ -361,7 +361,7 @@ Congratulations! You now have a multi-node Tezos based permissioned chain. On each computer, run this command to check that the nodes have matching heads by comparing their hashes (it may take a minute for the nodes to sync up): ```shell -kubectl get pod -n tqtezos -l appType=tezos -o name | +kubectl get pod -n tqtezos -l appType=tezos-node -o name | while read line; do kubectl -n tqtezos exec $line -c tezos-node -- /usr/local/bin/tezos-client rpc get /chains/main/blocks/head/hash; done diff --git a/charts/tezos/templates/baker.yaml b/charts/tezos/templates/baker.yaml index 9e1cb0b16..441431b7d 100644 --- a/charts/tezos/templates/baker.yaml +++ b/charts/tezos/templates/baker.yaml @@ -74,7 +74,7 @@ spec: metadata: labels: app: {{ .Values.baker_statefulset.name }} - appType: tezos + appType: tezos-node spec: containers: {{- include "tezos.container.node" . | indent 8 }} diff --git a/charts/tezos/templates/node.yaml b/charts/tezos/templates/node.yaml index b458a1c5b..7fed01da1 100644 --- a/charts/tezos/templates/node.yaml +++ b/charts/tezos/templates/node.yaml @@ -16,7 +16,7 @@ spec: metadata: labels: app: {{ .Values.regular_node_statefulset.name }} - appType: tezos + appType: tezos-node spec: containers: {{- include "tezos.container.node" . | indent 8 }} diff --git a/charts/tezos/templates/static.yaml b/charts/tezos/templates/static.yaml index 7e3364dd6..8f13f5d1d 100644 --- a/charts/tezos/templates/static.yaml +++ b/charts/tezos/templates/static.yaml @@ -8,7 +8,7 @@ spec: - port: 8732 name: rpc selector: - app: tezos-node + appType: tezos-node type: NodePort --- {{- if (include "tezos.shouldDeployRegularNodeStatefulset" .) }} From c38bc0693be137a1023661773ce5053f0f086a25 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Wed, 21 Apr 2021 20:45:57 -0400 Subject: [PATCH 27/35] Add imagePullPolicy=IfNotPresent to some containers --- charts/tezos/templates/bcd_indexer.yaml | 2 ++ charts/tezos/templates/nomadic_indexer.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 29734e416..7ffafce83 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -51,6 +51,7 @@ spec: name: db-creds - image: postgres:alpine name: db + imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /var/lib/postgresql/ name: indexer-db @@ -59,6 +60,7 @@ spec: name: db-creds - image: rabbitmq:latest name: mq + imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /var/lib/rabbitmq/mnesia name: mq-data diff --git a/charts/tezos/templates/nomadic_indexer.yaml b/charts/tezos/templates/nomadic_indexer.yaml index b76b9f676..485fc0a6d 100644 --- a/charts/tezos/templates/nomadic_indexer.yaml +++ b/charts/tezos/templates/nomadic_indexer.yaml @@ -35,6 +35,7 @@ spec: - --tezos-url={{ .Values.indexer.rpc_url }} - image: postgres:alpine name: postgres + imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /docker-entrypoint-initdb.d/ name: schema-volume From 02c674e2d33017db685be00e844d1bf5c7df1755 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Wed, 21 Apr 2021 20:56:46 -0400 Subject: [PATCH 28/35] Update template functions that determine which indexer to deploy --- charts/tezos/templates/_helpers.tpl | 27 +++++++++++++++++---- charts/tezos/templates/bcd_indexer.yaml | 2 +- charts/tezos/templates/nomadic_indexer.yaml | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/charts/tezos/templates/_helpers.tpl b/charts/tezos/templates/_helpers.tpl index 14a7ce04f..dcb559478 100644 --- a/charts/tezos/templates/_helpers.tpl +++ b/charts/tezos/templates/_helpers.tpl @@ -82,15 +82,32 @@ {{- end }} {{/* - Checks if indexer config has an indexer type and target set. - This is to make helm linter happy. - Returns the indexer type or empty string which is falsey. + BCD indexer + Checks if indexer config has an indexer and rpc_url set. + Then checks if indexer name is "bcd". + Returns the true type or empty string which is falsey. */}} -{{- define "tezos.indexer" -}} +{{- define "tezos.shouldDeployBcdIndexer" -}} {{- $index_config := .Values.indexer | default dict }} {{- if and $index_config.name $index_config.rpc_url }} -{{- $index_config.name }} +{{- if eq $index_config.name "bcd" }} +{{- "true" }} {{- else }} {{- "" }} {{- end }} {{- end }} +{{- end }} + +{{/* + Nomadic indexer +*/}} +{{- define "tezos.shouldDeployNomadicIndexer" -}} +{{- $index_config := .Values.indexer | default dict }} +{{- if and $index_config.name $index_config.rpc_url }} +{{- if eq $index_config.name "nomadic" }} +{{- "true" }} +{{- else }} +{{- "" }} +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 7ffafce83..a2682e347 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -1,4 +1,4 @@ -{{- if eq (include "tezos.indexer" .) "bcd" }} +{{- if (include "tezos.shouldDeployBcdIndexer" .) }} apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/charts/tezos/templates/nomadic_indexer.yaml b/charts/tezos/templates/nomadic_indexer.yaml index 485fc0a6d..eca0c5124 100644 --- a/charts/tezos/templates/nomadic_indexer.yaml +++ b/charts/tezos/templates/nomadic_indexer.yaml @@ -1,4 +1,4 @@ -{{- if eq (include "tezos.indexer" .) "nomadic" }} +{{- if (include "tezos.shouldDeployNomadicIndexer" .) }} apiVersion: apps/v1 kind: StatefulSet metadata: From 2fc5ff858d492275dadfe65283fa9a07ce4d68ad Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Wed, 21 Apr 2021 21:11:23 -0400 Subject: [PATCH 29/35] Add bcd service --- charts/tezos/templates/static.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/charts/tezos/templates/static.yaml b/charts/tezos/templates/static.yaml index 8f13f5d1d..cc76ad40e 100644 --- a/charts/tezos/templates/static.yaml +++ b/charts/tezos/templates/static.yaml @@ -33,3 +33,18 @@ spec: selector: app: {{ .Values.baker_statefulset.name }} {{- end }} +--- +{{- if (include "tezos.shouldDeployBcdIndexer" .) }} +apiVersion: v1 +kind: Service +metadata: + name: bcd + namespace: {{ .Release.Namespace }} +spec: + ports: + - port: 14000 + name: bcd + selector: + app: {{ .Values.bcd_indexer_statefulset.name }} + type: NodePort +{{- end }} From 801188945c14bd1c974ebae55a93da29083ac9f8 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Fri, 2 Sep 2022 16:12:36 -0400 Subject: [PATCH 30/35] Delete nomadic indexer --- charts/tezos/templates/nomadic_indexer.yaml | 68 --------------------- charts/tezos/values.yaml | 3 +- 2 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 charts/tezos/templates/nomadic_indexer.yaml diff --git a/charts/tezos/templates/nomadic_indexer.yaml b/charts/tezos/templates/nomadic_indexer.yaml deleted file mode 100644 index eca0c5124..000000000 --- a/charts/tezos/templates/nomadic_indexer.yaml +++ /dev/null @@ -1,68 +0,0 @@ -{{- if (include "tezos.shouldDeployNomadicIndexer" .) }} -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: {{ .Values.nomadic_indexer_statefulset.name }} - namespace: {{ .Release.Namespace }} -spec: - podManagementPolicy: Parallel - replicas: 1 - selector: - matchLabels: - app: {{ .Values.nomadic_indexer_statefulset.name }} - serviceName: "" - template: - metadata: - labels: - app: {{ .Values.nomadic_indexer_statefulset.name }} - spec: - initContainers: - - image: registry.gitlab.com/nomadic-labs/tezos-indexer/tezos-indexer:v9.1.0 - command: ["/bin/bash","-c"] - args: [ "/home/tezos/tezos-indexer --db-schema | tee /docker-entrypoint-initdb.d/tezos-indexer-schema.sql" ] - name: schema-extractor - volumeMounts: - - mountPath: /docker-entrypoint-initdb.d/ - name: schema-volume - containers: - - image: registry.gitlab.com/nomadic-labs/tezos-indexer/tezos-indexer:v9.1.0 - name: tezos-indexer - args: - - --debug - - --verbosity=1 - - --no-contract-balances - - --db=postgresql://localhost/tezos - - --tezos-url={{ .Values.indexer.rpc_url }} - - image: postgres:alpine - name: postgres - imagePullPolicy: IfNotPresent - volumeMounts: - - mountPath: /docker-entrypoint-initdb.d/ - name: schema-volume - - mountPath: /var/lib/postgresql/data - name: indexer-db - envFrom: - - configMapRef: - name: db-creds - volumes: - - emptyDir: {} - name: schema-volume - volumeClaimTemplates: - - metadata: - name: indexer-db - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: "5Gi" ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: db-creds -data: - POSTGRES_USER: tezos - POSTGRES_PASSWORD: tezosrocks - POSTGRES_DB: tezos -{{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 274e1fd4e..467846f82 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -453,8 +453,7 @@ protocols: # Deploy an indexer with the chain. An indexer puts the chain # contents in a database for efficient indexing. Most dapps need it. -# Supports two types of indexers: -# * "nomadic": Tezos nomadic indexer: https://gitlab.com/nomadic-labs/tezos-indexer +# Supports: # * "bcd": Better Call Dev indexer: https://better-call.dev/ # indexer: # name: bcd From 8234a417e1f2d41ef9a5a93c3e44235245841070 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Sun, 9 Oct 2022 16:33:22 -0400 Subject: [PATCH 31/35] Update bcd indexer --- charts/tezos/templates/_helpers.tpl | 16 +-- charts/tezos/templates/bcd_indexer.yaml | 154 +++++++++--------------- charts/tezos/templates/static.yaml | 16 --- charts/tezos/values.yaml | 17 ++- 4 files changed, 68 insertions(+), 135 deletions(-) diff --git a/charts/tezos/templates/_helpers.tpl b/charts/tezos/templates/_helpers.tpl index 00a7c9150..0c8d02104 100644 --- a/charts/tezos/templates/_helpers.tpl +++ b/charts/tezos/templates/_helpers.tpl @@ -153,18 +153,14 @@ metadata: {{- end }} {{/* - BCD indexer - Checks if indexer config has an indexer and rpc_url set. - Then checks if indexer name is "bcd". + Checks if `bcdIndexer` has `rpcUrl` and `dbPassword` set. Returns the true type or empty string which is falsey. */}} {{- define "tezos.shouldDeployBcdIndexer" -}} - {{- $index_config := .Values.indexer | default dict }} - {{- if and $index_config.name $index_config.rpc_url }} - {{- if eq $index_config.name "bcd" }} - {{- "true" }} - {{- else }} - {{- "" }} - {{- end }} + {{- $indexConfig := .Values.bcdIndexer | default dict }} + {{- if and $indexConfig.indexerRpcUrl $indexConfig.dbPassword }} + {{- "true" }} + {{- else }} + {{- "" }} {{- end }} {{- end }} diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index a2682e347..3374129fc 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -1,4 +1,44 @@ {{- if (include "tezos.shouldDeployBcdIndexer" .) }} + +apiVersion: v1 +kind: Service +metadata: + name: bcd + namespace: {{ .Release.Namespace }} +spec: + ports: + - port: 14000 + name: bcd + targetPort: bcd + selector: + app: {{ .Values.bcd_indexer_statefulset.name }} + type: NodePort + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: bcd-env + namespace: {{ .Release.Namespace }} +data: + BCD_ENV: sandbox + GIN_MODE: debug + DB_HOSTNAME: localhost + SANDBOX_NODE_URI: {{ .Values.bcdIndexer.indexerRpcUrl }} + +--- +apiVersion: v1 +kind: Secret +metadata: + name: db-creds + namespace: {{ .Release.Namespace }} +data: + POSTGRES_USER: {{ b64enc .Values.bcdIndexer.dbUser }} + POSTGRES_PASSWORD: {{ b64enc .Values.bcdIndexer.dbPassword }} + POSTGRES_DB: {{ b64enc .Values.bcdIndexer.dbName }} + PGDATA: {{ b64enc "/var/lib/postgresql/data/pgdata" }} + +--- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -15,89 +55,34 @@ spec: labels: app: {{ .Values.bcd_indexer_statefulset.name }} spec: - securityContext: - fsGroup: 1000 containers: - - image: bakingbad/bcdhub-api:3.5 + - image: ghcr.io/baking-bad/bcdhub-api:4.3.0 name: api ports: - containerPort: 14000 name: bcd - volumeMounts: - - mountPath: /etc/bcd - name: shared-volume envFrom: - - configMapRef: - name: bcd-env - - configMapRef: - name: db-creds - - image: bakingbad/bcdhub-indexer:3.5 + - configMapRef: + name: bcd-env + - secretRef: + name: db-creds + - image: ghcr.io/baking-bad/bcdhub-indexer:4.3.0 name: indexer - volumeMounts: - - mountPath: /etc/bcd - name: shared-volume - envFrom: - - configMapRef: - name: bcd-env - - image: bakingbad/bcdhub-metrics:3.5 - name: metrics - volumeMounts: - - mountPath: /etc/bcd - name: shared-volume envFrom: - - configMapRef: - name: bcd-env - - configMapRef: - name: db-creds - - image: postgres:alpine + - configMapRef: + name: bcd-env + - secretRef: + name: db-creds + - image: postgres:14 name: db imagePullPolicy: IfNotPresent volumeMounts: - - mountPath: /var/lib/postgresql/ + - mountPath: /var/lib/postgresql/data name: indexer-db envFrom: - - configMapRef: - name: db-creds - - image: rabbitmq:latest - name: mq - imagePullPolicy: IfNotPresent - volumeMounts: - - mountPath: /var/lib/rabbitmq/mnesia - name: mq-data - env: - - name: RABBITMQ_DEFAULT_USER - value: guest - - name: RABBITMQ_DEFAULT_PASS - value: guest - - image: bakingbad/bcdhub-elastic:3.5 - name: elastic - volumeMounts: - - mountPath: /usr/share/elasticsearch/data - name: esdata - env: - - name: "bootstrap.memory_lock" - value: "true" - - name: "discovery.type" - value: single-node - - name: ES_JAVA_OPTS - value: "-Xms256m -Xmx256m" + - secretRef: + name: db-creds volumeClaimTemplates: - - metadata: - name: esdata - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: "300Gi" - - metadata: - name: mq-data - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: "5Gi" - metadata: name: indexer-db spec: @@ -106,36 +91,5 @@ spec: resources: requests: storage: "300Gi" - - metadata: - name: shared-volume - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: "1Gi" ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: bcd-env -data: - BCD_ENV: sandbox - GIN_MODE: debug - ELASTIC_HOSTNAME: localhost - RABBITMQ_HOSTNAME: localhost - DB_HOSTNAME: 127.0.0.1 - RABBITMQ_DEFAULT_USER: guest - RABBITMQ_DEFAULT_PASS: guest - SANDBOX_NODE_URI: {{ .Values.indexer.rpc_url }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: db-creds -data: - POSTGRES_USER: root - POSTGRES_PASSWORD: root - POSTGRES_DB: bcd {{- end }} diff --git a/charts/tezos/templates/static.yaml b/charts/tezos/templates/static.yaml index 23808d841..620fade77 100644 --- a/charts/tezos/templates/static.yaml +++ b/charts/tezos/templates/static.yaml @@ -38,19 +38,3 @@ spec: app: {{ .Values.tzkt_indexer_statefulset.name }} type: NodePort {{- end }} - ---- -{{- if (include "tezos.shouldDeployBcdIndexer" .) }} -apiVersion: v1 -kind: Service -metadata: - name: bcd - namespace: {{ .Release.Namespace }} -spec: - ports: - - port: 14000 - name: bcd - selector: - app: {{ .Values.bcd_indexer_statefulset.name }} - type: NodePort -{{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 467846f82..d3840b46e 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -410,8 +410,8 @@ protocols: ## Deploy an indexer with the chain. An indexer puts the chain ## contents in a database for efficient indexing. Most dapps need it. ## Supported indexers: -## * tzkt https://github.com/baking-bad/tzkt -# +## * tzkt: https://github.com/baking-bad/tzkt +## * bcd: https://github.com/baking-bad/bcdhub ## Templatized indexer configuration values go in the config field. ## # indexers: @@ -451,10 +451,9 @@ protocols: # # api_log_level: Debug # # indexer_log_level: Debug -# Deploy an indexer with the chain. An indexer puts the chain -# contents in a database for efficient indexing. Most dapps need it. -# Supports: -# * "bcd": Better Call Dev indexer: https://better-call.dev/ -# indexer: -# name: bcd -# rpc_url: http://tezos-node-0.tezos-node:8732 +bcdIndexer: + # dbName: bcd + # dbPassword: bcd-password + # dbUser: bcd + # indexerRpcUrl: http://archive-baking-node-0.archive-baking-node:8732 + From 0f15bf9799ebfacc8a2681f431585ddc7ff8244c Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Sun, 9 Oct 2022 18:00:56 -0400 Subject: [PATCH 32/35] Add storageClassName field --- charts/tezos/templates/bcd_indexer.yaml | 1 + charts/tezos/values.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 3374129fc..cfe4a6803 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -88,6 +88,7 @@ spec: spec: accessModes: - ReadWriteOnce + storageClassName: {{ .Values.bcdIndexer.storageClassName }} resources: requests: storage: "300Gi" diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 8b7817d91..8b10437c7 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -455,5 +455,6 @@ bcdIndexer: # dbName: bcd # dbPassword: bcd-password # dbUser: bcd + # storageClassName: "" # indexerRpcUrl: http://archive-baking-node-0.archive-baking-node:8732 From fb987b153f8c4f26abd5fd17bcab46da93da44ae Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Wed, 1 Feb 2023 17:39:49 -0500 Subject: [PATCH 33/35] Make bcd images configurable --- charts/tezos/templates/bcd_indexer.yaml | 4 ++-- charts/tezos/values.yaml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index cfe4a6803..c3aff9392 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -56,7 +56,7 @@ spec: app: {{ .Values.bcd_indexer_statefulset.name }} spec: containers: - - image: ghcr.io/baking-bad/bcdhub-api:4.3.0 + - image: {{ .Values.bcdIndexer.images.api }} name: api ports: - containerPort: 14000 @@ -66,7 +66,7 @@ spec: name: bcd-env - secretRef: name: db-creds - - image: ghcr.io/baking-bad/bcdhub-indexer:4.3.0 + - image: {{ .Values.bcdIndexer.images.indexer }} name: indexer envFrom: - configMapRef: diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 56f6bd486..5b2cea10a 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -493,6 +493,9 @@ protocols: # # indexer_log_level: Debug bcdIndexer: + images: + api: ghcr.io/baking-bad/bcdhub-api:4.3.0 + indexer: ghcr.io/baking-bad/bcdhub-indexer:4.3.0 # dbName: bcd # dbPassword: bcd-password # dbUser: bcd From f5ff84c1b0fefd070fd06759224b65758e8e283a Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Wed, 1 Feb 2023 18:23:25 -0500 Subject: [PATCH 34/35] black . --- .../pyrometer/scripts/pyrometer_exporter.py | 24 ++++--- mkchain/tqchain/mkchain.py | 1 + snapshotEngine/getAllSnapshotMetadata.py | 30 ++++---- snapshotEngine/getLatestSnapshotMetadata.py | 68 +++++++++++++------ utils/config-generator.py | 6 +- utils/sidecar.py | 25 ++++--- 6 files changed, 102 insertions(+), 52 deletions(-) diff --git a/charts/pyrometer/scripts/pyrometer_exporter.py b/charts/pyrometer/scripts/pyrometer_exporter.py index 4c2b61fbe..cdda7b21e 100644 --- a/charts/pyrometer/scripts/pyrometer_exporter.py +++ b/charts/pyrometer/scripts/pyrometer_exporter.py @@ -4,18 +4,20 @@ import datetime import logging -log = logging.getLogger('werkzeug') + +log = logging.getLogger("werkzeug") log.setLevel(logging.ERROR) application = Flask(__name__) unhealthy_bakers = set() -@application.route('/pyrometer_webhook', methods=['POST']) + +@application.route("/pyrometer_webhook", methods=["POST"]) def pyrometer_webhook(): - ''' + """ Receive all events from pyrometer - ''' + """ for msg in request.get_json(): if msg["kind"] == "baker_unhealthy": print(f"Baker {msg['baker']} is unhealthy") @@ -26,14 +28,16 @@ def pyrometer_webhook(): return "Webhook received" -@application.route('/metrics', methods=['GET']) + +@application.route("/metrics", methods=["GET"]) def prometheus_metrics(): - ''' + """ Prometheus endpoint - ''' - return f'''# total number of monitored bakers that are currently unhealthy + """ + return f"""# total number of monitored bakers that are currently unhealthy pyrometer_unhealthy_bakers_total {len(unhealthy_bakers)} -''' +""" + if __name__ == "__main__": - application.run(host = "0.0.0.0", port = 31732, debug = False) + application.run(host="0.0.0.0", port=31732, debug=False) diff --git a/mkchain/tqchain/mkchain.py b/mkchain/tqchain/mkchain.py index 704b03adb..fd0b5398a 100644 --- a/mkchain/tqchain/mkchain.py +++ b/mkchain/tqchain/mkchain.py @@ -82,6 +82,7 @@ def quoted_scalar(dumper, data): # a representer to force quotations on scalars }, } + # python versions < 3.8 doesn't have "extend" action class ExtendAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): diff --git a/snapshotEngine/getAllSnapshotMetadata.py b/snapshotEngine/getAllSnapshotMetadata.py index 2527d3018..70ec6db8f 100644 --- a/snapshotEngine/getAllSnapshotMetadata.py +++ b/snapshotEngine/getAllSnapshotMetadata.py @@ -3,10 +3,10 @@ import urllib, json import urllib.request -allSubDomains = os.environ['ALL_SUBDOMAINS'].split(",") -snapshotWebsiteBaseDomain = os.environ['SNAPSHOT_WEBSITE_DOMAIN_NAME'] +allSubDomains = os.environ["ALL_SUBDOMAINS"].split(",") +snapshotWebsiteBaseDomain = os.environ["SNAPSHOT_WEBSITE_DOMAIN_NAME"] -filename="tezos-snapshots.json" +filename = "tezos-snapshots.json" # Write empty top-level array to initialize json json_object = [] @@ -15,16 +15,18 @@ # Get each subdomain's base.json and combine all artifacts into 1 metadata file for subDomain in allSubDomains: - baseJsonUrl="https://"+subDomain+"."+snapshotWebsiteBaseDomain+"/base.json" - try: - with urllib.request.urlopen(baseJsonUrl) as url: - data = json.loads(url.read().decode()) - for entry in data: - json_object.append(entry) - except urllib.error.HTTPError: - continue + baseJsonUrl = ( + "https://" + subDomain + "." + snapshotWebsiteBaseDomain + "/base.json" + ) + try: + with urllib.request.urlopen(baseJsonUrl) as url: + data = json.loads(url.read().decode()) + for entry in data: + json_object.append(entry) + except urllib.error.HTTPError: + continue # Write to file -with open (filename, 'w') as json_file: - json_string = json.dumps(json_object, indent=4) - json_file.write(json_string) \ No newline at end of file +with open(filename, "w") as json_file: + json_string = json.dumps(json_object, indent=4) + json_file.write(json_string) diff --git a/snapshotEngine/getLatestSnapshotMetadata.py b/snapshotEngine/getLatestSnapshotMetadata.py index a7a39edcd..532385ebd 100644 --- a/snapshotEngine/getLatestSnapshotMetadata.py +++ b/snapshotEngine/getLatestSnapshotMetadata.py @@ -10,14 +10,14 @@ import pytz from genericpath import exists -filename='tezos-snapshots.json' +filename = "tezos-snapshots.json" if exists(filename): - print('SUCCESS tezos-snapshots.json exists locally!') - with open(filename,'r') as localJson: + print("SUCCESS tezos-snapshots.json exists locally!") + with open(filename, "r") as localJson: snapshots = json.load(localJson) else: - print('ERROR tezos-snapshots.json does not exist locally!') + print("ERROR tezos-snapshots.json does not exist locally!") # sort per network snapshots_per_network = {} @@ -25,9 +25,9 @@ # for some reason, the first page is empty, so we initialize the map with dummy data to generate a first page # The error is: # Error reading file /home/nochem/workspace/xtz-shots-website/_layouts/latest_snapshots.md/latest_snapshots.md: Not a directory @ rb_sysopen - /home/nochem/workspace/xtz-shots-website/_layouts/latest_snapshots.md/latest_snapshots.md -latest_snapshots = [{ "name": "example", "latest_snapshots" : {}}] +latest_snapshots = [{"name": "example", "latest_snapshots": {}}] -all_snapshots = [{ "name": "example", "all_snapshots" : {}}] +all_snapshots = [{"name": "example", "all_snapshots": {}}] for snapshot in snapshots: network = snapshot["chain_name"] @@ -40,19 +40,31 @@ network_snapshots = {} # Initialize date to now, and then update with build date as we iterate - last_tezos_build_datetime=datetime.now().replace(tzinfo=pytz.UTC) - for (type, mode, path) in [("tarball", "rolling", "rolling-tarball"), ("tarball", "archive", "archive-tarball"), ("tezos-snapshot", "rolling", "rolling")]: - + last_tezos_build_datetime = datetime.now().replace(tzinfo=pytz.UTC) + for type, mode, path in [ + ("tarball", "rolling", "rolling-tarball"), + ("tarball", "archive", "archive-tarball"), + ("tezos-snapshot", "rolling", "rolling"), + ]: # Parses date from tezos build of each artifact, compares to last date, updates if older, otherwise its newer for snapshot in snapshots: - matches=datefinder.find_dates(snapshot['tezos_version']) - tezos_build_datetime=list(matches)[0] + matches = datefinder.find_dates(snapshot["tezos_version"]) + tezos_build_datetime = list(matches)[0] if tezos_build_datetime < last_tezos_build_datetime: - latest_tezos_build_version=[src for time, src in datefinder.find_dates(snapshot['tezos_version'], source=True)][1] - last_tezos_build_datetime=tezos_build_datetime + latest_tezos_build_version = [ + src + for time, src in datefinder.find_dates( + snapshot["tezos_version"], source=True + ) + ][1] + last_tezos_build_datetime = tezos_build_datetime # Snapshots of type (tarball/snapshot) and history mode - typed_snapshots = [s for s in snapshots if s["artifact_type"] == type and s["history_mode"] == mode] + typed_snapshots = [ + s + for s in snapshots + if s["artifact_type"] == type and s["history_mode"] == mode + ] typed_snapshots.sort(key=lambda x: int(x["block_height"]), reverse=True) try: @@ -62,7 +74,11 @@ continue # Latest should only show oldest supported build so let's filter by the oldest supported version we found above - typed_snapshots=[t for t in typed_snapshots if latest_tezos_build_version in t['tezos_version']] + typed_snapshots = [ + t + for t in typed_snapshots + if latest_tezos_build_version in t["tezos_version"] + ] try: # Latest snapshot of type is the first item in typed_snapshots which we just filtered by the latest supported tezos build @@ -71,10 +87,24 @@ continue latest_snapshots.append( - { "name": network, "permalink": network+"/index.html", "latest_snapshots": network_latest_snapshots }) + { + "name": network, + "permalink": network + "/index.html", + "latest_snapshots": network_latest_snapshots, + } + ) all_snapshots.append( - { "name": network, "permalink": network+"/list.html", "snapshots": network_snapshots }) + { + "name": network, + "permalink": network + "/list.html", + "snapshots": network_snapshots, + } + ) Path("_data").mkdir(parents=True, exist_ok=True) -with open(f"_data/snapshot_jekyll_data.json", 'w') as f: - json.dump({"latest_snapshots": latest_snapshots, "all_snapshots": all_snapshots}, f, indent=2) +with open(f"_data/snapshot_jekyll_data.json", "w") as f: + json.dump( + {"latest_snapshots": latest_snapshots, "all_snapshots": all_snapshots}, + f, + indent=2, + ) diff --git a/utils/config-generator.py b/utils/config-generator.py index 7b0dcf62b..45cf8ba4b 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -627,7 +627,11 @@ def create_node_snapshot_config_json(history_mode): """Create this node's snapshot config""" network_name = NETWORK_CONFIG.get("chain_name") - prefer_tarballs = os.environ.get("PREFER_TARBALLS", "").lower() in ("true", "1", "t") + prefer_tarballs = os.environ.get("PREFER_TARBALLS", "").lower() in ( + "true", + "1", + "t", + ) artifact_type = "tarball" if prefer_tarballs else "tezos-snapshot" rolling_tarball_url = os.environ.get("ROLLING_TARBALL_URL") full_tarball_url = os.environ.get("FULL_TARBALL_URL") diff --git a/utils/sidecar.py b/utils/sidecar.py index 0185b2909..085b149bb 100755 --- a/utils/sidecar.py +++ b/utils/sidecar.py @@ -5,24 +5,26 @@ import datetime import logging -log = logging.getLogger('werkzeug') + +log = logging.getLogger("werkzeug") log.setLevel(logging.ERROR) application = Flask(__name__) AGE_LIMIT_IN_SECS = 600 -@application.route('/is_synced') + +@application.route("/is_synced") def sync_checker(): - ''' + """ Here we don't trust the /is_bootstrapped endpoint of octez-node. We have seen it return true when the node is in a bad state (for example, some crashed threads) Instead, we query the head block and verify timestamp is not too old. - ''' + """ try: - r = requests.get('http://127.0.0.1:8732/chains/main/blocks/head/header') + r = requests.get("http://127.0.0.1:8732/chains/main/blocks/head/header") except requests.exceptions.RequestException as e: err = "Could not connect to node, %s" % repr(e), 500 print(err) @@ -34,13 +36,20 @@ def sync_checker(): # otherwise it will never activate (activation uses rpc service) return "Chain has not been activated yet" timestamp = r.json()["timestamp"] - block_age = datetime.datetime.utcnow() - datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%SZ') + block_age = datetime.datetime.utcnow() - datetime.datetime.strptime( + timestamp, "%Y-%m-%dT%H:%M:%SZ" + ) age_in_secs = block_age.total_seconds() if age_in_secs > AGE_LIMIT_IN_SECS: - err = "Error: Chain head is %s secs old, older than %s" % ( age_in_secs, AGE_LIMIT_IN_SECS), 500 + err = ( + "Error: Chain head is %s secs old, older than %s" + % (age_in_secs, AGE_LIMIT_IN_SECS), + 500, + ) print(err) return err return "Chain is bootstrapped" + if __name__ == "__main__": - application.run(host = "0.0.0.0", port = 31732, debug = False) + application.run(host="0.0.0.0", port=31732, debug=False) From bf640b490c5e70f0cdd6e5a2c039a4ff7a47ca23 Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Wed, 1 Feb 2023 18:41:03 -0500 Subject: [PATCH 35/35] Update BCD indexer to 4.4.0 --- charts/tezos/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 5b2cea10a..df3ef5a92 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -494,8 +494,8 @@ protocols: bcdIndexer: images: - api: ghcr.io/baking-bad/bcdhub-api:4.3.0 - indexer: ghcr.io/baking-bad/bcdhub-indexer:4.3.0 + api: ghcr.io/baking-bad/bcdhub-api:4.4.0 + indexer: ghcr.io/baking-bad/bcdhub-indexer:4.4.0 # dbName: bcd # dbPassword: bcd-password # dbUser: bcd