From a0ecfdb71b257a6c507806c06c434fe77604aacf Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Thu, 4 May 2023 19:50:30 -0400 Subject: [PATCH] Add Node RPC and BCD ingresses (#583) * Add bcd ingress * Rename bcd indexerRpcUrl field to rpcUrl + add pathType * Add rpc ingress --- charts/tezos/templates/_helpers.tpl | 2 +- charts/tezos/templates/bcd_indexer.yaml | 61 +++++++++++++++++++++++-- charts/tezos/templates/ingress.yaml | 39 ++++++++++++++++ charts/tezos/values.yaml | 33 +++++++++++-- 4 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 charts/tezos/templates/ingress.yaml diff --git a/charts/tezos/templates/_helpers.tpl b/charts/tezos/templates/_helpers.tpl index 57a08d659..1f5823ec4 100644 --- a/charts/tezos/templates/_helpers.tpl +++ b/charts/tezos/templates/_helpers.tpl @@ -133,7 +133,7 @@ metadata: Returns the true type or empty string which is falsey. */}} {{- define "tezos.shouldDeployBcdIndexer" -}} - {{- if and .indexerRpcUrl .db.password }} + {{- if and .rpcUrl .db.password }} {{- "true" }} {{- else }} {{- "" }} diff --git a/charts/tezos/templates/bcd_indexer.yaml b/charts/tezos/templates/bcd_indexer.yaml index 88ef0dc4d..3c2d24c0a 100644 --- a/charts/tezos/templates/bcd_indexer.yaml +++ b/charts/tezos/templates/bcd_indexer.yaml @@ -29,7 +29,7 @@ metadata: data: BCD_ENV: sandbox GIN_MODE: debug - SANDBOX_NODE_URI: {{ $indexerConfig.indexerRpcUrl }} + SANDBOX_NODE_URI: {{ $indexerConfig.rpcUrl }} --- apiVersion: v1 @@ -176,8 +176,8 @@ spec: mountPath: /app/indexer/sandbox.yml subPath: sandbox.yml {{- if $indexerConfig.gui.enabled }} - {{- $_ := required "gui.apiUrl is required" $indexerConfig.gui.apiUrl }} - {{- $_ := required "gui.rpcUrl is required" $indexerConfig.gui.rpcUrl }} + {{- $_ := required "apiUrl is required for gui" $indexerConfig.apiUrl }} + {{- $_ := required "gui.rpcUrl is required for gui" $indexerConfig.gui.rpcUrl }} - image: {{ $indexerConfig.images.gui }} name: gui ports: @@ -189,7 +189,7 @@ spec: - | set -ex - api_url="{{ $indexerConfig.gui.apiUrl }}/v1" + api_url="{{ $indexerConfig.apiUrl }}/v1" for file in js/*; do echo $file @@ -223,4 +223,57 @@ spec: storage: {{ $indexerConfig.storage | default "300Gi" }} {{- end }} +--- +{{- if $indexerConfig.ingress.enabled }} +{{- $_ := required "apiUrl is required for ingress" $indexerConfig.apiUrl }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: bcd + namespace: {{ .Release.Namespace }} +{{- with $indexerConfig.ingress.labels }} + labels: + {{- toYaml . | nindent 4 }} +{{- end }} +{{- with $indexerConfig.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + ingressClassName: {{ $indexerConfig.ingress.className }} + {{- if $indexerConfig.ingress.tls }} + tls: + {{- range $indexerConfig.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - host: {{ regexReplaceAll "(https?://)" $indexerConfig.apiUrl "" }} + http: + paths: + - pathType: {{ $indexerConfig.ingress.pathType }} + path: / + backend: + service: + name: bcd + port: + number: 14000 + {{- if and $indexerConfig.gui.enabled $indexerConfig.ingress.guiHostname }} + - host: {{ $indexerConfig.ingress.guiHostname }} + http: + paths: + - pathType: {{ $indexerConfig.ingress.pathType }} + path: / + backend: + service: + name: bcd + port: + number: 8080 + {{- end }} +{{- end }} + {{- end }} diff --git a/charts/tezos/templates/ingress.yaml b/charts/tezos/templates/ingress.yaml new file mode 100644 index 000000000..108a75a0e --- /dev/null +++ b/charts/tezos/templates/ingress.yaml @@ -0,0 +1,39 @@ +{{- if .Values.ingress.enabled }} +{{- $_ := required "host is required for tezos-node-rpc ingress" .Values.ingress.host }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: tezos-node-rpc + namespace: {{ .Release.Namespace }} +{{- with .Values.ingress.labels }} + labels: + {{- toYaml . | nindent 4 }} +{{- end }} +{{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} +{{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - pathType: {{ .Values.ingress.pathType }} + path: / + backend: + service: + name: tezos-node-rpc + port: + number: 8732 +{{- end }} diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index 4ce14acf5..ca5bf4baf 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -269,6 +269,16 @@ services: selector: # rpc_node: "true" +## Configuration for the tezos-node-rpc ingress +ingress: + enabled: false + host: "" + annotations: {} + className: "" + labels: {} + pathType: Prefix + tls: [] + # Prometheus Operator is required in your cluster in order to enable # serviceMonitor below. # ServiceMonitor allows you to scrape the prometheus endpoints of your tezos nodes. @@ -549,15 +559,28 @@ bcdIndexer: gui: ghcr.io/baking-bad/bcdhub-gui:4.4.0 postgres: postgres:14 + # Url of the RPC backend for the indexer to index + rpcUrl: "" # http://archive-baking-node-0.archive-baking-node:8732 + # When creating an ingress, this will be the BCD api's hostname/FQDN (stripped + # of http(s)). When deploying the BCD gui, this will also be the api's full + # url called by the frontend. + apiUrl: "" # http://localhost:14000 + gui: enabled: false - ## Url of the BCD api for the frontend to hit - apiUrl: http://localhost:14000 - ## Url to the RPC backend for the frontend to hit + # Url of the RPC backend for the frontend to query rpcUrl: http://localhost:8732 - ## RPC url of the node to be indexed - # indexerRpcUrl: http://archive-baking-node-0.archive-baking-node:8732 + ingress: + enabled: false + # Hostname for BCD frontend. The ingress rule will only be created when this + # is set and gui is enabled. + guiHostname: "" + annotations: {} + className: "" + labels: {} + pathType: Prefix + tls: [] db: # By default creates a postgres db container. Setting to true won't create