Skip to content

Commit

Permalink
Add Node RPC and BCD ingresses (#583)
Browse files Browse the repository at this point in the history
* Add bcd ingress

* Rename bcd indexerRpcUrl field to rpcUrl + add pathType

* Add rpc ingress
  • Loading branch information
harryttd authored May 4, 2023
1 parent 6158f2e commit a0ecfdb
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/tezos/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
{{- "" }}
Expand Down
61 changes: 57 additions & 4 deletions charts/tezos/templates/bcd_indexer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ metadata:
data:
BCD_ENV: sandbox
GIN_MODE: debug
SANDBOX_NODE_URI: {{ $indexerConfig.indexerRpcUrl }}
SANDBOX_NODE_URI: {{ $indexerConfig.rpcUrl }}

---
apiVersion: v1
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
39 changes: 39 additions & 0 deletions charts/tezos/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
33 changes: 28 additions & 5 deletions charts/tezos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a0ecfdb

Please sign in to comment.