Skip to content

Commit

Permalink
feat: support grpc ingress for sequencer (#923)
Browse files Browse the repository at this point in the history
## Summary
Updates sequencer chart to support grpc ingress.

## Background
We need grpc access to run local rollups against dusk-4, this enables
that ingress.

## Changes
- List changes which were made.

## Testing
Tested using buf curl locally and against preview environment:

```sh
> buf curl --schema buf.build/astria/astria --protocol grpc --insecure -d '{"height": 10}' \                                                                      
         https://grpc.pr-923.dev.astria.org/astria.sequencer.v1.SequencerService/GetSequencerBlock

{
  "header": {
    "cometbftHeader": {
      "version": {
        "block": "11"
      },
      "chainId": "sequencer-test-chain",
      "height": "10",
      "time": "2024-04-04T20:56:39.139623869Z",
      "lastBlockId": {
        "hash": "kZC9YtY/2yMzgFywTwuTzrqx4V14r1e4/Ue8CvMWhYc=",
        "partSetHeader": {
          "total": 1,
          "hash": "glbsPoEpcBgIWAoE8U8UdrpnzkVu517H8A+lqRmCgqg="
        }
      },
      "lastCommitHash": "T/MtZlCt1Pig87rguqA3xWLeyT8wXF9sMozwbjpKG4E=",
      "dataHash": "7P54CyIFJkHEJOCs+wvzRlhEqN7zh03qLi3wIKP1T3g=",
      "validatorsHash": "qrGhJDUB9nA/QGo+DsiLtow2k95obUAsKTCTeF+X/W8=",
      "nextValidatorsHash": "qrGhJDUB9nA/QGo+DsiLtow2k95obUAsKTCTeF+X/W8=",
      "consensusHash": "BICRvH3cKD93v7+R1zxE2ljD34qcvIZ0Bdi389qtoi8=",
      "appHash": "AnN3gdlx+rsrV4KipXVx0pL4rw8+cdS5UlGNXIrdaOo=",
      "lastResultsHash": "/kPWavpKmlxPnJ2on0/7UmNcjzQuf/tzHWjjbFmCByo=",
      "evidenceHash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
      "proposerAddress": "CR5HdhxYxHRTT01BSvEEpsr5DCI="
    },
    "rollupTransactionsRoot": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
    "rollupIdsRoot": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="
  },
  "rollupTransactionsProof": {
    "auditPath": "JsGJBReVHuey7Fl7QecbOc3c7YsgK9YBpLs4BaQ07HA=",
    "treeSize": "3"
  },
  "rollupIdsProof": {
    "auditPath": "JsGJBReVHuey7Fl7QecbOc3c7YsgK9YBpLs4BaQ07HA=",
    "leafIndex": "1",
    "treeSize": "3"
  }
}
```
  • Loading branch information
joroshiba authored Apr 4, 2024
1 parent f9b3bb4 commit 9682b0c
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/sequencer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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.11.1
version: 0.11.2

# 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
Expand Down
90 changes: 83 additions & 7 deletions charts/sequencer/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{- $ingressSupportsIngressClassName := eq (include "sequencer.ingress.supportsIngressClassName" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "sequencer.ingress.supportsPathType" .) "true" -}}

{{- range $service, $ingress := .Values.ingress }}
{{- $ingress := .Values.ingress.rpc -}}
{{- if $ingress.enabled -}}
{{- $servicePort := $ingress.service.port -}}
{{- $serviceName := $ingress.service.name -}}
Expand All @@ -12,8 +12,8 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $.Values.config.moniker }}-sequencer-{{ $service }}-ingress
namespace: {{ include "sequencer.namespace" $ }}
name: {{ .Values.config.moniker }}-sequencer-rpc-ingress
namespace: {{ include "sequencer.namespace" . }}
labels:
{{- with $ingress.labels }}
{{- toYaml . | nindent 4 }}
Expand Down Expand Up @@ -65,17 +65,93 @@ spec:
{{- tpl (toYaml .) $ | nindent 4 }}
{{- end }}
{{- else if $ingress.hostname }}
- host: {{ $service }}.{{ $ingress.hostname }}
- host: rpc.{{ $ingress.hostname }}
http:
paths:
- path: "/"
pathType: Prefix
backend:
service:
name: {{ $.Values.config.moniker }}-sequencer-{{ $service }}-service
name: {{ $.Values.config.moniker }}-sequencer-rpc-service
port:
name: cometbft-{{ $service }}
{{- end -}}
name: cometbft-rpc
{{- end }}
---
{{- end }}
{{- $ingress := .Values.ingress.grpc }}
{{- if $ingress.enabled -}}
{{- $servicePort := $ingress.service.port -}}
{{- $serviceName := $ingress.service.name -}}
{{- $ingressPath := $ingress.path -}}
{{- $ingressPathType := $ingress.pathType -}}
{{- $extraPaths := $ingress.extraPaths -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Values.config.moniker }}-sequencer-grpc-ingress
namespace: {{ include "sequencer.namespace" . }}
labels:
{{- with $ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
{{- if $ingress.annotations }}
{{- with $ingress.annotations }}
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
{{- else }}
kubernetes.io/ingress.class: nginx
{{- end }}
spec:
{{- if and $ingressSupportsIngressClassName $ingress.ingressClassName }}
ingressClassName: {{ $ingress.ingressClassName }}
{{- end -}}
{{- with $ingress.defaultBackend }}
defaultBackend:
{{- tpl (toYaml .) $ | nindent 4 }}
{{- end }}
rules:
{{- if $ingress.hosts }}
{{- range $ingress.hosts }}
- host: {{ tpl . $ }}
http:
paths:
{{- with $extraPaths }}
{{- toYaml . | nindent 10 }}
{{- end }}
- path: {{ $ingressPath }}
{{- if $ingressSupportsPathType }}
pathType: {{ $ingressPathType }}
{{- end }}
backend:
{{- if $ingressApiIsStable }}
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end }}
{{- with $ingress.tls }}
tls:
{{- tpl (toYaml .) $ | nindent 4 }}
{{- end }}
{{- else if $ingress.hostname }}
- host: grpc.{{ $ingress.hostname }}
http:
paths:
- path: "/"
pathType: Prefix
backend:
service:
name: {{ .Values.config.moniker }}-sequencer-grpc-service
port:
name: sequencer-grpc
{{- end }}
---
{{- end }}
2 changes: 1 addition & 1 deletion charts/sequencer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ ingress:
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
p2p:
grpc:
enabled: false
hostname: sequencer.localdev.me
ingressClassName: nginx
Expand Down
4 changes: 3 additions & 1 deletion dev/values/validators/node0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ config:
pubKey: 4v1RdMiKkWgBBTTP26iRSLOEkAY99gMVfZijm6OCzjs=

ingress:
p2p:
rpc:
enabled: true
grpc:
enabled: true

sequencer-relayer:
Expand Down
2 changes: 2 additions & 0 deletions dev/values/validators/node1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ config:
ingress:
rpc:
enabled: false
grpc:
enabled: false
2 changes: 2 additions & 0 deletions dev/values/validators/node2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ config:
ingress:
rpc:
enabled: false
grpc:
enabled: false
6 changes: 6 additions & 0 deletions dev/values/validators/single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ sequencer-relayer:
sequencerGrpc: http://node0-sequencer-grpc-service.astria-dev-cluster.svc.cluster.local:8080
storage:
enabled: false

ingress:
rpc:
enabled: true
grpc:
enabled: true

0 comments on commit 9682b0c

Please sign in to comment.