From f7a82bacd0154dffbf3f555d415c77df08fb9283 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Fri, 11 Nov 2022 17:04:35 -0800 Subject: [PATCH 001/206] tilt + PO + localnet --- Tiltfile | 60 +++++++++++++++ build/localnet/cli-client.yaml | 25 ++++++ build/localnet/network.yaml | 16 ++++ build/localnet/postgres-database.yaml | 21 ++++++ build/localnet/private-keys.yaml | 11 +++ build/localnet/validators.yaml | 105 ++++++++++++++++++++++++++ 6 files changed, 238 insertions(+) create mode 100644 Tiltfile create mode 100644 build/localnet/cli-client.yaml create mode 100644 build/localnet/network.yaml create mode 100644 build/localnet/postgres-database.yaml create mode 100644 build/localnet/private-keys.yaml create mode 100644 build/localnet/validators.yaml diff --git a/Tiltfile b/Tiltfile new file mode 100644 index 000000000..f5cf4eb3c --- /dev/null +++ b/Tiltfile @@ -0,0 +1,60 @@ +# Verify pocket operator is available in the parent directory. We use pocket operator to maintain the workloads. +if not os.path.exists('../pocket-operator'): + fail('Please "git clone" the git@github.com:pokt-network/pocket-operator.git repo in ../pocket-operator!') + +# TODO(@okdas): add check if the pocket-operator directory has no changes vs the remote and is behind the remote +# to pull the latest changes. This will allow to iterate on operator at the same time as having working localnet, +# but will also allow to get latest changes from the operator repo for developers who don't work on operator. +include('../pocket-operator/Tiltfile') + +# Validators require postgres database - let's install the operator that manages databases in cluster. +is_psql_operator_installed = str(local('kubectl api-resources | grep postgres | grep zalan.do | wc -l')).strip() +if is_psql_operator_installed == '0': + print('Installing postgres operator') + local('kubectl apply -k github.com/zalando/postgres-operator/manifests') + +# Builds the pocket binary. Note target OS is linux, because it later will be run in a container. +local_resource('pocket: Watch & Compile', 'GOOS=linux go build -o bin/pocket-linux app/pocket/main.go', deps=['**/**.go']) +local_resource('client: Watch & Compile', 'GOOS=linux go build -o bin/client-linux app/client/main.go', deps=['**/**.go']) + +# Builds and maintains the container after the binary is built on machine +docker_build('validator-image', '.', + dockerfile_contents='''FROM debian:bullseye +WORKDIR / +COPY bin/pocket-linux /usr/local/bin/pocket +CMD ["/usr/local/bin/pocket"] +''', + only=['./bin/pocket-linux'], + live_update=[ + sync('./bin/pocket-linux', '/usr/local/bin/pocket'), + ] +) + +docker_build('client-image', '.', + dockerfile_contents='''FROM debian:bullseye +WORKDIR / +COPY bin/client-linux /usr/local/bin/client +CMD ["/usr/local/bin/client"] +''', + only=['./bin/client-linux'], + live_update=[ + sync('./bin/client-linux', '/usr/local/bin/client'), + ] +) + +# Makes Tilt aware of our own custom resource, so it can work with our operator. +k8s_kind('PocketValidator', image_json_path='{.spec.pocketImage}') + +# Pushes localnet manifests to the cluster. +k8s_yaml([ + 'build/localnet/postgres-database.yaml', + 'build/localnet/private-keys.yaml', + 'build/localnet/validators.yaml', + 'build/localnet/cli-client.yaml', + 'build/localnet/network.yaml']) + +k8s_resource(new_name='postgres', + objects=['pocket-database:postgresql'], + extra_pod_selectors=[{'cluster-name': 'pocket-database'}], + port_forwards=5432) + diff --git a/build/localnet/cli-client.yaml b/build/localnet/cli-client.yaml new file mode 100644 index 000000000..432ded80f --- /dev/null +++ b/build/localnet/cli-client.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Pod +metadata: + name: pocket-v1-client + namespace: default +spec: + containers: + - name: pocket + image: client-image + imagePullPolicy: IfNotPresent + command: ["sleep", "infinity"] + volumeMounts: + - mountPath: /var/pocket/config + name: config-volume + - mountPath: /var/pocket/genesis + name: genesis-volume + volumes: + - name: config-volume + configMap: + name: v1-validator1-config + defaultMode: 420 + - name: genesis-volume + configMap: + name: default-genesis + defaultMode: 420 diff --git a/build/localnet/network.yaml b/build/localnet/network.yaml new file mode 100644 index 000000000..027167a7f --- /dev/null +++ b/build/localnet/network.yaml @@ -0,0 +1,16 @@ +apiVersion: nodes.pokt.network/v1alpha1 +kind: PocketSet +metadata: + name: default +spec: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: pocket-validators +spec: + selector: + v1-purpose: validator + ports: + - port: 50832 + targetPort: 50832 diff --git a/build/localnet/postgres-database.yaml b/build/localnet/postgres-database.yaml new file mode 100644 index 000000000..fca86afca --- /dev/null +++ b/build/localnet/postgres-database.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: "acid.zalan.do/v1" +kind: postgresql +metadata: + name: pocket-database + namespace: default +spec: + teamId: pocket + volume: + size: 1Gi + numberOfInstances: 1 + users: + validator: # database owner + - superuser + - createdb + databases: + validatordb: validator + preparedDatabases: + bar: {} + postgresql: + version: "14" diff --git a/build/localnet/private-keys.yaml b/build/localnet/private-keys.yaml new file mode 100644 index 000000000..bb29f73ab --- /dev/null +++ b/build/localnet/private-keys.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: private-keys + namespace: default +type: Opaque +stringData: + 6f66574e1f50f0ef72dff748c3f11b9e0e89d32a: "6fd0bc54cc2dd205eaf226eebdb0451629b321f11d279013ce6fdd5a33059256b2eda2232ffb2750bf761141f70f75a03a025f65b2b2b417c7f8b3c9ca91e8e4" + 67eb3f0a50ae459fecf666be0e93176e92441317: "b37d3ba2f232060c41ba1177fea6008d885fcccad6826d64ee7d49f94d1dbc49a8b6be75d7551da093f788f7286c3a9cb885cfc8e52710eac5f1d5e5b4bf19b2" + 3f52e08c4b3b65ab7cf098d77df5bf8cedcf5f99: "c7bd1bd027e76b31534c3f5226c8e3c3f2a034ba9fa11017b65191f7f9ef0d253e5e4bbed5f98721163bb84445072a9202d213f1e348c5e9e0e2ea83bbb7e3aa" + 113fdb095d42d6e09327ab5b8df13fd8197a1eaf: "c6c136d010d07d7f5e9944aa3594a10f9210dd3e26ebc1bc1516a6d957fd0df353ee26c82826694ffe1773d7b60d5f20dd9e91bdf8745544711bec5ff9c6fb4a" diff --git a/build/localnet/validators.yaml b/build/localnet/validators.yaml new file mode 100644 index 000000000..32738a716 --- /dev/null +++ b/build/localnet/validators.yaml @@ -0,0 +1,105 @@ +apiVersion: nodes.pokt.network/v1alpha1 +kind: PocketValidator +metadata: + name: v1-validator1 +spec: + collection: + name: "default" + pocketImage: validator-image + privateKey: + secretKeyRef: + name: private-keys + key: 6f66574e1f50f0ef72dff748c3f11b9e0e89d32a + postgres: + user: + secretKeyRef: + name: validator.pocket-database.credentials.postgresql.acid.zalan.do + key: username + password: + secretKeyRef: + name: validator.pocket-database.credentials.postgresql.acid.zalan.do + key: password + host: pocket-database + port: "5432" + database: validatordb + schema: validator1 +--- +apiVersion: nodes.pokt.network/v1alpha1 +kind: PocketValidator +metadata: + name: v1-validator2 +spec: + collection: + name: "default" + pocketImage: validator-image + privateKey: + secretKeyRef: + name: private-keys + key: 67eb3f0a50ae459fecf666be0e93176e92441317 + postgres: + user: + secretKeyRef: + name: validator.pocket-database.credentials.postgresql.acid.zalan.do + key: username + password: + secretKeyRef: + name: validator.pocket-database.credentials.postgresql.acid.zalan.do + key: password + host: pocket-database + port: "5432" + database: validatordb + schema: validator2 +--- +apiVersion: nodes.pokt.network/v1alpha1 +kind: PocketValidator +metadata: + name: v1-validator3 +spec: + collection: + name: "default" + pocketImage: validator-image + privateKey: + secretKeyRef: + name: private-keys + key: 3f52e08c4b3b65ab7cf098d77df5bf8cedcf5f99 + postgres: + user: + secretKeyRef: + name: validator.pocket-database.credentials.postgresql.acid.zalan.do + key: username + password: + secretKeyRef: + name: validator.pocket-database.credentials.postgresql.acid.zalan.do + key: password + host: pocket-database + port: "5432" + database: validatordb + schema: validator3 +--- +apiVersion: nodes.pokt.network/v1alpha1 +kind: PocketValidator +metadata: + name: v1-validator4 +spec: + collection: + name: "default" + pocketImage: validator-image + privateKey: + secretKeyRef: + name: private-keys + key: 113fdb095d42d6e09327ab5b8df13fd8197a1eaf + postgres: + user: + secretKeyRef: + name: validator.pocket-database.credentials.postgresql.acid.zalan.do + key: username + password: + secretKeyRef: + name: validator.pocket-database.credentials.postgresql.acid.zalan.do + key: password + host: pocket-database + port: "5432" + database: validatordb + schema: validator4 +--- + From 62683a55087cbfc4c6c14d1f7e18991ad97c2135 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Fri, 11 Nov 2022 18:00:41 -0800 Subject: [PATCH 002/206] --wip-- [skip ci] --- Dockerfile | 7 +++++ Tiltfile | 10 +++++-- app/pocket/main.go | 2 ++ build/localnet/restart.sh | 25 ++++++++++++++++ build/localnet/start.sh | 44 +++++++++++++++++++++++++++++ build/localnet/validator.dockerfile | 7 +++++ 6 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 build/localnet/restart.sh create mode 100644 build/localnet/start.sh create mode 100644 build/localnet/validator.dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..ab88c5999 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM debian:bullseye +WORKDIR / +COPY build/localnet/start.sh /start.sh +COPY build/localnet/restart.sh /restart.sh +COPY bin/pocket-linux /usr/local/bin/pocket +CMD ["/usr/local/bin/pocket"] +ENTRYPOINT ["/start.sh", "/usr/local/bin/pocket"] diff --git a/Tiltfile b/Tiltfile index f5cf4eb3c..ef93763ef 100644 --- a/Tiltfile +++ b/Tiltfile @@ -1,3 +1,5 @@ +# TODO: add resource dependencies + # Verify pocket operator is available in the parent directory. We use pocket operator to maintain the workloads. if not os.path.exists('../pocket-operator'): fail('Please "git clone" the git@github.com:pokt-network/pocket-operator.git repo in ../pocket-operator!') @@ -14,19 +16,23 @@ if is_psql_operator_installed == '0': local('kubectl apply -k github.com/zalando/postgres-operator/manifests') # Builds the pocket binary. Note target OS is linux, because it later will be run in a container. -local_resource('pocket: Watch & Compile', 'GOOS=linux go build -o bin/pocket-linux app/pocket/main.go', deps=['**/**.go']) +local_resource('pocket: Watch & Compile', 'GOOS=linux go build -o bin/pocket-linux app/pocket/main.go', deps=['app/pocket/main.go']) local_resource('client: Watch & Compile', 'GOOS=linux go build -o bin/client-linux app/client/main.go', deps=['**/**.go']) # Builds and maintains the container after the binary is built on machine docker_build('validator-image', '.', dockerfile_contents='''FROM debian:bullseye -WORKDIR / +COPY build/localnet/start.sh /start.sh +COPY build/localnet/restart.sh /restart.sh COPY bin/pocket-linux /usr/local/bin/pocket +WORKDIR / CMD ["/usr/local/bin/pocket"] +ENTRYPOINT ["/start.sh", "/usr/local/bin/pocket"] ''', only=['./bin/pocket-linux'], live_update=[ sync('./bin/pocket-linux', '/usr/local/bin/pocket'), + run('/restart.sh'), ] ) diff --git a/app/pocket/main.go b/app/pocket/main.go index f49f015ac..8a11a03d2 100644 --- a/app/pocket/main.go +++ b/app/pocket/main.go @@ -18,6 +18,8 @@ func main() { v := flag.Bool("version", false, "") flag.Parse() + // log.Println("Starting Pocket Core", version) + if *v { log.Printf("Version flag currently unused %s\n", version) return diff --git a/build/localnet/restart.sh b/build/localnet/restart.sh new file mode 100644 index 000000000..e0e5dd76c --- /dev/null +++ b/build/localnet/restart.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# A helper script to restart a given process as part of a Live Update. +# +# Further reading: +# https://docs.tilt.dev/live_update_reference.html#restarting-your-process +# +# Usage: +# Copy start.sh and restart.sh to your container working dir. +# +# Make your container entrypoint: +# ./start.sh path-to-binary [args] +# +# To restart the container: +# ./restart.sh + +set -u + +touch restart.txt +PID="$(cat process.txt)" +if [ $? -ne 0 ]; then + echo "unable to read process.txt. was your process started with start.sh?" + exit 1 +fi +kill "$PID" diff --git a/build/localnet/start.sh b/build/localnet/start.sh new file mode 100644 index 000000000..ec7f09083 --- /dev/null +++ b/build/localnet/start.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# +# A helper script to restart a given process as part of a Live Update. +# +# Further reading: +# https://docs.tilt.dev/live_update_reference.html#restarting-your-process +# +# Usage: +# Copy start.sh and restart.sh to your container working dir. +# +# Make your container entrypoint: +# ./start.sh path-to-binary [args] +# +# To restart the container: +# ./restart.sh + +set -eu + +process_id="" + +trap quit TERM INT + +quit() { + if [ -n "$process_id" ]; then + kill $process_id + fi +} + +while true; do + rm -f restart.txt + + "$@" & + process_id=$! + echo "$process_id" >process.txt + set +e + wait $process_id + EXIT_CODE=$? + set -e + if [ ! -f restart.txt ]; then + echo "Exiting with code $EXIT_CODE" + exit $EXIT_CODE + fi + echo "Restarting" +done diff --git a/build/localnet/validator.dockerfile b/build/localnet/validator.dockerfile new file mode 100644 index 000000000..ab88c5999 --- /dev/null +++ b/build/localnet/validator.dockerfile @@ -0,0 +1,7 @@ +FROM debian:bullseye +WORKDIR / +COPY build/localnet/start.sh /start.sh +COPY build/localnet/restart.sh /restart.sh +COPY bin/pocket-linux /usr/local/bin/pocket +CMD ["/usr/local/bin/pocket"] +ENTRYPOINT ["/start.sh", "/usr/local/bin/pocket"] From 67132ebf372fe9a7277c20717a7afd41c3ed4596 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 14 Nov 2022 16:59:44 -0800 Subject: [PATCH 003/206] --wip-- [skip ci] --- Tiltfile | 34 +++++++++++++++++++++++------ app/client/cli/debug.go | 13 ++++++++--- app/pocket/main.go | 2 -- build/localnet/cli-client.yaml | 5 +++++ build/localnet/restart.sh | 0 build/localnet/start.sh | 0 build/localnet/validator.dockerfile | 7 ------ 7 files changed, 42 insertions(+), 19 deletions(-) mode change 100644 => 100755 build/localnet/restart.sh mode change 100644 => 100755 build/localnet/start.sh delete mode 100644 build/localnet/validator.dockerfile diff --git a/Tiltfile b/Tiltfile index ef93763ef..c0f02dbce 100644 --- a/Tiltfile +++ b/Tiltfile @@ -1,4 +1,20 @@ -# TODO: add resource dependencies +# TODO: add resource dependencies https://docs.tilt.dev/resource_dependencies.html#adding-resource_deps-for-startup-order + +# List of directories Tilt watches to trigger a hot-reload on changes +deps = [ + 'app', + 'build', + 'consensus', + 'p2p', + 'persistance', + 'rpc', + 'runtime', + 'shared', + 'telemetry', + 'utility', + 'vendor', + 'logger' +] # Verify pocket operator is available in the parent directory. We use pocket operator to maintain the workloads. if not os.path.exists('../pocket-operator'): @@ -16,10 +32,12 @@ if is_psql_operator_installed == '0': local('kubectl apply -k github.com/zalando/postgres-operator/manifests') # Builds the pocket binary. Note target OS is linux, because it later will be run in a container. -local_resource('pocket: Watch & Compile', 'GOOS=linux go build -o bin/pocket-linux app/pocket/main.go', deps=['app/pocket/main.go']) -local_resource('client: Watch & Compile', 'GOOS=linux go build -o bin/client-linux app/client/main.go', deps=['**/**.go']) +local_resource('pocket: Watch & Compile', 'GOOS=linux go build -o bin/pocket-linux app/pocket/main.go', deps=deps) +local_resource('debug client: Watch & Compile', 'GOOS=linux go build -tags=debug -o bin/client-linux app/client/*.go', deps=deps) +# go run -tags=debug app/client/*.go debug +# local_resource('client: Watch & Compile', 'GOOS=linux go build -o bin/client-linux app/client/main.go', deps=deps) -# Builds and maintains the container after the binary is built on machine +# Builds and maintains the validator container image after the binary is built on local machine docker_build('validator-image', '.', dockerfile_contents='''FROM debian:bullseye COPY build/localnet/start.sh /start.sh @@ -27,15 +45,16 @@ COPY build/localnet/restart.sh /restart.sh COPY bin/pocket-linux /usr/local/bin/pocket WORKDIR / CMD ["/usr/local/bin/pocket"] -ENTRYPOINT ["/start.sh", "/usr/local/bin/pocket"] +ENTRYPOINT ["/start.sh", "/usr/local/bin/pocket", "-config=/configs/config.json", "-genesis=/genesis.json"] ''', - only=['./bin/pocket-linux'], + only=['./bin/pocket-linux', './build/'], live_update=[ sync('./bin/pocket-linux', '/usr/local/bin/pocket'), run('/restart.sh'), ] ) +# Builds and maintains the client container image after the binary is built on local machine docker_build('client-image', '.', dockerfile_contents='''FROM debian:bullseye WORKDIR / @@ -48,7 +67,7 @@ CMD ["/usr/local/bin/client"] ] ) -# Makes Tilt aware of our own custom resource, so it can work with our operator. +# Makes Tilt aware of our own Custom Resource Definition from pocket-operator, so it can work with our operator. k8s_kind('PocketValidator', image_json_path='{.spec.pocketImage}') # Pushes localnet manifests to the cluster. @@ -59,6 +78,7 @@ k8s_yaml([ 'build/localnet/cli-client.yaml', 'build/localnet/network.yaml']) +# Exposes postgres port to 5432 on the host machine. k8s_resource(new_name='postgres', objects=['pocket-database:postgresql'], extra_pod_selectors=[{'cluster-name': 'pocket-database'}], diff --git a/app/client/cli/debug.go b/app/client/cli/debug.go index 3c6026603..b46dddaaf 100644 --- a/app/client/cli/debug.go +++ b/app/client/cli/debug.go @@ -27,9 +27,6 @@ const ( PromptTriggerNextView string = "TriggerNextView" PromptTogglePacemakerMode string = "TogglePacemakerMode" PromptShowLatestBlockInStore string = "ShowLatestBlockInStore" - - defaultConfigPath = "build/config/config1.json" - defaultGenesisPath = "build/config/genesis.json" ) var ( @@ -47,6 +44,9 @@ var ( PromptTogglePacemakerMode, PromptShowLatestBlockInStore, } + + defaultConfigPath = getEnv("CONFIG_PATH", "build/config/config1.json") + defaultGenesisPath = getEnv("GENESIS_PATH", "build/config/genesis.json") ) func init() { @@ -75,6 +75,13 @@ func runDebug(cmd *cobra.Command, args []string) (err error) { } } +func getEnv(key, fallback string) string { + if value, ok := os.LookupEnv(key); ok { + return value + } + return fallback +} + func promptGetInput() (string, error) { prompt := promptui.Select{ Label: "Select an action", diff --git a/app/pocket/main.go b/app/pocket/main.go index 8a11a03d2..f49f015ac 100644 --- a/app/pocket/main.go +++ b/app/pocket/main.go @@ -18,8 +18,6 @@ func main() { v := flag.Bool("version", false, "") flag.Parse() - // log.Println("Starting Pocket Core", version) - if *v { log.Printf("Version flag currently unused %s\n", version) return diff --git a/build/localnet/cli-client.yaml b/build/localnet/cli-client.yaml index 432ded80f..da9a6d30e 100644 --- a/build/localnet/cli-client.yaml +++ b/build/localnet/cli-client.yaml @@ -9,6 +9,11 @@ spec: image: client-image imagePullPolicy: IfNotPresent command: ["sleep", "infinity"] + env: + - name: CONFIG_PATH + value: "/var/pocket/config/config.json" + - name: GENESIS_PATH + value: "/var/pocket/genesis/genesis.json" volumeMounts: - mountPath: /var/pocket/config name: config-volume diff --git a/build/localnet/restart.sh b/build/localnet/restart.sh old mode 100644 new mode 100755 diff --git a/build/localnet/start.sh b/build/localnet/start.sh old mode 100644 new mode 100755 diff --git a/build/localnet/validator.dockerfile b/build/localnet/validator.dockerfile deleted file mode 100644 index ab88c5999..000000000 --- a/build/localnet/validator.dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM debian:bullseye -WORKDIR / -COPY build/localnet/start.sh /start.sh -COPY build/localnet/restart.sh /restart.sh -COPY bin/pocket-linux /usr/local/bin/pocket -CMD ["/usr/local/bin/pocket"] -ENTRYPOINT ["/start.sh", "/usr/local/bin/pocket"] From 764c722beb50b768b99952bf006a78e26400f972 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Fri, 18 Nov 2022 17:45:45 -0800 Subject: [PATCH 004/206] observability stack --- .tiltignore | 2 + Tiltfile | 17 +++++- build/localnet/observability-stack/.gitignore | 2 + .../localnet/observability-stack/.tiltignore | 2 + build/localnet/observability-stack/Chart.yaml | 5 ++ .../observability-stack/requirements.yaml | 17 ++++++ .../templates/_helpers.tpl | 58 +++++++++++++++++++ .../templates/datasources.yml | 49 ++++++++++++++++ .../localnet/observability-stack/values.yaml | 57 ++++++++++++++++++ 9 files changed, 207 insertions(+), 2 deletions(-) create mode 100644 .tiltignore create mode 100644 build/localnet/observability-stack/.gitignore create mode 100644 build/localnet/observability-stack/.tiltignore create mode 100644 build/localnet/observability-stack/Chart.yaml create mode 100644 build/localnet/observability-stack/requirements.yaml create mode 100644 build/localnet/observability-stack/templates/_helpers.tpl create mode 100644 build/localnet/observability-stack/templates/datasources.yml create mode 100644 build/localnet/observability-stack/values.yaml diff --git a/.tiltignore b/.tiltignore new file mode 100644 index 000000000..8bc82e411 --- /dev/null +++ b/.tiltignore @@ -0,0 +1,2 @@ +**/charts +**/tmpcharts diff --git a/Tiltfile b/Tiltfile index c0f02dbce..57f8a64d8 100644 --- a/Tiltfile +++ b/Tiltfile @@ -1,9 +1,12 @@ +load('ext://helm_resource', 'helm_resource', 'helm_repo') +load('ext://namespace', 'namespace_create') + # TODO: add resource dependencies https://docs.tilt.dev/resource_dependencies.html#adding-resource_deps-for-startup-order # List of directories Tilt watches to trigger a hot-reload on changes deps = [ 'app', - 'build', + # 'build', 'consensus', 'p2p', 'persistance', @@ -31,6 +34,16 @@ if is_psql_operator_installed == '0': print('Installing postgres operator') local('kubectl apply -k github.com/zalando/postgres-operator/manifests') +# Deploy observability stack (grafana, prometheus, loki) and wire it up with localnet +# TODO(@okdas): check if helm cli is available. +helm_repo('grafana', 'https://grafana.github.io/helm-charts') +helm_repo('prometheus-community', 'https://prometheus-community.github.io/helm-charts') + +if not os.path.exists('build/localnet/observability-stack/charts'): + local('helm dependency build build/localnet/observability-stack') +namespace_create('observability') +k8s_yaml(helm("build/localnet/observability-stack", name='observability-stack', namespace="observability")) + # Builds the pocket binary. Note target OS is linux, because it later will be run in a container. local_resource('pocket: Watch & Compile', 'GOOS=linux go build -o bin/pocket-linux app/pocket/main.go', deps=deps) local_resource('debug client: Watch & Compile', 'GOOS=linux go build -tags=debug -o bin/client-linux app/client/*.go', deps=deps) @@ -75,7 +88,7 @@ k8s_yaml([ 'build/localnet/postgres-database.yaml', 'build/localnet/private-keys.yaml', 'build/localnet/validators.yaml', - 'build/localnet/cli-client.yaml', + 'build/localnet/cli-client.yaml', # TODO(@okdas): switch to https://github.com/tilt-dev/tilt-extensions/tree/master/deployment 'build/localnet/network.yaml']) # Exposes postgres port to 5432 on the host machine. diff --git a/build/localnet/observability-stack/.gitignore b/build/localnet/observability-stack/.gitignore new file mode 100644 index 000000000..28ebd32d3 --- /dev/null +++ b/build/localnet/observability-stack/.gitignore @@ -0,0 +1,2 @@ +charts +requirements.lock diff --git a/build/localnet/observability-stack/.tiltignore b/build/localnet/observability-stack/.tiltignore new file mode 100644 index 000000000..28ebd32d3 --- /dev/null +++ b/build/localnet/observability-stack/.tiltignore @@ -0,0 +1,2 @@ +charts +requirements.lock diff --git a/build/localnet/observability-stack/Chart.yaml b/build/localnet/observability-stack/Chart.yaml new file mode 100644 index 000000000..1ecb22e9b --- /dev/null +++ b/build/localnet/observability-stack/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: "v1" +name: observability-stack +version: 0.0.1 +appVersion: v0.0.1 +description: "Helm chart for deploying the observability stack. This chart is mostly used for managing observability dependencies and wiring them up together." diff --git a/build/localnet/observability-stack/requirements.yaml b/build/localnet/observability-stack/requirements.yaml new file mode 100644 index 000000000..d74e06e68 --- /dev/null +++ b/build/localnet/observability-stack/requirements.yaml @@ -0,0 +1,17 @@ +dependencies: + - name: "loki" + condition: loki.enabled + repository: "https://grafana.github.io/helm-charts" + version: "^2.15.2" + - name: "promtail" + condition: promtail.enabled + repository: "https://grafana.github.io/helm-charts" + version: "^6.6.1" + - name: "grafana" + condition: grafana.enabled + version: "~6.43.0" + repository: "https://grafana.github.io/helm-charts" + - name: "prometheus" + condition: prometheus.enabled + version: "~15.5.3" + repository: "https://prometheus-community.github.io/helm-charts" diff --git a/build/localnet/observability-stack/templates/_helpers.tpl b/build/localnet/observability-stack/templates/_helpers.tpl new file mode 100644 index 000000000..60dd484ac --- /dev/null +++ b/build/localnet/observability-stack/templates/_helpers.tpl @@ -0,0 +1,58 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "observability-stack.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "observability-stack.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "observability-stack.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Override the naming defined by the prometheus chart. +Added as a fix for https://github.com/grafana/loki/issues/1169 +*/}} +{{- define "prometheus.fullname" -}} +{{- printf "%s-%s" .Release.Name "prometheus-server" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +The service name to connect to Loki. Defaults to the same logic as "loki.fullname" +*/}} +{{- define "loki.serviceName" -}} +{{- if .Values.loki.serviceName -}} +{{- .Values.loki.serviceName -}} +{{- else if .Values.loki.fullnameOverride -}} +{{- .Values.loki.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default "loki" .Values.loki.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/build/localnet/observability-stack/templates/datasources.yml b/build/localnet/observability-stack/templates/datasources.yml new file mode 100644 index 000000000..b8ed80d15 --- /dev/null +++ b/build/localnet/observability-stack/templates/datasources.yml @@ -0,0 +1,49 @@ +{{- if .Values.grafana.sidecar.datasources.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "observability-stack.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "observability-stack.name" . }} + chart: {{ template "observability-stack.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- if .Values.grafana.sidecar.datasources.label }} + {{ .Values.grafana.sidecar.datasources.label }}: {{ .Values.grafana.sidecar.datasources.labelValue | quote }} + {{- else }} + grafana_datasource: "1" + {{- end }} +data: + observability-stack-datasource.yaml: |- + apiVersion: 1 + datasources: +{{- if .Values.loki.enabled }} + - name: Loki + type: loki + access: proxy + url: {{ tpl .Values.loki.url . | quote }} + version: 1 + isDefault: {{ default false .Values.loki.isDefault }} + {{- with .Values.loki.datasource.uid }} + uid: {{ . | quote }} + {{- end }} + {{- with .Values.loki.datasource.jsonData }} + jsonData: + {{- tpl . $ | nindent 8 }} + {{- end }} +{{- end }} + +{{- if .Values.prometheus.enabled }} + - name: Prometheus + type: prometheus + access: proxy + url: {{ tpl .Values.prometheus.url . | quote }} + version: 1 + isDefault: {{ default false .Values.prometheus.isDefault }} + {{- with .Values.prometheus.datasource.jsonData }} + jsonData: + {{- tpl . $ | nindent 8 }} + {{- end }} +{{- end }} +{{- end }} diff --git a/build/localnet/observability-stack/values.yaml b/build/localnet/observability-stack/values.yaml new file mode 100644 index 000000000..1f544e9fc --- /dev/null +++ b/build/localnet/observability-stack/values.yaml @@ -0,0 +1,57 @@ +grafana: + enabled: true + sidecar: + datasources: + label: "" + labelValue: "" + enabled: true + maxLines: 1000 + image: + tag: 8.3.5 + grafana.ini: + auth: + disable_login_form: true + disable_signout_menu: true + anonymous: + enabled: true + org_role: Admin + org_name: Pocket v1 LocalNet + users: + allow_sign_up: false + allow_org_create: false + auto_assign_org: true + auto_assign_org_role: Admin + auto_assign_org_id: 1 + +loki: + enabled: true + isDefault: true + url: http://{{(include "loki.serviceName" .)}}:{{ .Values.loki.service.port }} + readinessProbe: + httpGet: + path: /ready + port: http-metrics + initialDelaySeconds: 45 + livenessProbe: + httpGet: + path: /ready + port: http-metrics + initialDelaySeconds: 45 + datasource: + jsonData: {} + uid: "" + +promtail: + enabled: true + config: + logLevel: info + serverPort: 3101 + clients: + - url: http://{{ .Release.Name }}:3100/loki/api/v1/push + +prometheus: + enabled: false + isDefault: false + url: http://{{ include "prometheus.fullname" .}}:{{ .Values.prometheus.server.service.servicePort }}{{ .Values.prometheus.server.prefixURL }} + datasource: + jsonData: {} From c2c0fd5587fd7d79e3c7184e3ca72d403236834f Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 21 Nov 2022 14:05:36 -0800 Subject: [PATCH 005/206] --wip-- [skip ci] --- Tiltfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Tiltfile b/Tiltfile index 57f8a64d8..90ee8faa0 100644 --- a/Tiltfile +++ b/Tiltfile @@ -2,6 +2,7 @@ load('ext://helm_resource', 'helm_resource', 'helm_repo') load('ext://namespace', 'namespace_create') # TODO: add resource dependencies https://docs.tilt.dev/resource_dependencies.html#adding-resource_deps-for-startup-order +# - validators depend on postgres # List of directories Tilt watches to trigger a hot-reload on changes deps = [ From 2960669062ff37dc22fbf4cbd9211f0c2864f99a Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 21 Nov 2022 17:27:28 -0800 Subject: [PATCH 006/206] grafana is auto provisioned with observability stack --- Tiltfile | 26 +++++++++++++++---- .../localnet/observability-stack/values.yaml | 14 +++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Tiltfile b/Tiltfile index 90ee8faa0..0f0c7fe79 100644 --- a/Tiltfile +++ b/Tiltfile @@ -2,7 +2,12 @@ load('ext://helm_resource', 'helm_resource', 'helm_repo') load('ext://namespace', 'namespace_create') # TODO: add resource dependencies https://docs.tilt.dev/resource_dependencies.html#adding-resource_deps-for-startup-order -# - validators depend on postgres +# - validators depend on postgres db, postgres db depends on postgres operator +# - validators depend on operator + +# TODO: cleanup resources on tilt down: +# - pocket-database svc cleanup +# - pocket validators are not getting removed # List of directories Tilt watches to trigger a hot-reload on changes deps = [ @@ -37,19 +42,25 @@ if is_psql_operator_installed == '0': # Deploy observability stack (grafana, prometheus, loki) and wire it up with localnet # TODO(@okdas): check if helm cli is available. -helm_repo('grafana', 'https://grafana.github.io/helm-charts') -helm_repo('prometheus-community', 'https://prometheus-community.github.io/helm-charts') +helm_repo('grafana', 'https://grafana.github.io/helm-charts', resource_name='helm-repo-grafana') +helm_repo('prometheus-community', 'https://prometheus-community.github.io/helm-charts', resource_name='helm-repo-prometheus') if not os.path.exists('build/localnet/observability-stack/charts'): local('helm dependency build build/localnet/observability-stack') + namespace_create('observability') k8s_yaml(helm("build/localnet/observability-stack", name='observability-stack', namespace="observability")) +# helm_resource('helm-observability-stack', +# 'build/localnet/observability-stack', +# release_name='observability-stack', +# namespace='observability', resource_deps=['helm-repo-grafana', 'helm-repo-prometheus'], +# deps=[ +# 'build/localnet/observability-stack/values.yaml', +# 'build/localnet/observability-stack/templates'],) # Builds the pocket binary. Note target OS is linux, because it later will be run in a container. local_resource('pocket: Watch & Compile', 'GOOS=linux go build -o bin/pocket-linux app/pocket/main.go', deps=deps) local_resource('debug client: Watch & Compile', 'GOOS=linux go build -tags=debug -o bin/client-linux app/client/*.go', deps=deps) -# go run -tags=debug app/client/*.go debug -# local_resource('client: Watch & Compile', 'GOOS=linux go build -o bin/client-linux app/client/main.go', deps=deps) # Builds and maintains the validator container image after the binary is built on local machine docker_build('validator-image', '.', @@ -98,3 +109,8 @@ k8s_resource(new_name='postgres', extra_pod_selectors=[{'cluster-name': 'pocket-database'}], port_forwards=5432) +# Exposes grafana +k8s_resource(new_name='grafana', + workload='observability-stack-grafana', + extra_pod_selectors=[{'app.kubernetes.io/name': 'grafana'}], + port_forwards=['42000:3000']) diff --git a/build/localnet/observability-stack/values.yaml b/build/localnet/observability-stack/values.yaml index 1f544e9fc..28b6ee2e8 100644 --- a/build/localnet/observability-stack/values.yaml +++ b/build/localnet/observability-stack/values.yaml @@ -12,16 +12,18 @@ grafana: auth: disable_login_form: true disable_signout_menu: true - anonymous: - enabled: true - org_role: Admin - org_name: Pocket v1 LocalNet + auth.anonymous: + enabled: true + org_role: Admin users: allow_sign_up: false allow_org_create: false auto_assign_org: true auto_assign_org_role: Admin auto_assign_org_id: 1 + viewers_can_edit: true + security: + allow_embedding: true loki: enabled: true @@ -47,10 +49,10 @@ promtail: logLevel: info serverPort: 3101 clients: - - url: http://{{ .Release.Name }}:3100/loki/api/v1/push + - url: http://{{ .Release.Name }}-loki:3100/loki/api/v1/push prometheus: - enabled: false + enabled: true isDefault: false url: http://{{ include "prometheus.fullname" .}}:{{ .Values.prometheus.server.service.servicePort }}{{ .Values.prometheus.server.prefixURL }} datasource: From 1455a4018add49457179a9c1d70bf319793cd8d9 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 28 Nov 2022 17:32:44 -0800 Subject: [PATCH 007/206] --wip-- [skip ci] --- Dockerfile | 7 ------- build/localnet/network.yaml | 9 +++++++++ build/localnet/observability-stack/dashboards/README.md | 3 +++ build/localnet/observability-stack/values.yaml | 1 + build/localnet/validators.yaml | 4 ++++ 5 files changed, 17 insertions(+), 7 deletions(-) delete mode 100644 Dockerfile create mode 100644 build/localnet/observability-stack/dashboards/README.md diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ab88c5999..000000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM debian:bullseye -WORKDIR / -COPY build/localnet/start.sh /start.sh -COPY build/localnet/restart.sh /restart.sh -COPY bin/pocket-linux /usr/local/bin/pocket -CMD ["/usr/local/bin/pocket"] -ENTRYPOINT ["/start.sh", "/usr/local/bin/pocket"] diff --git a/build/localnet/network.yaml b/build/localnet/network.yaml index 027167a7f..8f8de0944 100644 --- a/build/localnet/network.yaml +++ b/build/localnet/network.yaml @@ -8,9 +8,18 @@ apiVersion: v1 kind: Service metadata: name: pocket-validators + annotations: + prometheus.io/scrape: "false" + prometheus.io/port: "9000" spec: selector: v1-purpose: validator ports: - port: 50832 targetPort: 50832 + name: rpc + - port: 9000 + targetPort: 9000 + name: metrics +--- + diff --git a/build/localnet/observability-stack/dashboards/README.md b/build/localnet/observability-stack/dashboards/README.md new file mode 100644 index 000000000..1252650a4 --- /dev/null +++ b/build/localnet/observability-stack/dashboards/README.md @@ -0,0 +1,3 @@ +# Grafana dashboards for localnet + +Include json files in this directory to have them automatically imported into Grafana. diff --git a/build/localnet/observability-stack/values.yaml b/build/localnet/observability-stack/values.yaml index 28b6ee2e8..9afa09d92 100644 --- a/build/localnet/observability-stack/values.yaml +++ b/build/localnet/observability-stack/values.yaml @@ -8,6 +8,7 @@ grafana: maxLines: 1000 image: tag: 8.3.5 + dashboardsConfigMaps: {} grafana.ini: auth: disable_login_form: true diff --git a/build/localnet/validators.yaml b/build/localnet/validators.yaml index 32738a716..4be5df0c0 100644 --- a/build/localnet/validators.yaml +++ b/build/localnet/validators.yaml @@ -3,6 +3,7 @@ kind: PocketValidator metadata: name: v1-validator1 spec: + prometheusScrape: true collection: name: "default" pocketImage: validator-image @@ -29,6 +30,7 @@ kind: PocketValidator metadata: name: v1-validator2 spec: + prometheusScrape: true collection: name: "default" pocketImage: validator-image @@ -55,6 +57,7 @@ kind: PocketValidator metadata: name: v1-validator3 spec: + prometheusScrape: true collection: name: "default" pocketImage: validator-image @@ -81,6 +84,7 @@ kind: PocketValidator metadata: name: v1-validator4 spec: + prometheusScrape: true collection: name: "default" pocketImage: validator-image From ca9ebebaea53fc917c308bb7c1aa65281080e765 Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Mon, 5 Dec 2022 17:52:32 -0800 Subject: [PATCH 008/206] stabilizing tilt --- Makefile | 12 + Tiltfile | 24 +- build/localnet/cli-client.yaml | 65 ++- .../dashboards/raintree-telemetry-graphs.json | 466 ++++++++++++++++++ .../templates/dashboards.yml | 24 + .../localnet/observability-stack/values.yaml | 16 +- 6 files changed, 568 insertions(+), 39 deletions(-) create mode 100644 build/localnet/observability-stack/dashboards/raintree-telemetry-graphs.json create mode 100644 build/localnet/observability-stack/templates/dashboards.yml diff --git a/Makefile b/Makefile index 665c67090..8b68e4611 100644 --- a/Makefile +++ b/Makefile @@ -431,6 +431,18 @@ gen_genesis_and_config: clear_genesis_and_config: rm build/config/gen.*.json +.PHONY: localnet_up +## Starts localnet with all dependencies (basically, `tilt up`) +localnet_up: + tilt up + +.PHONY: localnet_down +## Stops localnet and cleans up dependencies (basically, `tilt down` + resources might not be cleaned up by tilt) +localnet_down: + tilt down --delete-namespaces + # kubectl delete --all --namespace=default pocketvalidators + kubectl get sts -n default --no-headers=true | awk '/v1-validator/{print $1}' | xargs kubectl delete -n default sts + .PHONY: check_cross_module_imports ## Lists cross-module imports check_cross_module_imports: diff --git a/Tiltfile b/Tiltfile index 0f0c7fe79..831064b70 100644 --- a/Tiltfile +++ b/Tiltfile @@ -1,8 +1,9 @@ load('ext://helm_resource', 'helm_resource', 'helm_repo') load('ext://namespace', 'namespace_create') +# TODO: add check k8s is 1.23, 1.24+ is supported once https://github.com/zalando/postgres-operator/issues/2098 is resolved. + # TODO: add resource dependencies https://docs.tilt.dev/resource_dependencies.html#adding-resource_deps-for-startup-order -# - validators depend on postgres db, postgres db depends on postgres operator # - validators depend on operator # TODO: cleanup resources on tilt down: @@ -39,6 +40,9 @@ is_psql_operator_installed = str(local('kubectl api-resources | grep postgres | if is_psql_operator_installed == '0': print('Installing postgres operator') local('kubectl apply -k github.com/zalando/postgres-operator/manifests') +# Wait for postgres operator to be available before deploying the database. +local_resource('wait-for-postgres-operator', 'kubectl wait --for=condition=available --timeout=600s --namespace=default deployment postgres-operator') +k8s_yaml('build/localnet/postgres-database.yaml') # Deploy observability stack (grafana, prometheus, loki) and wire it up with localnet # TODO(@okdas): check if helm cli is available. @@ -50,13 +54,6 @@ if not os.path.exists('build/localnet/observability-stack/charts'): namespace_create('observability') k8s_yaml(helm("build/localnet/observability-stack", name='observability-stack', namespace="observability")) -# helm_resource('helm-observability-stack', -# 'build/localnet/observability-stack', -# release_name='observability-stack', -# namespace='observability', resource_deps=['helm-repo-grafana', 'helm-repo-prometheus'], -# deps=[ -# 'build/localnet/observability-stack/values.yaml', -# 'build/localnet/observability-stack/templates'],) # Builds the pocket binary. Note target OS is linux, because it later will be run in a container. local_resource('pocket: Watch & Compile', 'GOOS=linux go build -o bin/pocket-linux app/pocket/main.go', deps=deps) @@ -75,7 +72,7 @@ ENTRYPOINT ["/start.sh", "/usr/local/bin/pocket", "-config=/configs/config.json" only=['./bin/pocket-linux', './build/'], live_update=[ sync('./bin/pocket-linux', '/usr/local/bin/pocket'), - run('/restart.sh'), + run('/restart.sh'), # TODO(@okdas): add healthchecks as this is possibly catching some of the issues with running the validators, e.g. when postgres db is not provisioned yet? ] ) @@ -95,12 +92,17 @@ CMD ["/usr/local/bin/client"] # Makes Tilt aware of our own Custom Resource Definition from pocket-operator, so it can work with our operator. k8s_kind('PocketValidator', image_json_path='{.spec.pocketImage}') +# Wait for postgres database to be available before deploying the validators. +local_resource('wait-for-postgres-database', 'sleep 5 && kubectl wait postgresqls --for=jsonpath={.status.PostgresClusterStatus}=Running pocket-database') + +# Wait for pocket operator +local_resource('wait-for-pocket-operator', 'kubectl wait --for=condition=available --timeout=600s --namespace=pocket-operator-system deployment pocket-operator-controller-manager') + # Pushes localnet manifests to the cluster. k8s_yaml([ - 'build/localnet/postgres-database.yaml', 'build/localnet/private-keys.yaml', 'build/localnet/validators.yaml', - 'build/localnet/cli-client.yaml', # TODO(@okdas): switch to https://github.com/tilt-dev/tilt-extensions/tree/master/deployment + 'build/localnet/cli-client.yaml', 'build/localnet/network.yaml']) # Exposes postgres port to 5432 on the host machine. diff --git a/build/localnet/cli-client.yaml b/build/localnet/cli-client.yaml index da9a6d30e..118307ee7 100644 --- a/build/localnet/cli-client.yaml +++ b/build/localnet/cli-client.yaml @@ -1,30 +1,41 @@ -apiVersion: v1 -kind: Pod +apiVersion: apps/v1 +kind: Deployment metadata: - name: pocket-v1-client + name: pocket-v1-cli-client namespace: default + labels: + app: v1-cli-client spec: - containers: - - name: pocket - image: client-image - imagePullPolicy: IfNotPresent - command: ["sleep", "infinity"] - env: - - name: CONFIG_PATH - value: "/var/pocket/config/config.json" - - name: GENESIS_PATH - value: "/var/pocket/genesis/genesis.json" - volumeMounts: - - mountPath: /var/pocket/config - name: config-volume - - mountPath: /var/pocket/genesis - name: genesis-volume - volumes: - - name: config-volume - configMap: - name: v1-validator1-config - defaultMode: 420 - - name: genesis-volume - configMap: - name: default-genesis - defaultMode: 420 + replicas: 1 + selector: + matchLabels: + app: v1-cli-client + template: + metadata: + labels: + app: v1-cli-client + spec: + containers: + - name: pocket + image: client-image + imagePullPolicy: IfNotPresent + command: ["sleep", "infinity"] + env: + - name: CONFIG_PATH + value: "/var/pocket/config/config.json" + - name: GENESIS_PATH + value: "/var/pocket/genesis/genesis.json" + volumeMounts: + - mountPath: /var/pocket/config + name: config-volume + - mountPath: /var/pocket/genesis + name: genesis-volume + volumes: + - name: config-volume + configMap: + name: v1-validator1-config + defaultMode: 420 + - name: genesis-volume + configMap: + name: default-genesis + defaultMode: 420 diff --git a/build/localnet/observability-stack/dashboards/raintree-telemetry-graphs.json b/build/localnet/observability-stack/dashboards/raintree-telemetry-graphs.json new file mode 100644 index 000000000..79a762899 --- /dev/null +++ b/build/localnet/observability-stack/dashboards/raintree-telemetry-graphs.json @@ -0,0 +1,466 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 3, + "x": 0, + "y": 0 + }, + "id": 19, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "8.5.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "expr": "sum(p2p_nodes_started_counter)", + "refId": "A" + } + ], + "title": "Online Nodes", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 21, + "x": 3, + "y": 0 + }, + "id": 23, + "options": { + "displayMode": "gradient", + "minVizHeight": 10, + "minVizWidth": 0, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true + }, + "pluginVersion": "8.5.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "consensus_blockchain_height_counter", + "interval": "1s", + "legendFormat": "{{instance}}", + "range": true, + "refId": "A" + } + ], + "title": "Block Height / Node", + "type": "bargauge" + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 12, + "w": 13, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 15, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "8.5.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "expr": "avg by (blockheight, instance) (sum by (blockheight) (count_over_time({host=\"docker-desktop\"}\n |= \"[EVENT] event_metrics_namespace_p2p raintree_message_event_metric \"\n | pattern ` <_>