diff --git a/buildkite/helm/README.md b/buildkite/helm/README.md new file mode 100644 index 00000000000..dcdf2b23cd4 --- /dev/null +++ b/buildkite/helm/README.md @@ -0,0 +1,37 @@ +## Introduction + +This chart bootstraps a Buildkite GraphQL API metrics exporter providing job and agent statistics to a Prometheus compatible endpoint. + +## Add Coda Helm chart repository: + + ```console + helm repo add coda + helm repo update + ``` + +## Configuration + +The following table lists the configurable parameters of the `buildkite-exporter` chart and its default values. + +### Required Settings + +Parameter | Description +--- | --- +`exporter.buildkiteApiKey` | Buildkite GraphQL API access key + +### Optional Settings + +Parameter | Description | Default +--- | --- | --- +`exporter.pipeline` | Buildkite pipeline to scrape and export | `coda` +`exporter.image` | Buildkite exporter container image to deploy | `codaprotocol/buildkite-exporter:0.1.0` +`exporter.listeningPort` | port on which to listen for data collection requests | `8000` +`exporter.optionalEnv` | optional environment variable configuration settings | `[]` + +## buildkite-exporter launch examples + +```console +helm install buildkite-exporter \ + --set exporter.buildkiteApiKey= \ + --set exporter.optionalEnv=[{'name': 'BUILDKITE_BRANCH', 'value': 'release'}] +``` diff --git a/buildkite/helm/buildkite-exporter/Chart.yaml b/buildkite/helm/buildkite-exporter/Chart.yaml new file mode 100644 index 00000000000..002d68ef578 --- /dev/null +++ b/buildkite/helm/buildkite-exporter/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: buildkite-exporter +description: A Helm chart for O(1) Lab's Buildkite graphql exporter +type: application +version: 0.1.0 +appVersion: 0.1.0 +icon: https://pbs.twimg.com/profile_images/968998928241733632/Rhxmu_9O_400x400.jpg +keywords: +- buildkite +- prometheus exporter +- graphql +home: https://o1labs.org/ +sources: +- https://github.com/CodaProtocol diff --git a/buildkite/helm/buildkite-exporter/templates/buildkite-exporter.yaml b/buildkite/helm/buildkite-exporter/templates/buildkite-exporter.yaml new file mode 100644 index 00000000000..9d72dbc5da2 --- /dev/null +++ b/buildkite/helm/buildkite-exporter/templates/buildkite-exporter.yaml @@ -0,0 +1,41 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{tpl $.Values.exporter.name .}} + labels: + app: {{tpl $.Values.exporter.name .}} +spec: + replicas: 1 + selector: + matchLabels: + app: {{tpl $.Values.exporter.name .}} + template: + metadata: + labels: + app: {{tpl $.Values.exporter.name .}} + pipeline: {{ $.Values.exporter.pipeline }} + annotations: + prometheus.io/scrape: 'true' + prometheus.io/port: {{ $.Values.exporter.listeningPort | quote }} + prometheus.io/path: '/metrics' + spec: + containers: + - name: exporter + resources: + limits: + memory: 2.0Gi + requests: + memory: 2.0Gi + cpu: 1000m + image: {{ $.Values.exporter.image }} + env: + - name: BUILDKITE_API_KEY + value: {{ .Values.exporter.buildkiteApiKey }} +{{- if .Values.exporter.optionalEnv }} +{{ toYaml .Values.exporter.optionalEnv | nindent 10 }} +{{- end }} + ports: + - containerPort: {{ .Values.exporter.listeningPort }} + hostPort: {{ .Values.exporter.listeningPort }} + protocol: TCP + imagePullPolicy: Always diff --git a/buildkite/helm/buildkite-exporter/templates/exporter-service.yaml b/buildkite/helm/buildkite-exporter/templates/exporter-service.yaml new file mode 100644 index 00000000000..f9adf3ca037 --- /dev/null +++ b/buildkite/helm/buildkite-exporter/templates/exporter-service.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ tpl $.Values.exporter.name . }} +spec: + type: NodePort + selector: + app: {{ tpl $.Values.exporter.name . }} + ports: + - name: metric-collection + protocol: TCP + port: {{ $.Values.exporter.listeningPort }} + targetPort: {{ $.Values.exporter.listeningPort }} diff --git a/buildkite/helm/buildkite-exporter/values.yaml b/buildkite/helm/buildkite-exporter/values.yaml new file mode 100644 index 00000000000..064ac09db47 --- /dev/null +++ b/buildkite/helm/buildkite-exporter/values.yaml @@ -0,0 +1,10 @@ +exporter: + pipeline: coda + name: "buildkite-{{ .Values.exporter.pipeline }}-exporter" + image: codaprotocol/buildkite-exporter:0.1.0 + listeningPort: 8000 + optionalEnv: +# - name: BUILDKITE_EXPORTER_SCAN_INTERVAL +# value: 1800 +# - name: BUILDKITE_BRANCH +# value: develop diff --git a/buildkite/scripts/generate-diff.sh b/buildkite/scripts/generate-diff.sh index 68dacb600bd..5397c8433cf 100755 --- a/buildkite/scripts/generate-diff.sh +++ b/buildkite/scripts/generate-diff.sh @@ -11,7 +11,6 @@ COMMIT=$(diff -u <(git rev-list --first-parent HEAD) \ if [[ $COMMIT != "" ]]; then # Get the files that have changed since that shared commit - echo "--- Generating diff based on shared commit: ${COMMIT}" git diff $COMMIT --name-only else if [ -n "${BUILDKITE_INCREMENTAL+x}" ]; then @@ -22,7 +21,6 @@ else | jq '.data.pipeline.builds.edges[0].node.commit' | tr -d '"' ) - echo "--- Generating incremental diff against: ${ci_recent_pass_commit}" git diff "${ci_recent_pass_commit}" --name-only else # TODO: Dump commits as artifacts when build succeeds so we can diff against @@ -30,4 +28,3 @@ else git ls-files fi fi - diff --git a/buildkite/scripts/helm-ci.sh b/buildkite/scripts/helm-ci.sh new file mode 100755 index 00000000000..7646987434c --- /dev/null +++ b/buildkite/scripts/helm-ci.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +set -eou pipefail + +echo "--- Generating change DIFF" +diff=$( + ./buildkite/scripts/generate-diff.sh +) + +# Identifying modifications to helm charts (based on existence of Chart.yaml at change root) +charts=$( + for val in $diff; do + find $(dirname $val) -name 'Chart.yaml'; + done +) + +# filter duplicates +charts=$(echo $charts | xargs -n1 | sort -u | xargs) +dirs=$(dirname $charts | xargs -n1 | sort -u | xargs) + +if [ -n "${HELM_LINT+x}" ]; then + for dir in $dirs; do + echo "--- Linting: ${dir}" + helm lint $dir + + echo "--- Executing dry-run: ${dir}" + helm install test $dir --dry-run --namespace default + done +fi + +if [ -n "${HELM_RELEASE+x}" ]; then + syncDir="sync_dir" + stageDir="updates" + mkdir -p $stageDir $syncDir + + echo "--- Syncing with remote GCS Helm chart repository" + gsutil -m rsync ${CODA_CHART_REPO:-"gs://coda-charts/"} $syncDir + + echo "--- Preparing the following charts for Release: ${charts}" + for dir in $dirs; do + git diff develop... "${dir}/Chart.yaml" | grep version + + helm package $dir --destination $stageDir + + if [ -n "${HELM_EXPERIMENTAL_OCI+x}" ]; then + echo "--- Helm experimental OCI activated - deploying to GCR registry" + helm chart save $(basename $dir) + + gcloud auth configure-docker + docker login "gcr.io/o1labs-192920/coda-charts/$(basename ${dir})" + + helm chart push "gcr.io/o1labs-192920/coda-charts/$(basename ${dir})" + fi + done + + cp --force --recursive "${stageDir}" "${syncDir}" + + helm repo index $syncDir + + if [ -n "${AUTO_DEPLOY+x}" ]; then + echo "--- Deploying/Syncing with remote repository" + gsutil -m rsync $syncDir ${CODA_CHART_REPO:-"gs://coda-charts/"} + fi +fi diff --git a/buildkite/src/Jobs/HelmRelease.dhall b/buildkite/src/Jobs/HelmRelease.dhall new file mode 100644 index 00000000000..b71a638033b --- /dev/null +++ b/buildkite/src/Jobs/HelmRelease.dhall @@ -0,0 +1,35 @@ +let Prelude = ../External/Prelude.dhall + +let S = ../Lib/SelectFiles.dhall +let Cmd = ../Lib/Cmds.dhall + +let Pipeline = ../Pipeline/Dsl.dhall +let JobSpec = ../Pipeline/JobSpec.dhall + +let Command = ../Command/Base.dhall +let Docker = ../Command/Docker/Type.dhall +let Size = ../Command/Size.dhall + +let jobDocker = Cmd.Docker::{image = (../Constants/ContainerImages.dhall).codaToolchain} + +in + +Pipeline.build + Pipeline.Config::{ + spec = JobSpec::{ + dirtyWhen = [ S.contains "helm", S.strictly (S.contains "Chart.yaml") ], + name = "HelmRelease" + }, + steps = [ + Command.build + Command.Config::{ + commands = [ Cmd.run "HELM_RELEASE=true buildkite/scripts/helm-ci.sh" ] + , label = "Helm chart release" + , key = "release-helm-chart" + , target = Size.Medium + , docker = None Docker.Type + , artifact_paths = [ S.contains "updates/*" ] + , depends_on = [ { name = "HelmChart", key = "lint-helm-chart" } ] + } + ] + } diff --git a/buildkite/src/Jobs/Lint/HelmChart.dhall b/buildkite/src/Jobs/Lint/HelmChart.dhall new file mode 100644 index 00000000000..1449f5d5e6f --- /dev/null +++ b/buildkite/src/Jobs/Lint/HelmChart.dhall @@ -0,0 +1,34 @@ +let Prelude = ../../External/Prelude.dhall + +let S = ../../Lib/SelectFiles.dhall +let Cmd = ../../Lib/Cmds.dhall + +let Pipeline = ../../Pipeline/Dsl.dhall +let JobSpec = ../../Pipeline/JobSpec.dhall + +let Command = ../../Command/Base.dhall +let Docker = ../../Command/Docker/Type.dhall +let Size = ../../Command/Size.dhall + +let jobDocker = Cmd.Docker::{image = (../../Constants/ContainerImages.dhall).codaToolchain} + +in + +Pipeline.build + Pipeline.Config::{ + spec = JobSpec::{ + dirtyWhen = [ S.contains "helm" ], + path = "Lint", + name = "HelmChart" + }, + steps = [ + Command.build + Command.Config::{ + commands = [ Cmd.run "HELM_LINT=true buildkite/scripts/helm-ci.sh" ] + , label = "Helm chart lint steps" + , key = "lint-helm-chart" + , target = Size.Small + , docker = None Docker.Type + } + ] + } diff --git a/dockerfiles/Dockerfile-toolchain b/dockerfiles/Dockerfile-toolchain index 34c62afcd57..f645f63a9b1 100644 --- a/dockerfiles/Dockerfile-toolchain +++ b/dockerfiles/Dockerfile-toolchain @@ -61,6 +61,11 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \ curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \ sudo apt-get update -y && sudo apt-get install google-cloud-sdk kubectl -y +# Helm tools +RUN curl https://baltocdn.com/helm/signing.asc | apt-key add - && \ + echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list && \ + sudo apt-get update -y && sudo apt-get install helm -y + RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rust_install.sh RUN chmod +x /tmp/rust_install.sh RUN /tmp/rust_install.sh -y diff --git a/frontend/bot/helm/.helmignore b/frontend/bot/helm/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/frontend/bot/helm/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/frontend/bot/helm/Chart.yaml b/frontend/bot/helm/Chart.yaml new file mode 100644 index 00000000000..646d6142954 --- /dev/null +++ b/frontend/bot/helm/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +name: o1-bot +description: A Helm chart for Coda Protocol's O(1) role-based testnet service bots +type: application +version: 0.0.1 +appVersion: 0.0.1 +icon: https://github.com/CodaProtocol/coda/blob/develop/frontend/website/public/static/img/coda-logo@3x.png +keywords: +- bot +- faucet +- echo +- community +home: https://codaprotocol.com/ +sources: +- https://github.com/CodaProtocol diff --git a/frontend/bot/helm/README.md b/frontend/bot/helm/README.md new file mode 100644 index 00000000000..baee81e73b5 --- /dev/null +++ b/frontend/bot/helm/README.md @@ -0,0 +1,40 @@ +## Introduction + +This chart bootstraps O(1) Lab's Coda protocol bot for providing various services to deployed testnets. + +## Add Coda Helm chart repository: + + ```console + helm repo add coda + helm repo update + ``` + +## Configuration + +The following table lists the configurable parameters of the `o1-bot` chart and its default values. + +### Required Settings + +Parameter | Description +--- | --- +`bot.name` | name of bot to deploy +`bot.image` | container image representing bot function/role +`bot.role` | role/function of bot to deploy +`bot.testnet` | coda protocol testnet to deploy to + +### Optional Settings + +Parameter | Description | Default +--- | --- | --- +`bot.command` | override command to run on bot startup | `[]` +`bot.args` | arguments to pass to startup override command | `[]` +`bot.resources` | bot resource specification/mapping | `see default Values.yaml` +`bot.optionalEnv` | optional environment variable configuration settings | `[]` +`bot.volumes` | k8s volume objects to launch bot with | `[]` +`bot.volumeMounts` | bot pod volume mount path settings | `[]` + +## buildkite-exporter launch examples + +```console +helm install faucet ... +``` diff --git a/frontend/bot/helm/templates/o1-bot-deployment.yaml b/frontend/bot/helm/templates/o1-bot-deployment.yaml new file mode 100644 index 00000000000..b6d75b7f6c3 --- /dev/null +++ b/frontend/bot/helm/templates/o1-bot-deployment.yaml @@ -0,0 +1,44 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $.Values.bot.name }} + labels: + app: {{ $.Values.bot.name }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ $.Values.bot.name }} + template: + metadata: + labels: + app: {{ $.Values.bot.name }} + testnet: {{ $.Values.bot.testnet }} + role: {{ $.Values.bot.role }} + spec: + containers: + - name: bot + imagePullPolicy: Always + resources: +{{- if .Values.bot.resources }} +{{ toYaml .Values.bot.resources | nindent 10 }} +{{- end }} + image: {{ $.Values.bot.image }} + command: {{ $.Values.bot.command }} + args: {{ $.Values.bot.args }} + env: +{{- if .Values.bot.optionalEnv }} +{{ toYaml .Values.bot.optionalEnv | nindent 10 }} +{{- end }} + ports: +{{- if .Values.bot.ports }} +{{ toYaml .Values.bot.ports | nindent 10 }} +{{- end }} + volumeMounts: +{{- if .Values.bot.volumeMounts }} +{{ toYaml .Values.bot.volumeMounts | nindent 10 }} +{{- end }} + volumes: +{{- if .Values.bot.volumes }} +{{ toYaml .Values.bot.volumes | nindent 8 }} +{{- end }} diff --git a/frontend/bot/helm/values.yaml b/frontend/bot/helm/values.yaml new file mode 100644 index 00000000000..b2513f5be88 --- /dev/null +++ b/frontend/bot/helm/values.yaml @@ -0,0 +1,37 @@ +bot: # user-agent role default settings + name: o1-bot + image: codaprotocol/coda-user-agent:0.1.5 + testnet: default + role: user-agent + command: ["bash"] + args: ["-c", "python3 agent.py"] + resources: + requests: + memory: 1.0Gi + cpu: 1000m + limits: + cpu: 1000m + memory: 1.0Gi + optionalEnv: + - name: AGENT_MIN_FEE + value: 1 + - name: AGENT_MAX_FEE + value: 5 + - name: AGENT_MIN_TX + value: 1 + - name: AGENT_MAX_TX + value: 10 + - name: AGENT_SEND_EVERY_MINUTES + value: "10" + - name: PYTHONUNBUFFERED + value: "1" + ports: [] + # - name: graphql + # containerPort: 3085 + volumeMounts: [] + # - name: wallet-keys + # mountPath: /root/wallet-keys + volumes: [] + # - name: wallet-keys + # emptyDir: {} + diff --git a/frontend/leaderboard/helm/.helmignore b/frontend/leaderboard/helm/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/frontend/leaderboard/helm/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/frontend/leaderboard/helm/Chart.yaml b/frontend/leaderboard/helm/Chart.yaml new file mode 100644 index 00000000000..4ab0e594bf4 --- /dev/null +++ b/frontend/leaderboard/helm/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +name: leaderboard +description: A Helm chart for Coda Protocol's Testnet leaderboard service +type: application +version: 0.1.8 +appVersion: 1.16.0 +icon: https://github.com/CodaProtocol/coda/blob/develop/frontend/website/public/static/img/coda-logo@3x.png +keywords: +- coda protocol +- testnet +- leaderboard +- points +home: https://codaprotocol.com/ +sources: +- https://github.com/CodaProtocol/coda/tree/develop/frontend/leaderboard diff --git a/frontend/leaderboard/helm/README.md b/frontend/leaderboard/helm/README.md new file mode 100644 index 00000000000..8d0702561e2 --- /dev/null +++ b/frontend/leaderboard/helm/README.md @@ -0,0 +1,39 @@ +## Introduction + +This chart bootstraps a Coda Protocol Testnet leaderboard service + +## Add Coda Helm chart repository: + + ```console + helm repo add coda + helm repo update + ``` + +## Configuration + +The following table lists the configurable parameters of the `leaderboard` chart and its default values. + +### Required Settings + +Parameter | Description +--- | --- +`postgresql.postgresHost` | Coda protocol Postgres SQL archive host address +`postgresql.postgresPort` | Coda protocol Postgres SQL archive listening port +`volume.secretName` | Leaderboard credentials information | `none` + +### Optional Settings + +Parameter | Description | Default +--- | --- | --- +`leaderboard.name` | Coda protocol leaderboard service/cron job name | `leaderboard-cron` +`leaderboard.containerName` | name of container to provision for leaderboard job | `leaderboard` +`leaderboard.image` | Coda protocol leaderboard container image | `gcr.io/o1labs-192920/leaderboard` +`leaderboard.schedule` | frequency with which to execute leaderboard operations | `@hourly` +`postgresql.postgresqlUsername` | Coda protocol Postgres SQL archive username | `none` +`postgresql.postgresqlPassword` | Coda protocol Postgres SQL archive password | `none` + +## leaderboard launch examples + +```console +helm install leaderboard +``` diff --git a/frontend/leaderboard/helm/templates/leaderboard-cron-job.yaml b/frontend/leaderboard/helm/templates/leaderboard-cron-job.yaml new file mode 100644 index 00000000000..3d26c9da307 --- /dev/null +++ b/frontend/leaderboard/helm/templates/leaderboard-cron-job.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: {{ .Values.leaderboard.name }} +spec: + schedule: "{{ .Values.leaderboard.schedule }}" + jobTemplate: + spec: + template: + spec: + restartPolicy: Never + volumes: + - name: {{ .Values.volume.name }} + secret: + secretName: {{ .Values.volume.secretName }} + containers: + - name: {{ .Values.leaderboard.containerName }} + image: {{ .Values.leaderboard.image }} + imagePullPolicy: Always + env: + - name: PGCONN + value: postgres://{{ .Values.postgresql.postgresqlUsername }}:{{ .Values.postgresql.postgresqlPassword }}@{{ .Values.postgresql.postgresHost }}:{{ .Values.postgresql.postgresPort }}/{{ .Values.postgresql.postgresDB }} + volumeMounts: + - name: {{ .Values.volume.name }} + mountPath: {{ .Values.volume.mountPath }} + subPath: {{ .Values.volume.subPath }} + readOnly: true diff --git a/frontend/leaderboard/helm/values.yaml b/frontend/leaderboard/helm/values.yaml new file mode 100644 index 00000000000..2be80716831 --- /dev/null +++ b/frontend/leaderboard/helm/values.yaml @@ -0,0 +1,18 @@ +leaderboard: + name: "leaderboard-cron" + containerName: "leaderboard" + image: "gcr.io/o1labs-192920/leaderboard" + schedule: "@hourly" + +volume: + name: "credentials" + secretName: "sheets-credentials" + mountPath: "/code/google_sheets_credentials.json" + subPath: "google_sheets_credentials.json" + +postgresql: + postgresqlPassword: "foobar" + postgresqlUsername: "postgres" + postgresHost: "postgresql" + postgresPort: "5432" + postgresDB: "archive" diff --git a/helm/archive-node/.helmignore b/helm/archive-node/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/helm/archive-node/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/archive-node/Chart.lock b/helm/archive-node/Chart.lock new file mode 100644 index 00000000000..dc83976aa2f --- /dev/null +++ b/helm/archive-node/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 8.7.2 +digest: sha256:c6f7c7f032bb756dfb1d21e6190d171a160d8cfd29cb33ceabe208fbad9295f2 +generated: "2020-04-07T15:39:48.931361-07:00" diff --git a/helm/archive-node/Chart.yaml b/helm/archive-node/Chart.yaml new file mode 100644 index 00000000000..8d292ef47b2 --- /dev/null +++ b/helm/archive-node/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v2 +name: archive-node +description: A Helm chart for Coda Protocol's archive node +type: application +version: 0.1.0 +appVersion: 1.16.0 +dependencies: + - name: postgresql + version: "*" + repository: "@bitnami" +icon: https://github.com/CodaProtocol/coda/blob/develop/frontend/website/public/static/img/coda-logo@3x.png +keywords: +- archive +- postgres +home: https://codaprotocol.com/ +sources: +- https://github.com/CodaProtocol/coda/tree/develop/src/app/archive diff --git a/helm/archive-node/README.md b/helm/archive-node/README.md new file mode 100644 index 00000000000..2d24228faa0 --- /dev/null +++ b/helm/archive-node/README.md @@ -0,0 +1,51 @@ +## Introduction + +This chart bootstraps a Coda protocol archive node and associated Postgres database. + +## Add Coda Helm chart repository: + + ```console + helm repo add coda + helm repo update + ``` + +## Configuration + +The following table lists the configurable parameters of the `archive-node` chart and its default values. + +### Required Settings + +Parameter | Description +--- | --- +`testnetName` | Coda protocol testnet name +`coda.seedPeers` | peers to bootstrap the the archive node's Coda daemon +`archive.nodeName` | name identifier of archive node pod + +### Optional Settings + +Parameter | Description | Default +--- | --- | --- +`archive.image` | container image to use for operating an archive node | `codaprotocol/coda-archive:0.0.12-beta-fix-archive-debs-62bae52` +`archive.postgresHost` | Postgres database host to store archival data | `see [default] values.yaml` +`archive.postgresPort` | Postgres database port | `5432` +`archive.postgresDB` | Postgres database to store archival data | `archive` +`archive.postgresUri` | port on which to listen for data collection requests | `see [default] values.yaml` +`archive.remoteSchemaFile` | archive database schema during initialization | `see [default] values.yaml` +`archive.hostPort` | Kubernetes node port to expose | `10909` +`archive.optionalEnv` | optional environment variable configuration settings | `[]` +`postgres.postgresqlUsername` | Postgress database access username (if set) | `postgres` +`postgres.postgresPassword` | Postgres database access password (if set) | `foobar` +`coda.image` | container image to use for operating the archive node's Coda daemon | `codaprotocol/coda-daemon:0.0.14-rosetta-scaffold-inversion-489d898` +`coda.logLevel` | log level to set for Coda daemon | `TRACE` +`coda.logReceivedBlocks` | whether the Coda daemon should log received blocks events | `false` +`coda.logSnarkWorkGossip` | whether the Coda daemon should log SNARK work gossip | `false` +`coda.runtimeConfig` | Coda daemon configuration to use at runtime | `undefined` +`coda.privKeyPass` | public-private key-pair associated with Coda daemon account | `see [default] values.yaml` + +## archive-node launch examples + +```console +helm install archive-node \ + --set testnetName=pickles \ + --set coda.seedPeers=['/dns4/coda-testnet-seed-one.pickles.o1test.net/tcp/10002/p2p/12D3KooWP7fTKbyiUcYJGajQDpCFo2rDexgTHFJTxCH8jvcL1eAH] +``` diff --git a/helm/archive-node/charts/postgresql-8.7.2.tgz b/helm/archive-node/charts/postgresql-8.7.2.tgz new file mode 100644 index 00000000000..b164de07ac7 Binary files /dev/null and b/helm/archive-node/charts/postgresql-8.7.2.tgz differ diff --git a/helm/archive-node/templates/NOTES.txt b/helm/archive-node/templates/NOTES.txt new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/helm/archive-node/templates/NOTES.txt @@ -0,0 +1 @@ + diff --git a/helm/archive-node/templates/_helpers.tpl b/helm/archive-node/templates/_helpers.tpl new file mode 100644 index 00000000000..44d2352330c --- /dev/null +++ b/helm/archive-node/templates/_helpers.tpl @@ -0,0 +1,83 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "archive-node.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 "archive-node.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 "archive-node.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "archive-node.labels" -}} +helm.sh/chart: {{ include "archive-node.chart" . }} +{{ include "archive-node.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "archive-node.selectorLabels" -}} +app.kubernetes.io/name: {{ include "archive-node.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "archive-node.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "archive-node.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + + +{{/* +NOTE: This utility template is needed until https://git.io/JvuGN is resolved. + +Call a template from the context of a subchart. + +Usage: + {{ include "call-nested" (list . "" "") }} +*/}} +{{- define "call-nested" }} +{{- $dot := index . 0 }} +{{- $subchart := index . 1 | splitList "." }} +{{- $template := index . 2 }} +{{- $values := $dot.Values }} +{{- range $subchart }} +{{- $values = index $values . }} +{{- end }} +{{- include $template (dict "Chart" (dict "Name" (last $subchart)) "Values" $values "Release" $dot.Release "Capabilities" $dot.Capabilities) }} +{{- end }} \ No newline at end of file diff --git a/helm/archive-node/templates/archive.yaml b/helm/archive-node/templates/archive.yaml new file mode 100644 index 00000000000..2bdc65513fa --- /dev/null +++ b/helm/archive-node/templates/archive.yaml @@ -0,0 +1,96 @@ +# Coda Daemon +apiVersion: apps/v1 +kind: Deployment +metadata: + name: archive-node-{{ .Values.archive.nodeName }} + labels: + app: archive-node-{{ .Values.archive.nodeName }} +spec: + replicas: 1 + selector: + matchLabels: + app: archive-node-{{ .Values.archive.nodeName }} + template: + metadata: + labels: + app: archive-node-{{ .Values.archive.nodeName }} + testnet: {{ $.Values.testnetName }} + role: archive-node + version: {{ (split ":" $.Values.coda.image)._1 }} + annotations: + prometheus.io/scrape: 'true' + prometheus.io/port: '10000' + prometheus.io/path: '/metrics' + spec: + containers: + - name: coda + resources: + limits: + memory: 6.0Gi + requests: + memory: 2.0Gi + cpu: 1000m + image: {{ $.Values.coda.image }} + command: ["/usr/bin/dumb-init", "/root/init_coda.sh"] + args: [ "daemon", + "-log-level", {{ $.Values.coda.logLevel }}, + "-log-json", + {{- if $.Values.coda.logReceivedBlocks }} + "-log-received-blocks", "true", + {{- end -}} + {{- if $.Values.coda.logSnarkWorkGossip }} + "-log-snark-work-gossip", "true", + {{- end -}} + {{- range $.Values.coda.seedPeers }} + "-peer", {{ . | quote }}, + {{- end -}} + "-config-directory", "/root/.coda-config", + "-client-port", "$(DAEMON_CLIENT_PORT)", + "-rest-port", "$(DAEMON_REST_PORT)", + "-insecure-rest-server", + "-external-port", "$(DAEMON_EXTERNAL_PORT)", + "-metrics-port", "$(DAEMON_METRICS_PORT)", + "-archive-address", "3086", + {{- if (ne $.Values.coda.runtimeConfig "") -}} + "-config-file", "/config/daemon.json", + "-generate-genesis-proof", "true", + {{- end -}} + ] + env: + - name: DAEMON_REST_PORT + value: "3085" + - name: DAEMON_ARCHIVE_PORT + value: "3086" + - name: DAEMON_CLIENT_PORT + value: "8301" + - name: DAEMON_METRICS_PORT + value: "10000" + - name: DAEMON_EXTERNAL_PORT + value: {{ .Values.archive.hostPort | quote }} + ports: + - containerPort: {{ .Values.archive.hostPort }} + hostPort: {{ .Values.archive.hostPort }} + protocol: TCP + imagePullPolicy: Always + volumeMounts: + - name: config-dir + mountPath: /root/.coda-config + {{- if (ne $.Values.coda.runtimeConfig "") }} + - name: daemon-config + mountPath: "/config/" + {{- end }} + # Archive Process + - name: archive + image: {{ $.Values.archive.image }} + command: ["bash", "-c"] + args: [ "coda-archive -postgres-uri {{ tpl .Values.archive.postgresUri . }} -server-port 3086" ] + env: + imagePullPolicy: Always + volumes: + - name: config-dir + emptyDir: {} + {{- if (ne $.Values.coda.runtimeConfig "") }} + - name: daemon-config + configMap: + name: archive-daemon-config + {{- end }} diff --git a/helm/archive-node/templates/db-bootstrap.yaml b/helm/archive-node/templates/db-bootstrap.yaml new file mode 100644 index 00000000000..5c595c9d4a4 --- /dev/null +++ b/helm/archive-node/templates/db-bootstrap.yaml @@ -0,0 +1,18 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: archive-db-bootstrap +spec: + template: + spec: + containers: + - name: create-db + image: bitnami/postgresql + command: ["bash", "-c"] + args: ["PGPASSWORD={{ .Values.postgresql.postgresqlPassword }} createdb --username {{ .Values.postgresql.postgresqlUsername }} --host {{ tpl .Values.archive.postgresHost . }} --port {{ .Values.archive.postgresPort }} --echo {{ .Values.archive.postgresDB}}"] + - name: import-schema + image: bitnami/postgresql + command: ["bash", "-c"] + args: ["PGPASSWORD={{ .Values.postgresql.postgresqlPassword }} psql --username {{ .Values.postgresql.postgresqlUsername }} --host {{ tpl .Values.archive.postgresHost . }} --port {{ .Values.archive.postgresPort }} --dbname {{ .Values.archive.postgresDB}} -f <(curl -Ls {{ .Values.archive.remoteSchemaFile }})"] + restartPolicy: Never + backoffLimit: 10 diff --git a/helm/archive-node/templates/genesis-configmap.yaml b/helm/archive-node/templates/genesis-configmap.yaml new file mode 100644 index 00000000000..40f4853a2f8 --- /dev/null +++ b/helm/archive-node/templates/genesis-configmap.yaml @@ -0,0 +1,12 @@ +{{ if (ne $.Values.coda.runtimeConfig "") -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: archive-daemon-config + labels: + app: archive + heritage: {{ $.Release.Service }} + release: {{ $.Release.Name }} +data: + daemon.json: {{ $.Values.coda.runtimeConfig | quote }} +{{- end }} diff --git a/helm/archive-node/values.yaml b/helm/archive-node/values.yaml new file mode 100644 index 00000000000..7976abb3b6f --- /dev/null +++ b/helm/archive-node/values.yaml @@ -0,0 +1,26 @@ +testnetName: "coda-testnet" +coda: + runtimeConfig: "" + logLevel: "Trace" + logReceivedBlocks: false + logSnarkWorkGossip: false + image: codaprotocol/coda-daemon:0.0.14-rosetta-scaffold-inversion-489d898 + privkeyPass: "naughty blue worm" + seedPeers: + - /dns4/seed-one.genesis-redux.o1test.net/tcp/10002/p2p/12D3KooWP7fTKbyiUcYJGajQDpCFo2rDexgTHFJTxCH8jvcL1eAH + - /dns4/seed-two.genesis-redux.o1test.net/tcp/10002/p2p/12D3KooWL9ywbiXNfMBqnUKHSB1Q1BaHFNUzppu6JLMVn9TTPFSA + +archive: + hostPort: "10909" + image: codaprotocol/coda-archive:0.0.12-beta-fix-archive-debs-62bae52 + nodeName: "dev" + remoteSchemaFile: "https://raw.githubusercontent.com/CodaProtocol/coda/master/src/app/archive/create_schema.sql" + postgresHost: '{{ .Release.Name }}-postgresql' + postgresPort: "5432" + postgresDB: "archive" + postgresUri: postgres://{{ .Values.postgresql.postgresqlUsername }}:{{ .Values.postgresql.postgresqlPassword }}@{{ tpl .Values.archive.postgresHost . }}:{{ .Values.archive.postgresPort }}/{{ .Values.archive.postgresDB }} + + +postgresql: + postgresqlPassword: "foobar" + postgresqlUsername: "postgres" diff --git a/helm/block-producer/.helmignore b/helm/block-producer/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/helm/block-producer/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/block-producer/Chart.yaml b/helm/block-producer/Chart.yaml new file mode 100644 index 00000000000..832c040ba38 --- /dev/null +++ b/helm/block-producer/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v2 +name: block-producer +description: A Helm chart for Coda Protocol's block producing network nodes +type: application +version: 0.1.8 +appVersion: 1.16.0 +dependencies: +icon: https://github.com/CodaProtocol/coda/blob/develop/frontend/website/public/static/img/coda-logo@3x.png +keywords: +- block-producer +- stake +- delegate +home: https://codaprotocol.com/ +sources: +- https://github.com/CodaProtocol/coda/tree/develop/src/lib/block_producer + diff --git a/helm/block-producer/README.md b/helm/block-producer/README.md new file mode 100644 index 00000000000..ee44ff6372c --- /dev/null +++ b/helm/block-producer/README.md @@ -0,0 +1,33 @@ +## Introduction + +This chart bootstraps a Coda protocol block producer. + +## Add Coda Helm chart repository: + + ```console + helm repo add coda + helm repo update + ``` + +## Configuration + +The following table lists the configurable parameters of the `block-producer` chart and its default values. + +### Required Settings + +Parameter | Description +--- | --- +`TODO` | TODO + +### Optional Settings + +Parameter | Description | Default +--- | --- | --- +`TODO` | TODO | `TODO` + +## block-producer launch examples + +```console +helm install block-producer \ + --set testnetName=pickles +``` diff --git a/helm/block-producer/templates/block-producer.yaml b/helm/block-producer/templates/block-producer.yaml new file mode 100644 index 00000000000..77971a7004c --- /dev/null +++ b/helm/block-producer/templates/block-producer.yaml @@ -0,0 +1,244 @@ +{{ range $config := $.Values.blockProducerConfigs}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $config.name }} + labels: + app: {{ $config.name }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ $config.name }} + template: + metadata: + labels: + app: {{ $config.name }} + testnet: {{ $.Values.testnetName }} + role: block-producer + class: {{ $config.class }} + version: {{ (split ":" $.Values.coda.image)._1 }} + annotations: + prometheus.io/scrape: 'true' + prometheus.io/path: '/metrics' + spec: + initContainers: + - name: fix-perms + image: busybox + command: + - sh + - -c + - for dir in keys echo-keys faucet-keys; do [ -d /$dir ] && /bin/cp /$dir/* /wallet-keys; done; /bin/chmod 0700 /wallet-keys + volumeMounts: + - name: private-keys + mountPath: "/keys/" + readOnly: true + {{- if $config.runWithBots }} + - name: echo-service-key + mountPath: "/echo-keys/" + readOnly: true + - name: faucet-service-key + mountPath: "/faucet-keys/" + readOnly: true + {{- end }} + - name: wallet-keys + mountPath: /wallet-keys + securityContext: + runAsUser: 0 + - name: install-key + image: {{ $.Values.coda.image }} + command: + - bash + - -c + - for key in key echo-key faucet-key; do [ ! -f /root/wallet-keys/$key ] || coda accounts import -config-directory /root/.coda-config -privkey-path /root/wallet-keys/$key; done + volumeMounts: + - name: wallet-keys + mountPath: /root/wallet-keys + - name: config-dir + mountPath: /root/.coda-config + env: + - name: CODA_PRIVKEY_PASS + value: {{ $.Values.coda.privkeyPass | quote }} + containers: + {{ if $config.runWithUserAgent -}} + - name: user-agent + resources: + requests: + memory: 512m + cpu: 0.1 + image: {{ $.Values.userAgent.image }} + command: ["bash"] + args: ["-c", "python3 agent.py"] + env: + {{ if ne $.Values.userAgent.minFee "" -}} + - name: AGENT_MIN_FEE + value: {{ $.Values.userAgent.minFee | quote }} + {{ end -}} + {{- if ne $.Values.userAgent.maxFee "" -}} + - name: AGENT_MAX_FEE + value: {{ $.Values.userAgent.maxFee | quote }} + {{ end -}} + {{- if ne $.Values.userAgent.minTx "" -}} + - name: AGENT_MIN_TX + value: {{ $.Values.userAgent.minTx | quote }} + {{ end -}} + {{- if ne $.Values.userAgent.maxTx "" -}} + - name: AGENT_MAX_TX + value: {{ $.Values.userAgent.maxTx | quote }} + {{ end -}} + - name: AGENT_SEND_EVERY_MINUTES + value: "10" + - name: CODA_PUBLIC_KEY + valueFrom: + secretKeyRef: + name: {{ $config.privateKeySecret }} + key: pub + - name: CODA_PRIVKEY_PASS + value: {{ $.Values.coda.privkeyPass | quote }} + - name: PYTHONUNBUFFERED + value: "1" + ports: + - name: metrics + containerPort: 8000 + imagePullPolicy: Always + {{- end }} + {{ if $config.runWithBots -}} + - name: bots + resources: + requests: + memory: 512m + cpu: 0.1 + image: {{ $.Values.bots.image }} + env: + - name: CODA_GRAPHQL_HOST + value: "0.0.0.0" + - name: CODA_GRAPHQL_PORT + value: "3085" + - name: ECHO_PUBLICKEY + valueFrom: + secretKeyRef: + name: echo-service-key + key: pub + - name: ECHO_PASSWORD + value: {{ $.Values.coda.privkeyPass | quote }} + - name: FAUCET_PUBLICKEY + valueFrom: + secretKeyRef: + name: faucet-service-key + key: pub + - name: FAUCET_PASSWORD + value: {{ $.Values.coda.privkeyPass | quote }} + - name: DISCORD_API_KEY + valueFrom: + secretKeyRef: + name: o1-discord-api-key + key: o1discord + - name: FAUCET_AMOUNT + value: {{ $.Values.bots.faucet.amount | quote }} + - name: FEE_AMOUNT + value: {{ $.Values.bots.faucet.fee | quote }} + imagePullPolicy: Always + {{- end }} + - name: coda + resources: + limits: + memory: 6.0Gi + requests: + memory: 2.0Gi + cpu: 1 + image: {{ $.Values.coda.image | quote }} + command: ["/usr/bin/dumb-init", "/root/init_coda.sh"] + args: [ "daemon", + "-log-level", {{ $.Values.coda.logLevel }}, + "-log-json", + {{- if $.Values.coda.logReceivedBlocks }} + "-log-received-blocks", "true", + {{- end -}} + {{- if $.Values.coda.logSnarkWorkGossip }} + "-log-snark-work-gossip", "true", + {{- end -}} + {{- range $.Values.coda.seedPeers }} + "-peer", {{ . | quote }}, + {{- end -}} + "-config-directory", "/root/.coda-config", + "-client-port", "$(DAEMON_CLIENT_PORT)", + "-rest-port", "$(DAEMON_REST_PORT)", + "-insecure-rest-server", + "-external-port", "$(DAEMON_EXTERNAL_PORT)", + "-metrics-port", "$(DAEMON_METRICS_PORT)", + "-block-producer-key", "/root/wallet-keys/key", + {{- if (ne $.Values.coda.runtimeConfig "") -}} + "-config-file", "/config/daemon.json", + "-generate-genesis-proof", "true", + {{- end -}} + ] + env: + - name: DAEMON_REST_PORT + value: "3085" + - name: DAEMON_CLIENT_PORT + value: "8301" + - name: DAEMON_METRICS_PORT + value: "10000" + - name: DAEMON_EXTERNAL_PORT + value: {{ $config.externalPort | quote }} + - name: CODA_PRIVKEY_PASS + value: {{ $.Values.coda.privkeyPass | quote }} + ports: + - containerPort: {{ $config.externalPort }} + hostPort: {{ $config.externalPort }} + protocol: TCP + - name: graphql + containerPort: 3085 + - name: metrics + containerPort: 10000 + imagePullPolicy: Always + volumeMounts: + - name: wallet-keys + mountPath: /root/wallet-keys + - name: config-dir + mountPath: /root/.coda-config + {{- if (ne $.Values.coda.runtimeConfig "") }} + - name: daemon-config + mountPath: "/config/" + {{- end }} + volumes: + - name: private-keys + secret: + secretName: {{ $config.privateKeySecret }} + defaultMode: 256 + items: + - key: key + path: key + - key: pub + path: key.pub + {{ if $config.runWithBots }} + - name: echo-service-key + secret: + secretName: echo-service-key + defaultMode: 256 + items: + - key: key + path: echo-key + - key: pub + path: echo-key.pub + - name: faucet-service-key + secret: + secretName: faucet-service-key + defaultMode: 256 + items: + - key: key + path: faucet-key + - key: pub + path: faucet-key.pub + {{ end -}} + - name: wallet-keys + emptyDir: {} + - name: config-dir + emptyDir: {} + {{- if (ne $.Values.coda.runtimeConfig "") }} + - name: daemon-config + configMap: + name: block-producer-daemon-config + {{- end }} +--- +{{ end }} diff --git a/helm/block-producer/templates/genesis-configmap.yaml b/helm/block-producer/templates/genesis-configmap.yaml new file mode 100644 index 00000000000..3bdb99bf66f --- /dev/null +++ b/helm/block-producer/templates/genesis-configmap.yaml @@ -0,0 +1,12 @@ +{{ if (ne $.Values.coda.runtimeConfig "") -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: block-producer-daemon-config + labels: + app: block-producer + heritage: {{ $.Release.Service }} + release: {{ $.Release.Name }} +data: + daemon.json: {{ $.Values.coda.runtimeConfig | quote }} +{{- end }} diff --git a/helm/block-producer/templates/secret.yaml b/helm/block-producer/templates/secret.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/helm/block-producer/values.yaml b/helm/block-producer/values.yaml new file mode 100644 index 00000000000..774049d8195 --- /dev/null +++ b/helm/block-producer/values.yaml @@ -0,0 +1,56 @@ +testnetName: "coda-testnet" + +coda: + runtimeConfig: "" + logLevel: "Trace" + logReceivedBlocks: false + logSnarkWorkGossip: false + image: codaprotocol/coda-daemon:0.0.12-beta-new-genesis-01eca9b + privkeyPass: "naughty blue worm" + seedPeers: + - /dns4/seed-one.genesis-redux.o1test.net/tcp/10002/p2p/12D3KooWP7fTKbyiUcYJGajQDpCFo2rDexgTHFJTxCH8jvcL1eAH + - /dns4/seed-two.genesis-redux.o1test.net/tcp/10002/p2p/12D3KooWL9ywbiXNfMBqnUKHSB1Q1BaHFNUzppu6JLMVn9TTPFSA + +userAgent: + image: "" + minFee: "" + maxFee: "" + minTx: "" + maxTx: "" + +bots: + image: "" + faucet: + amount: "10000000000" + fee: "100000000" + +# for purposes of testing this chart, we provide defaults that exercise all sidecar permutations +blockProducerConfigs: + - name: "test-1" + class: "test" + externalPort: 1 + runWithUserAgent: false + runWithBots: false + enableGossipFlooding: false + privateKeySecret: "yolo" + - name: "test-2" + class: "test" + externalPort: 2 + runWithUserAgent: true + runWithBots: false + enableGossipFlooding: true + privateKeySecret: "yolo" + - name: "test-3" + class: "test" + externalPort: 3 + runWithUserAgent: false + runWithBots: true + enableGossipFlooding: true + privateKeySecret: "yolo" + - name: "test-4" + class: "test" + externalPort: 4 + runWithUserAgent: true + runWithBots: true + enableGossipFlooding: false + privateKeySecret: "yolo" diff --git a/helm/seed-node/.helmignore b/helm/seed-node/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/helm/seed-node/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/seed-node/Chart.yaml b/helm/seed-node/Chart.yaml new file mode 100644 index 00000000000..8a44104856d --- /dev/null +++ b/helm/seed-node/Chart.yaml @@ -0,0 +1,13 @@ +apiVersion: v2 +name: seed-node +description: A Helm chart for Coda Protocol's seed nodes +type: application +version: 0.1.1 +appVersion: 1.16.0 +dependencies: +icon: https://github.com/CodaProtocol/coda/blob/develop/frontend/website/public/static/img/coda-logo@3x.png +keywords: +- seed +home: https://codaprotocol.com/ +sources: +- https://github.com/CodaProtocol/coda diff --git a/helm/seed-node/README.md b/helm/seed-node/README.md new file mode 100644 index 00000000000..5286e93deef --- /dev/null +++ b/helm/seed-node/README.md @@ -0,0 +1,33 @@ +## Introduction + +This chart bootstraps a Coda protocol seed node. + +## Add Coda Helm chart repository: + + ```console + helm repo add coda + helm repo update + ``` + +## Configuration + +The following table lists the configurable parameters of the `seed-node` chart and its default values. + +### Required Settings + +Parameter | Description +--- | --- +`TODO` | TODO + +### Optional Settings + +Parameter | Description | Default +--- | --- | --- +`TODO` | TODO | `TODO` + +## seed-node launch examples + +```console +helm install seed-node \ + --set testnetName=pickles +``` diff --git a/helm/seed-node/templates/genesis-configmap.yaml b/helm/seed-node/templates/genesis-configmap.yaml new file mode 100644 index 00000000000..b322216df26 --- /dev/null +++ b/helm/seed-node/templates/genesis-configmap.yaml @@ -0,0 +1,12 @@ +{{ if (ne $.Values.coda.runtimeConfig "") -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ tpl $.Values.seed.fullname . }}-daemon-config + labels: + app: {{ tpl $.Values.seed.fullname . }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +data: + daemon.json: {{ $.Values.coda.runtimeConfig | quote }} +{{- end }} diff --git a/helm/seed-node/templates/seed-node.yaml b/helm/seed-node/templates/seed-node.yaml new file mode 100644 index 00000000000..ffbc3947ad1 --- /dev/null +++ b/helm/seed-node/templates/seed-node.yaml @@ -0,0 +1,80 @@ +{{- if $.Values.seed.active }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{tpl $.Values.seed.fullname .}} + labels: + app: {{tpl $.Values.seed.fullname .}} +spec: + replicas: 1 + selector: + matchLabels: + app: {{tpl $.Values.seed.fullname .}} + template: + metadata: + labels: + app: {{tpl $.Values.seed.fullname .}} + testnet: {{ $.Values.testnetName }} + role: seed + version: {{ (split ":" $.Values.coda.image)._1 }} + annotations: + prometheus.io/scrape: 'true' + prometheus.io/port: '10000' + prometheus.io/path: '/metrics' + spec: + containers: + - name: seed + resources: + limits: + memory: 6.0Gi + requests: + memory: 2.0Gi + cpu: 1000m + image: {{ $.Values.coda.image }} + command: ["/usr/bin/dumb-init", "/root/init_coda.sh"] + args: [ "daemon", + "-log-level", "Trace", + "-log-json", + "-log-snark-work-gossip", "true", + "-config-directory", "/root/.coda-config", + "-log-received-blocks", "true", + "-client-port", "$(DAEMON_CLIENT_PORT)", + "-rest-port", "$(DAEMON_REST_PORT)", + "-external-port", "$(DAEMON_EXTERNAL_PORT)", + "-metrics-port", "$(DAEMON_METRICS_PORT)", + "-seed", + "-discovery-keypair", "{{ $.Values.seed.discoveryKeypair }}", + {{- if (ne $.Values.coda.runtimeConfig "") }} + "-config-file", "/config/daemon.json", + "-generate-genesis-proof", "true", + {{- end }} + {{- range $.Values.coda.seedPeers }} + "-peer", {{ . | quote }}, + {{- end }} + ] + env: + - name: DAEMON_REST_PORT + value: "3085" + - name: DAEMON_CLIENT_PORT + value: {{ .Values.seed.rpcPort | quote }} + - name: DAEMON_METRICS_PORT + value: "10000" + - name: CODA_CLIENT_TRUSTLIST + value: "10.0.0.0/8" + - name: DAEMON_EXTERNAL_PORT + value: {{ .Values.seed.hostPort | quote }} + ports: + - containerPort: {{ .Values.seed.hostPort }} + hostPort: {{ .Values.seed.hostPort }} + protocol: TCP + imagePullPolicy: Always + {{- if (ne $.Values.coda.runtimeConfig "") }} + volumeMounts: + - name: daemon-config + mountPath: "/config/" + volumes: + - name: daemon-config + configMap: + name: {{ tpl $.Values.seed.fullname . }}-daemon-config + {{- end -}} +{{- end }} diff --git a/helm/seed-node/templates/seed-service.yaml b/helm/seed-node/templates/seed-service.yaml new file mode 100644 index 00000000000..6068130cda9 --- /dev/null +++ b/helm/seed-node/templates/seed-service.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{tpl $.Values.seed.fullname .}} +spec: + selector: + app: {{tpl $.Values.seed.fullname .}} + clusterIP: None + ports: + - protocol: TCP + port: 8301 + targetPort: 8301 + name: gossip diff --git a/helm/seed-node/values.yaml b/helm/seed-node/values.yaml new file mode 100644 index 00000000000..82c48e31f8d --- /dev/null +++ b/helm/seed-node/values.yaml @@ -0,0 +1,14 @@ +testnetName: "coda-testnet" +coda: + runtimeConfig: "" + image: codaprotocol/coda-daemon:0.0.12-beta-develop-589b507 + seedPeers: + - /ip4/35.185.66.37/tcp/10105/p2p/12D3KooWQ7Pz3SPizarzx9ZhCJ6jNmQ2iDPgHQxVzRzqYU2SgRSd + - /ip4/35.237.214.144/tcp/10120/p2p/12D3KooWGtjWnCcvkaSEbKuNbPivEogxqtLWcsJiQtURydptvrsA + +seed: + active: true + fullname: "seed-node" + hostPort: 10001 + rpcPort: 8301 + discoveryKeypair: "CAESQNf7ldToowe604aFXdZ76GqW/XVlDmnXmBT+otorvIekBmBaDWu/6ZwYkZzqfr+3IrEh6FLbHQ3VSmubV9I9Kpc=,CAESIAZgWg1rv+mcGJGc6n6/tyKxIehS2x0N1Uprm1fSPSqX,12D3KooWAFFq2yEQFFzhU5dt64AWqawRuomG9hL8rSmm5vxhAsgr" diff --git a/helm/snark-worker/.helmignore b/helm/snark-worker/.helmignore new file mode 100644 index 00000000000..50af0317254 --- /dev/null +++ b/helm/snark-worker/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/snark-worker/Chart.yaml b/helm/snark-worker/Chart.yaml new file mode 100644 index 00000000000..d7816c9e7d5 --- /dev/null +++ b/helm/snark-worker/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: snark-worker +description: A Helm chart for Coda Protocol's SNARK worker nodes +type: application +version: 0.1.4 +appVersion: 1.16.0 +dependencies: +icon: https://github.com/CodaProtocol/coda/blob/develop/frontend/website/public/static/img/coda-logo@3x.png +keywords: +- snarks +- zero-knowledge +home: https://codaprotocol.com/ +sources: +- https://github.com/CodaProtocol/coda/tree/develop/src/lib/snark_worker diff --git a/helm/snark-worker/README.md b/helm/snark-worker/README.md new file mode 100644 index 00000000000..7ecbb37cad2 --- /dev/null +++ b/helm/snark-worker/README.md @@ -0,0 +1,33 @@ +## Introduction + +This chart bootstraps a Coda protocol snark worker. + +## Add Coda Helm chart repository: + + ```console + helm repo add coda + helm repo update + ``` + +## Configuration + +The following table lists the configurable parameters of the `snark-worker` chart and its default values. + +### Required Settings + +Parameter | Description +--- | --- +`TODO` | TODO + +### Optional Settings + +Parameter | Description | Default +--- | --- | --- +`TODO` | TODO | `TODO` + +## snark-worker launch examples + +```console +helm install snark-worker \ + --set testnetName=pickles +``` diff --git a/helm/snark-worker/templates/coordinator-service.yaml b/helm/snark-worker/templates/coordinator-service.yaml new file mode 100644 index 00000000000..4e9758e8b86 --- /dev/null +++ b/helm/snark-worker/templates/coordinator-service.yaml @@ -0,0 +1,15 @@ +{{- if $.Values.coordinator.active }} +apiVersion: v1 +kind: Service +metadata: + name: {{tpl $.Values.coordinator.fullname .}} + labels: + app: {{tpl $.Values.coordinator.fullname .}} +spec: + clusterIP: None + ports: + - port: {{ $.Values.coordinator.rpcPort }} + name: rpc + selector: + app: {{tpl $.Values.coordinator.fullname .}} +{{ end }} diff --git a/helm/snark-worker/templates/genesis-configmap.yaml b/helm/snark-worker/templates/genesis-configmap.yaml new file mode 100644 index 00000000000..316a609c711 --- /dev/null +++ b/helm/snark-worker/templates/genesis-configmap.yaml @@ -0,0 +1,12 @@ +{{ if (ne $.Values.coda.runtimeConfig "") -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: snark-coordinator-daemon-config + labels: + app: snark-coordinator + heritage: {{ $.Release.Service }} + release: {{ $.Release.Name }} +data: + daemon.json: {{ $.Values.coda.runtimeConfig | quote }} +{{- end }} diff --git a/helm/snark-worker/templates/snark-coordinator.yaml b/helm/snark-worker/templates/snark-coordinator.yaml new file mode 100644 index 00000000000..138c9100843 --- /dev/null +++ b/helm/snark-worker/templates/snark-coordinator.yaml @@ -0,0 +1,87 @@ +{{- if $.Values.coordinator.active }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{tpl $.Values.coordinator.fullname .}} + labels: + app: {{tpl $.Values.coordinator.fullname .}} +spec: + replicas: {{ .Values.numReplicas }} + selector: + matchLabels: + app: {{tpl $.Values.coordinator.fullname .}} + template: + metadata: + labels: + app: {{tpl $.Values.coordinator.fullname .}} + testnet: {{ $.Values.testnetName }} + role: snark-coordinator + version: {{ (split ":" $.Values.coda.image)._1 }} + annotations: + prometheus.io/scrape: 'true' + prometheus.io/port: '10000' + prometheus.io/path: '/metrics' + spec: + containers: + - name: coordinator + resources: + limits: + memory: 6.0Gi + requests: + memory: 2.0Gi + cpu: 2.0 + image: {{ $.Values.coda.image }} + command: ["/usr/bin/dumb-init", "/root/init_coda.sh"] + args: [ "daemon", + "-log-level", "Trace", + "-log-json", + "-config-directory", "/root/.coda-config", + "-log-received-blocks", "true", + "-log-snark-work-gossip", "true", + "-client-port", "$(DAEMON_CLIENT_PORT)", + "-rest-port", "$(DAEMON_REST_PORT)", + "-external-port", "$(DAEMON_EXTERNAL_PORT)", + "-metrics-port", "$(DAEMON_METRICS_PORT)", + "-run-snark-coordinator", "$(CODA_SNARK_KEY)", + "-snark-worker-fee", "$(CODA_SNARK_FEE)", + "-work-selection", "$(WORK_SELECTION)", + {{- if $.Values.coda.genesis.active }} + "-config-file", "/config/daemon.json", + "-generate-genesis-proof", "true", + {{- end }} + {{- range $.Values.coda.seedPeers }} + "-peer", {{ . | quote }}, + {{- end }} + ] + env: + - name: DAEMON_REST_PORT + value: "3085" + - name: DAEMON_CLIENT_PORT + value: {{ .Values.coordinator.rpcPort | quote }} + - name: DAEMON_METRICS_PORT + value: "10000" + - name: CODA_CLIENT_TRUSTLIST + value: "10.0.0.0/8" + - name: CODA_SNARK_KEY + value: {{ .Values.coordinator.publicKey | quote }} + - name: CODA_SNARK_FEE + value: {{ .Values.coordinator.snarkFee | quote }} + - name: DAEMON_EXTERNAL_PORT + value: {{ .Values.coordinator.hostPort | quote }} + - name: WORK_SELECTION + value: {{$.Values.coordinator.workSelectionAlgorithm | quote }} + ports: + - containerPort: {{ .Values.coordinator.hostPort }} + hostPort: {{ .Values.coordinator.hostPort }} + protocol: TCP + imagePullPolicy: Always + {{- if $.Values.coda.genesis.active }} + volumeMounts: + - name: daemon-config + mountPath: "/config/" + volumes: + - name: daemon-config + configMap: + name: snark-coordinator-daemon-config + {{- end -}} +{{- end }} diff --git a/helm/snark-worker/templates/snark-worker.yaml b/helm/snark-worker/templates/snark-worker.yaml new file mode 100644 index 00000000000..85d6e2a1c3b --- /dev/null +++ b/helm/snark-worker/templates/snark-worker.yaml @@ -0,0 +1,38 @@ +{{- if $.Values.worker.active }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{tpl $.Values.worker.fullname .}} + labels: + app: {{tpl $.Values.worker.fullname .}} +spec: + replicas: {{ $.Values.worker.numReplicas }} + selector: + matchLabels: + app: {{tpl $.Values.worker.fullname .}} + template: + metadata: + labels: + app: {{tpl $.Values.worker.fullname .}} + testnet: {{ $.Values.testnetName }} + role: snark-worker + version: {{ (split ":" $.Values.coda.image)._1 }} + annotations: + prometheus.io/scrape: 'true' + prometheus.io/port: '10000' + prometheus.io/path: '/metrics' + spec: + containers: + - name: worker + resources: + limits: + memory: 3.0Gi + requests: + memory: 2.0Gi + cpu: 1000m + image: {{ $.Values.coda.image }} + command: ["bash", "-c"] + args: [ "sleep 120 && coda internal snark-worker -proof-level full -daemon-address '{{ tpl $.Values.worker.remoteCoordinatorHost . }}:{{ $.Values.worker.remoteCoordinatorPort }}'" ] + env: + imagePullPolicy: Always +{{ end }} diff --git a/helm/snark-worker/values.yaml b/helm/snark-worker/values.yaml new file mode 100644 index 00000000000..b05115e18e9 --- /dev/null +++ b/helm/snark-worker/values.yaml @@ -0,0 +1,31 @@ +testnetName: "coda-testnet" +coda: + genesis: + active: true + k: 10 + delta: 3 + txpool_max_size: 3000 + genesis_state_timestamp: "2020-04-20 11:00:00-07:00" + ledger: "{}" + image: codaprotocol/coda-daemon:0.0.12-beta-develop-589b507 + seedPeers: + - /ip4/35.185.66.37/tcp/10105/p2p/12D3KooWQ7Pz3SPizarzx9ZhCJ6jNmQ2iDPgHQxVzRzqYU2SgRSd + - /ip4/35.237.214.144/tcp/10120/p2p/12D3KooWGtjWnCcvkaSEbKuNbPivEogxqtLWcsJiQtURydptvrsA + runtimeConfig: "" + +worker: + fullname: "snark-worker-{{ trunc -6 .Values.coordinator.publicKey | lower }}" + active: true + numReplicas: 1 + remoteCoordinatorHost: "{{ tpl $.Values.coordinator.fullname . }}.{{ $.Values.testnetName }}" + remoteCoordinatorPort: 8301 + +coordinator: + fullname: "snark-coordinator-{{ trunc -6 .Values.coordinator.publicKey | lower }}" + rpcPort: 8301 + hostPort: 10001 + deployService: true + active: true + publicKey: "4vsRCVadXwWMSGA9q81reJRX3BZ5ZKRtgZU7PtGsNq11w2V9tUNf4urZAGncZLUiP4SfWqur7AZsyhJKD41Ke7rJJ8yDibL41ePBeATLUnwNtMTojPDeiBfvTfgHzbAVFktD65vzxMNCvvAJ" + snarkFee: "0.025" + workSelectionAlgorithm: seq # seq OR rand