From d59844eb4a78b5ff38c69b625f337015d0af79ea Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Wed, 11 Oct 2023 11:30:09 +0200 Subject: [PATCH] feat: add beacon charts --- charts/beacon/Chart.yaml | 8 +- charts/beacon/README.md | 27 +++---- charts/beacon/templates/NOTES.txt | 8 +- charts/beacon/templates/_helpers.tpl | 16 ++-- charts/beacon/templates/deployment.yaml | 76 +++++++++++++------ charts/beacon/templates/ingress.yaml | 4 +- charts/beacon/templates/service.yaml | 16 ++-- .../templates/tests/test-connection.yaml | 6 +- charts/beacon/values.yaml | 44 +++++------ 9 files changed, 112 insertions(+), 93 deletions(-) diff --git a/charts/beacon/Chart.yaml b/charts/beacon/Chart.yaml index 597b5ff..d287f8f 100644 --- a/charts/beacon/Chart.yaml +++ b/charts/beacon/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 -name: hermes -description: Pyth cross-chain server +name: beacon +description: Highly available Wormhole RPC type: application -version: 0.2.2 -appVersion: v0.2.1 +version: 0.1.0 +appVersion: v0.1.0 diff --git a/charts/beacon/README.md b/charts/beacon/README.md index 5d361cf..82ed332 100644 --- a/charts/beacon/README.md +++ b/charts/beacon/README.md @@ -1,26 +1,22 @@ -# hermes +# beacon -![Version: 0.2.2](https://img.shields.io/badge/Version-0.2.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.2.1](https://img.shields.io/badge/AppVersion-v0.2.1-informational?style=flat-square) +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.1.0](https://img.shields.io/badge/AppVersion-v0.1.0-informational?style=flat-square) -Pyth cross-chain server +Highly available Wormhole RPC ## Values | Key | Type | Default | Description | |-----|------|---------|-------------| | affinity | object | `{}` | | +| beacon.logLevel | string | `"warn"` | Beacon log level. Valid values are: trace, debug, info, warn, error | +| beacon.natsUrl | string | `nil` | NATS server URL. Must be set. Example: nats.nats:4222 | +| beacon.wormholeBootstrapAddrs | string | `"/dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7,/dns4/wormhole-v2-mainnet-bootstrap.xlabs.xyz/udp/8999/quic/p2p/12D3KooWNQ9tVrcb64tw6bNs2CaNrUGPM7yRrKvBBheQ5yCyPHKC"` | Wormhole bootstrap addresses | +| beacon.wormholeNetworkId | string | `"/wormhole/mainnet/2"` | Wormhole network id | +| beacon.writerBatchSize | string | `"1000"` | Batch size for the writer. When the batch size is reached, the writer will flush the batch to the NATS stream. | | fullnameOverride | string | `""` | | -| hermes.benchmarks.enabled | bool | `true` | Enable benchmarks. Benchmarks endpoint does not support Hermes Beta yet and you need to disable it for that. | -| hermes.benchmarks.endpoint | string | `"https://benchmarks.pyth.network"` | Benchmarks endpoint. | -| hermes.logLevel | string | `"warn"` | Hermes log level. Valid values are: trace, debug, info, warn, error | -| hermes.pythnetHttpAddr | string | `nil` | Pythnet Http RPC address. Must be set. Example: http://localhost:8899 | -| hermes.pythnetWsAddr | string | `nil` | Pythnet Websocket RPC address. Must be set. Example: ws://localhost:8900 | -| hermes.rpcWsWhitelist | string | `nil` | Whitelisted ip network addresses (in CIDR notation) against websocket ratelimit (separated by comma). Example: 1.2.0.0/24,3.0.0.0/8 | -| hermes.wormholeBootstrapAddrs | string | `"/dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7,/dns4/wormhole-v2-mainnet-bootstrap.xlabs.xyz/udp/8999/quic/p2p/12D3KooWNQ9tVrcb64tw6bNs2CaNrUGPM7yRrKvBBheQ5yCyPHKC"` | Wormhole bootstrap addresses | -| hermes.wormholeContractAddr | string | `"H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU"` | Wormhole contract address | -| hermes.wormholeNetworkId | string | `"/wormhole/mainnet/2"` | Wormhole network id | | image.pullPolicy | string | `"IfNotPresent"` | | -| image.repository | string | `"public.ecr.aws/pyth-network/hermes"` | | +| image.repository | string | `"public.ecr.aws/pyth-network/beacon"` | | | image.tag | string | `""` | | | imagePullSecrets | list | `[]` | | | ingress.annotations | object | `{}` | | @@ -37,14 +33,15 @@ Pyth cross-chain server | podSecurityContext.runAsGroup | int | `10001` | | | podSecurityContext.runAsNonRoot | bool | `true` | | | podSecurityContext.runAsUser | int | `10001` | | -| replicaCount | int | `1` | | +| replicaCount | int | `3` | Number of Beacon replicas | | resources.limits | object | `{}` | | | resources.requests.cpu | int | `1` | | | resources.requests.memory | string | `"1Gi"` | | | securityContext.allowPrivilegeEscalation | bool | `false` | | | securityContext.capabilities.drop[0] | string | `"ALL"` | | | securityContext.readOnlyRootFilesystem | bool | `true` | | -| service.port | int | `8080` | | +| service.grpcPort | int | `8080` | | +| service.metricsPort | int | `8081` | | | service.type | string | `"ClusterIP"` | | | tolerations | list | `[]` | | diff --git a/charts/beacon/templates/NOTES.txt b/charts/beacon/templates/NOTES.txt index 6dbed94..ecc6642 100644 --- a/charts/beacon/templates/NOTES.txt +++ b/charts/beacon/templates/NOTES.txt @@ -6,16 +6,16 @@ {{- end }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "hermes.fullname" . }}) + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "beacon.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "hermes.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "hermes.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "beacon.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "beacon.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "hermes.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "beacon.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT diff --git a/charts/beacon/templates/_helpers.tpl b/charts/beacon/templates/_helpers.tpl index 401302c..4579e3c 100644 --- a/charts/beacon/templates/_helpers.tpl +++ b/charts/beacon/templates/_helpers.tpl @@ -1,7 +1,7 @@ {{/* Expand the name of the chart. */}} -{{- define "hermes.name" -}} +{{- define "beacon.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -10,7 +10,7 @@ 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 "hermes.fullname" -}} +{{- define "beacon.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "hermes.chart" -}} +{{- define "beacon.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "hermes.labels" -}} -helm.sh/chart: {{ include "hermes.chart" . }} -{{ include "hermes.selectorLabels" . }} +{{- define "beacon.labels" -}} +helm.sh/chart: {{ include "beacon.chart" . }} +{{ include "beacon.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -45,7 +45,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "hermes.selectorLabels" -}} -app.kubernetes.io/name: {{ include "hermes.name" . }} +{{- define "beacon.selectorLabels" -}} +app.kubernetes.io/name: {{ include "beacon.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} diff --git a/charts/beacon/templates/deployment.yaml b/charts/beacon/templates/deployment.yaml index c569bd8..0c6b1b9 100644 --- a/charts/beacon/templates/deployment.yaml +++ b/charts/beacon/templates/deployment.yaml @@ -1,14 +1,14 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "hermes.fullname" . }} + name: {{ include "beacon.fullname" . }} labels: - {{- include "hermes.labels" . | nindent 4 }} + {{- include "beacon.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - {{- include "hermes.selectorLabels" . | nindent 6 }} + {{- include "beacon.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.podAnnotations }} @@ -16,7 +16,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "hermes.selectorLabels" . | nindent 8 }} + {{- include "beacon.selectorLabels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: @@ -29,49 +29,75 @@ spec: image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} command: - - hermes + - beacon - run - --pythnet-http-addr - - {{ required "hermes.pythnetHttpAddr is required" .Values.hermes.pythnetHttpAddr }} + - {{ required "beacon.pythnetHttpAddr is required" .Values.beacon.pythnetHttpAddr }} - --pythnet-ws-addr - - {{ required "hermes.pythnetWsAddr is required" .Values.hermes.pythnetWsAddr }} + - {{ required "beacon.pythnetWsAddr is required" .Values.beacon.pythnetWsAddr }} - --rpc-listen-addr - 0.0.0.0:8080 - {{- if .Values.hermes.rpcWsWhitelist }} + {{- if .Values.beacon.rpcWsWhitelist }} - --rpc-ws-whitelist - - {{ .Values.hermes.rpcWsWhitelist }} + - {{ .Values.beacon.rpcWsWhitelist }} {{- end }} - --wormhole-bootstrap-addrs - - {{ .Values.hermes.wormholeBootstrapAddrs }} + - {{ .Values.beacon.wormholeBootstrapAddrs }} - --wormhole-network-id - - {{ .Values.hermes.wormholeNetworkId }} + - {{ .Values.beacon.wormholeNetworkId }} - --wormhole-contract-addr - - {{ .Values.hermes.wormholeContractAddr }} - {{- if .Values.hermes.benchmarks.enabled }} + - {{ .Values.beacon.wormholeContractAddr }} + {{- if .Values.beacon.benchmarks.enabled }} - --benchmarks-endpoint - - {{ .Values.hermes.benchmarks.endpoint }} + - {{ .Values.beacon.benchmarks.endpoint }} {{- end }} env: - - name: RUST_LOG - value: {{ .Values.hermes.logLevel }} + - name: WORMHOLE_LISTEN + value: /ip4/0.0.0.0/udp/30910/quic + - name: SERVER_URL + value: :8080 + - name: METRICS_URL + value: :8081 + - name: HEARTBEAT_URL + value: :9000 + - name: HEARTBEAT_INTERVAL + value: 10 + - name: LOG_LEVEL + value: {{ .Values.beacon.logLevel }} + - name: WORMHOLE_NETWORK_ID + value: {{ .Values.beacon.wormholeNetworkId }} + - name: WORMHOLE_BOOTSTRAP + value: {{ .Values.beacon.wormholeBootstrapAddrs }} + - name: NATS_URL + value: {{ .Values.beacon.natsUrl }} + - name: WRITER_BATCH_SIZE + value: {{ .Values.beacon.writerBatchSize }} ports: - - name: http - containerPort: 8080 + - containerPort: 7072 protocol: TCP + name: grpc + - containerPort: 8081 + protocol: TCP + name: metrics + - containerPort: 9000 + protocol: TCP + name: heartbeat + - containerPort: 30910 + protocol: UDP + name: wormhole-listen livenessProbe: httpGet: path: /ready - port: 8080 + port: 9000 initialDelaySeconds: 30 periodSeconds: 5 failureThreshold: 1 - readinessProbe: + livenessProbe: httpGet: - path: /ready - port: 8080 - initialDelaySeconds: 30 - periodSeconds: 5 - failureThreshold: 1 + path: / + port: 9000 + initialDelaySeconds: 5 + periodSeconds: 3 resources: {{- toYaml .Values.resources | nindent 12 }} securityContext: diff --git a/charts/beacon/templates/ingress.yaml b/charts/beacon/templates/ingress.yaml index 74a62f0..4423ae7 100644 --- a/charts/beacon/templates/ingress.yaml +++ b/charts/beacon/templates/ingress.yaml @@ -1,5 +1,5 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "hermes.fullname" . -}} +{{- $fullName := include "beacon.fullname" . -}} {{- $svcPort := .Values.service.port -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} @@ -17,7 +17,7 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - {{- include "hermes.labels" . | nindent 4 }} + {{- include "beacon.labels" . | nindent 4 }} {{- with .Values.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/beacon/templates/service.yaml b/charts/beacon/templates/service.yaml index ee81b89..26f24e6 100644 --- a/charts/beacon/templates/service.yaml +++ b/charts/beacon/templates/service.yaml @@ -1,15 +1,19 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "hermes.fullname" . }} + name: {{ include "beacon.fullname" . }} labels: - {{- include "hermes.labels" . | nindent 4 }} + {{- include "beacon.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: - - port: {{ .Values.service.port }} - targetPort: http + - port: {{ .Values.service.grpcPort }} + targetPort: grpc protocol: TCP - name: http + name: grpc + - port: {{ .Values.service.metricsPort }} + targetPort: metrics + protocol: TCP + name: metrics selector: - {{- include "hermes.selectorLabels" . | nindent 4 }} + {{- include "beacon.selectorLabels" . | nindent 4 }} diff --git a/charts/beacon/templates/tests/test-connection.yaml b/charts/beacon/templates/tests/test-connection.yaml index 84449b8..912d109 100644 --- a/charts/beacon/templates/tests/test-connection.yaml +++ b/charts/beacon/templates/tests/test-connection.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Pod metadata: - name: "{{ include "hermes.fullname" . }}-test-connection" + name: "{{ include "beacon.fullname" . }}-test-connection" labels: - {{- include "hermes.labels" . | nindent 4 }} + {{- include "beacon.labels" . | nindent 4 }} annotations: "helm.sh/hook": test spec: @@ -11,5 +11,5 @@ spec: - name: wget image: busybox command: ['wget'] - args: ['{{ include "hermes.fullname" . }}:{{ .Values.service.port }}'] + args: ['{{ include "beacon.fullname" . }}:{{ .Values.service.port }}'] restartPolicy: Never diff --git a/charts/beacon/values.yaml b/charts/beacon/values.yaml index d97334f..d286622 100644 --- a/charts/beacon/values.yaml +++ b/charts/beacon/values.yaml @@ -1,40 +1,31 @@ -# Default values for hermes application config. You should replace -# the pythnet endpoint values with your own. -hermes: - # -- Hermes log level. Valid values are: trace, debug, info, warn, error +# Default values for beacon application config. +beacon: + # -- Beacon log level. Valid values are: trace, debug, info, warn, error logLevel: warn - # -- Pythnet Http RPC address. Must be set. Example: http://localhost:8899 - pythnetHttpAddr: - # -- Pythnet Websocket RPC address. Must be set. Example: ws://localhost:8900 - pythnetWsAddr: - benchmarks: - # -- Enable benchmarks. Benchmarks endpoint does not support Hermes Beta yet and you need to disable it for that. - enabled: true - # -- Benchmarks endpoint. - endpoint: https://benchmarks.pyth.network + # -- NATS server URL. Must be set. Example: nats.nats:4222 + natsUrl: - # -- Whitelisted ip network addresses (in CIDR notation) against websocket ratelimit (separated by comma). Example: 1.2.0.0/24,3.0.0.0/8 - rpcWsWhitelist: + # -- Batch size for the writer. When the batch size is reached, the writer will flush the batch to the NATS stream. + writerBatchSize: "1000" - # -- Wormhole bootstrap addresses - wormholeBootstrapAddrs: /dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7,/dns4/wormhole-v2-mainnet-bootstrap.xlabs.xyz/udp/8999/quic/p2p/12D3KooWNQ9tVrcb64tw6bNs2CaNrUGPM7yRrKvBBheQ5yCyPHKC # -- Wormhole network id wormholeNetworkId: /wormhole/mainnet/2 - # -- Wormhole contract address - wormholeContractAddr: H3fxXJ86ADW2PNuDDmZJg6mzTtPxkYCpNuQUTgmJ7AjU - # The values below are the values for our Hermes Beta using testnet wormhole - # wormholeBootstrapAddrs: /dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWAkB9ynDur1Jtoa97LBUp8RXdhzS5uHgAfdTquJbrbN7i + # -- Wormhole bootstrap addresses + wormholeBootstrapAddrs: /dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7,/dns4/wormhole-v2-mainnet-bootstrap.xlabs.xyz/udp/8999/quic/p2p/12D3KooWNQ9tVrcb64tw6bNs2CaNrUGPM7yRrKvBBheQ5yCyPHKC + + # The values below are the values testnet Wormhole + # wormholeBootstrapAddrs: /dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWAkB9ynDur1Jtoa97LBUp8RXdhzS5uHgAfdTquJbrbN7i,/dns4/t-guardian-01.nodes.stable.io/udp/8999/quic/p2p/12D3KooWCW3LGUtkCVkHZmVSZHzL3C4WRKWfqAiJPz1NR7dT9Bxh,/dns4/t-guardian-02.nodes.stable.io/udp/8999/quic/p2p/12D3KooWJXA6goBCiWM8ucjzc4jVUBSqL9Rri6UpjHbkMPErz5zK # wormholeNetworkId: /wormhole/testnet/2/1 - # wormholeContractAddr: EUrRARh92Cdc54xrDn6qzaqjA77NRrCcfbr8kPwoTL4z -# Default values for hermes production config +# Default values for beacon production config -replicaCount: 1 +# -- Number of Beacon replicas +replicaCount: 3 image: - repository: public.ecr.aws/pyth-network/hermes + repository: public.ecr.aws/pyth-network/beacon pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "" @@ -60,7 +51,8 @@ securityContext: service: type: ClusterIP - port: 8080 + grpcPort: 8080 + metricsPort: 8081 ingress: enabled: false