From 802844c39d646e0b71afb69f90337df9159f07fb Mon Sep 17 00:00:00 2001 From: Thiago Nobayashi Date: Tue, 30 May 2023 21:57:14 -0300 Subject: [PATCH] chore: add tce-all-in-one 0.2.4 --- charts/tce-all-in-one/.helmignore | 23 ++++ charts/tce-all-in-one/Chart.yaml | 24 ++++ .../templates/00-tce-services.yaml | 44 +++++++ .../templates/01-tce-deployments.yaml | 120 ++++++++++++++++++ charts/tce-all-in-one/values.yaml | 43 +++++++ 5 files changed, 254 insertions(+) create mode 100644 charts/tce-all-in-one/.helmignore create mode 100644 charts/tce-all-in-one/Chart.yaml create mode 100644 charts/tce-all-in-one/templates/00-tce-services.yaml create mode 100644 charts/tce-all-in-one/templates/01-tce-deployments.yaml create mode 100644 charts/tce-all-in-one/values.yaml diff --git a/charts/tce-all-in-one/.helmignore b/charts/tce-all-in-one/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/tce-all-in-one/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/tce-all-in-one/Chart.yaml b/charts/tce-all-in-one/Chart.yaml new file mode 100644 index 0000000..853c74c --- /dev/null +++ b/charts/tce-all-in-one/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: tce-all-in-one +description: A Helm chart for TCE + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.2.4 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "main" diff --git a/charts/tce-all-in-one/templates/00-tce-services.yaml b/charts/tce-all-in-one/templates/00-tce-services.yaml new file mode 100644 index 0000000..988d946 --- /dev/null +++ b/charts/tce-all-in-one/templates/00-tce-services.yaml @@ -0,0 +1,44 @@ +{{- range $index, $e := until (int $.Values.replicas) }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ $.Values.mode }}-{{ $index }} + labels: + app: {{ $.Values.mode }}-{{ $index }} +spec: + type: ClusterIP + ports: + - port: {{ $.Values.ports.p2p }} + targetPort: p2p + protocol: TCP + name: p2p + - port: {{ $.Values.ports.http }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ $.Values.mode }}-{{ $index }} + sessionAffinity: ClientIP +{{- end }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ $.Values.mode }} + labels: + app: {{ $.Values.mode }} +spec: + type: ClusterIP + ports: + - port: {{ $.Values.ports.p2p }} + targetPort: p2p + protocol: TCP + name: p2p + - port: {{ $.Values.ports.http }} + targetPort: http + protocol: TCP + name: http + selector: + node: {{ $.Values.mode }} + sessionAffinity: ClientIP diff --git a/charts/tce-all-in-one/templates/01-tce-deployments.yaml b/charts/tce-all-in-one/templates/01-tce-deployments.yaml new file mode 100644 index 0000000..6335f29 --- /dev/null +++ b/charts/tce-all-in-one/templates/01-tce-deployments.yaml @@ -0,0 +1,120 @@ +{{- range $index, $e := until (int $.Values.replicas) }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $.Values.mode }}-{{ $index }} + labels: + app: {{ $.Values.mode }}-{{ $index }} +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: {{ $.Values.mode }}-{{ $index }} + template: + metadata: + labels: + app: {{ $.Values.mode }}-{{ $index }} + node: {{ $.Values.mode }} + spec: + hostname: {{ $.Values.mode }}-{{ $index }} + {{ if $.Values.singleTCENodePerK8sNode }} + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: node + operator: In + values: + - {{ $.Values.mode }} + topologyKey: "kubernetes.io/hostname" + {{ end }} + containers: + - name: {{ $.Values.mode }} + image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}" + imagePullPolicy: Always + startupProbe: + {{ if eq $.Values.mode "boot" }} + exec: + command: + - /bin/bash + - -c + - topos tce push-peer-list --node http://localhost:1340 --format json /tmp/shared/peer_ids.json; + {{ else }} + exec: + command: + - /bin/bash + - -c + - PEER=$(topos tce keys --from-seed=$HOSTNAME); NODE="http://$HOSTNAME:1340"; { topos tce push-peer-list --node http://localhost:1340 --format json /tmp/shared/peer_ids.json && topos tce status --node http://localhost:1340; } && { ( flock --exclusive -w 10 201 || exit 1; cat <<< $(jq --arg PEER $PEER '. |= (. + [$PEER] | unique )' /tmp/shared/peer_ids.json) > /tmp/shared/peer_ids.json;) 201>"/tmp/shared/peer_ids.json.lock"; ( flock --exclusive -w 10 200 || exit 1; cat <<< $(jq --arg NODE $NODE '.nodes |= (. + [$NODE] | unique)' /tmp/shared/peer_nodes.json) > /tmp/shared/peer_nodes.json;) 200>"/tmp/shared/peer_nodes.json.lock"; exit 0; } || { ( flock --exclusive -w 10 201 || exit 1; cat <<< $(jq --arg PEER $PEER '. |= (. - [$PEER])' /tmp/shared/peer_ids.json) > /tmp/shared/peer_ids.json;) 201>"/tmp/shared/peer_ids.json.lock"; ( flock --exclusive -w 10 200 || exit 1; cat <<< $(jq --arg NODE $NODE '.nodes |= (. - [$NODE])' /tmp/shared/peer_nodes.json) > /tmp/shared/peer_nodes.json;) 200>"/tmp/shared/peer_nodes.json.lock"; exit 1; }; + {{ end }} + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 30 + successThreshold: 1 + args: ["{{ $.Values.mode }}", "tce", "run"] + ports: + - name: p2p + containerPort: {{ $.Values.ports.p2p }} + protocol: TCP + - name: http + containerPort: {{ $.Values.ports.http }} + protocol: TCP + volumeMounts: + - mountPath: /tmp/shared + name: shared + env: + - name: TCE_LOCAL_KS + value: "{{ $.Values.env.TCE_LOCAL_KS }}" + - name: LOCAL_TEST_NET + value: "{{ $.Values.env.LOCAL_TEST_NET }}" + - name: TOOLCHAIN_VERSION + value: "{{ $.Values.env.TOOLCHAIN_VERSION }}" + - name: RUST_LOG + value: "{{ $.Values.env.RUST_LOG }}" + - name: RUST_BACKTRACE + value: "{{ $.Values.env.RUST_BACKTRACE }}" + - name: TCE_DB_PATH + value: "{{ $.Values.env.TCE_DB_PATH }}" + - name: TCE_API_ADDR + value: "{{ $.Values.env.TCE_API_ADDR }}" + - name: TOPOS_OTLP_SERVICE_NAME + value: "{{ $.Values.env.TOPOS_OTLP_SERVICE_NAME }}" + - name: TOPOS_OTLP_AGENT + value: "{{ $.Values.env.TOPOS_OTLP_AGENT }}" + - name: TCE_ECHO_SAMPLE_SIZE + value: "{{ $.Values.env.TCE_ECHO_SAMPLE_SIZE }}" + - name: TCE_READY_SAMPLE_SIZE + value: "{{ $.Values.env.TCE_READY_SAMPLE_SIZE }}" + - name: TCE_DELIVERY_SAMPLE_SIZE + value: "{{ $.Values.env.TCE_DELIVERY_SAMPLE_SIZE }}" + - name: TCE_ECHO_THRESHOLD + value: "{{ $.Values.env.TCE_ECHO_THRESHOLD }}" + - name: TCE_READY_THRESHOLD + value: "{{ $.Values.env.TCE_READY_THRESHOLD }}" + - name: TCE_DELIVERY_THRESHOLD + value: "{{ $.Values.env.TCE_DELIVERY_THRESHOLD }}" + - name: TOPOS_OTLP_TAGS + value: "{{ $.Values.env.TOPOS_OTLP_TAGS }}" + - name: OTLP_BATCH_SCHEDULED_DELAY + value: "{{ $.Values.env.OTLP_BATCH_SCHEDULED_DELAY }}" + - name: OTLP_BATCH_MAX_CONCURRENT_EXPORTS + value: "{{ $.Values.env.OTLP_BATCH_MAX_CONCURRENT_EXPORTS }}" + - name: OTLP_BATCH_MAX_EXPORTER_BATCH_SIZE + value: "{{ $.Values.env.OTLP_BATCH_MAX_EXPORTER_BATCH_SIZE }}" + - name: OTLP_BATCH_EXPORT_TIMEOUT + value: "{{ $.Values.env.OTLP_BATCH_EXPORT_TIMEOUT }}" + - name: OTLP_BATCH_MAX_QUEUE_SIZE + value: "{{ $.Values.env.OTLP_BATCH_MAX_QUEUE_SIZE }}" + - name: OTEL_EXPORTER_OTLP_COMPRESSION + value: "{{ $.Values.env.OTEL_EXPORTER_OTLP_COMPRESSION }}" + - name: OTEL_EXPORTER_OTLP_TIMEOUT + value: "{{ $.Values.env.OTEL_EXPORTER_OTLP_TIMEOUT }}" + volumes: + - name: shared + persistentVolumeClaim: + claimName: shared +--- +{{- end }} diff --git a/charts/tce-all-in-one/values.yaml b/charts/tce-all-in-one/values.yaml new file mode 100644 index 0000000..44af9c0 --- /dev/null +++ b/charts/tce-all-in-one/values.yaml @@ -0,0 +1,43 @@ +# Default values for tce-all-in-one. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicas: 5 + +# mode can be (boot | peer) +mode: boot + +# deploy a single TCE node per K8s node +singleTCENodePerK8sNode: true + +ports: + http: 1340 + p2p: 9090 + +image: + repository: ghcr.io/topos-network/topos + tag: main-tce + +env: + RUST_LOG: warn,topos=warn + TCE_DB_PATH: /tmp/default-db + TCE_API_ADDR: 0.0.0.0:1340 + TOPOS_OTLP_AGENT: tce-node + TOPOS_OTLP_SERVICE_NAME: https://telemetry.nowhere.com + TCE_ECHO_SAMPLE_SIZE: "6" + TCE_READY_SAMPLE_SIZE: "6" + TCE_DELIVERY_SAMPLE_SIZE: "6" + TCE_ECHO_THRESHOLD: "2" + TCE_READY_THRESHOLD: "2" + TCE_DELIVERY_THRESHOLD: "2" + LOCAL_TEST_NET: "true" + TCE_LOCAL_KS: "1" + RUST_BACKTRACE: full + TOOLCHAIN_VERSION: stable + TOPOS_OTLP_TAGS: key1=value1,key2=value2 + OTLP_BATCH_SCHEDULED_DELAY: "1500" + OTLP_BATCH_MAX_CONCURRENT_EXPORTS: "1000" + OTLP_BATCH_MAX_EXPORTER_BATCH_SIZE: "10000" + OTLP_BATCH_EXPORT_TIMEOUT: "100000" + OTLP_BATCH_MAX_QUEUE_SIZE: "10000" + OTEL_EXPORTER_OTLP_COMPRESSION: "gzip" + OTEL_EXPORTER_OTLP_TIMEOUT: "60"