Skip to content

Commit

Permalink
New rpc flags backward compatibility improvement (#241)
Browse files Browse the repository at this point in the history
* add node.perNodeServices.apiService.rpcPort config value while keeping backward compatible with wsPort and httpPort for legacy flags

* remove setting of collator relay-chain rpc-port to 9945 which was a workaround for paritytech/cumulus#2529

* bump node chart patch version

* use correct 'containerPort' and omit protocol=TCP as it is the default value

* remove websocket-rpc and http-rpc port from podspec but set as targetPort in service

* set wsPort default to 9955 as it can't be set be the same as another port

* call new rpc pod portfor startup probe

* add back line that was erroneously removed

* revert to hardcoded 9933/9944 for rpc-http and rpc-websocket ports when using legacy rpc flags

* hardcode port numbers for legacy rpc flags per node services
  • Loading branch information
PierreBesson authored May 10, 2023
1 parent 6863bf8 commit 609bbf6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion charts/node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: node
description: A Helm chart to deploy Substrate/Polkadot nodes
type: application
version: 4.6.0
version: 4.6.1
maintainers:
- name: Parity
url: https://github.com/paritytech/helm-charts
7 changes: 4 additions & 3 deletions charts/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ node:
### v4.6.0 (⚠️ breaking change)

Substrate changed the default rpc flags: https://github.com/paritytech/substrate/pull/13384 \
Port `9933` was replaced by combined port `9944`
The dual RPC ports; `--rpc-port=9933` (HTTP) ,`--ws-port=9944` (WS) was replaced by a combined port `--rpc-port=9944`.
Flags replaced:
```
--rpc-max--payload (replaced by --rpc--max-request-size and --rpc-max-response-size)
Expand Down Expand Up @@ -256,8 +256,9 @@ If you're running a collator node:
| `node.perNodeServices.apiService.enabled` | If true, creates a an API Service for every node in the statefulset exposing the HTTP, WS and Prometheus endpoints | `true` |
| `node.perNodeServices.apiService.type` | Define the type of the API Services (`ClusterIP`, `NodePort` or `LoadBalancer`) | `ClusterIP` |
| `node.perNodeServices.apiService.annotations` | Annotations to be set on API Services | `{}` |
| `node.perNodeServices.apiService.httpPort` | Port to use for the API Service HTTP endpoint | `9933` |
| `node.perNodeServices.apiService.wsPort` | Port to use for the API Service WS endpoint | `9944` |
| `node.perNodeServices.apiService.rpcPort` | Port to use for the API Service RPC endpoint | `9944` |
| `node.perNodeServices.apiService.httpPort` | Port to use for the API Service HTTP endpoint (deprecated, use rpcPort) | `9933` |
| `node.perNodeServices.apiService.wsPort` | Port to use for the API Service WS endpoint (deprecated, use rpcPort) | `9944` |
| `node.perNodeServices.apiService.prometheusPort` | Port to use for the API Service Prometheus endpoint | `9615` |
| `node.perNodeServices.apiService.externalDns.enabled` | If true, adds an [external-dns](https://github.com/kubernetes-sigs/external-dns) annotation to set a DNS record directing to the API Service | `false` |
| `node.perNodeServices.apiService.externalDns.hostname` | Define the base hostname for the external-dns DNS record which will be (eg. for `hostname: example.com`, the annotation set will be `external-dns.alpha.kubernetes.io/hostname: POD_NAME.example.com`) | `example.com` |
Expand Down
26 changes: 24 additions & 2 deletions charts/node/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@ spec:
{{- if $.Values.node.legacyRpcFlags }}
- port: 9933
name: http-rpc
{{- end}}
- port: 9944
name: websocket-rpc
{{- else }}
- port: {{ $.Values.node.perNodeServices.apiService.rpcPort | int }}
name: rpc
{{- /* Legacy RPC port, to be removed in the next major chart version */}}
- port: {{ $.Values.node.perNodeServices.apiService.httpPort | int }}
name: http-rpc
targetPort: rpc
{{- /* Legacy RPC port, to be removed in the next major chart version */}}
- port: {{ $.Values.node.perNodeServices.apiService.wsPort | int }}
name: websocket-rpc
targetPort: rpc
{{- end }}
{{- if and $.Values.node.serviceMonitor.enabled (not $.Values.node.perNodeServices.apiService.enabled) }}
- port: {{ .Values.node.prometheus.port | int }}
name: prometheus
Expand Down Expand Up @@ -78,11 +89,22 @@ spec:
statefulset.kubernetes.io/pod-name: {{ $fullname }}-{{ $i }}
ports:
{{- if $.Values.node.legacyRpcFlags }}
- port: 9933
name: http-rpc
- port: 9944
name: websocket-rpc
{{- else }}
- port: {{ $.Values.node.perNodeServices.apiService.rpcPort | int }}
name: rpc
{{- /* Legacy RPC port, to be removed in the next major chart version */}}
- port: {{ $.Values.node.perNodeServices.apiService.httpPort | int }}
name: http-rpc
{{- end }}
targetPort: rpc
{{- /* Legacy RPC port, to be removed in the next major chart version */}}
- port: {{ $.Values.node.perNodeServices.apiService.wsPort | int }}
name: websocket-rpc
targetPort: rpc
{{- end }}
- port: {{ $.Values.node.perNodeServices.apiService.prometheusPort | int }}
name: prometheus
{{- if $.Values.node.collatorRelayChain.prometheus.enabled }}
Expand Down
18 changes: 7 additions & 11 deletions charts/node/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ spec:
{{- if .Values.node.legacyRpcFlags }}
--unsafe-ws-external \
{{- else }}
--rpc-port=9944 \
--rpc-port={{ .Values.node.perNodeServices.apiService.rpcPort | int }} \
{{- end }}
{{- /*
CORS must be set to 'all' to allow RPC requests including Kubernetes heathchecks.
Expand Down Expand Up @@ -610,9 +610,6 @@ spec:
--name=${POD_NAME} \
--base-path=/relaychain-data \
--keystore-path=/relaychain-keystore \
{{- if not .Values.node.legacyRpcFlags }}
--rpc-port=9945 \
{{- end }}
{{- if .Values.node.collatorRelayChain.chainData.database }}
--database={{ .Values.node.collatorRelayChain.chainData.database }} \
{{- end }}
Expand Down Expand Up @@ -668,21 +665,20 @@ spec:
{{- if .Values.node.legacyRpcFlags }}
- containerPort: 9933
name: http-rpc
protocol: TCP
{{- end }}
- containerPort: 9944
name: websocket-rpc
protocol: TCP
{{- else }}
- containerPort: {{ $.Values.node.perNodeServices.apiService.rpcPort | int }}
name: rpc
{{- end }}
- containerPort: {{ .Values.node.prometheus.port }}
name: prometheus
protocol: TCP
{{- if and .Values.node.isParachain .Values.node.collatorRelayChain.prometheus.enabled }}
- containerPort: {{ .Values.node.collatorRelayChain.prometheus.port }}
name: prom-relaychain
{{- end }}
- containerPort: 30333
name: p2p
protocol: TCP
{{- if .Values.node.enableStartupProbe }}
# On startup, retry the connection to the /health endpoint every 10s for 5 min before killing the container
startupProbe:
Expand All @@ -693,7 +689,7 @@ spec:
{{- if .Values.node.legacyRpcFlags }}
port: http-rpc
{{- else }}
port: websocket-rpc
port: rpc
{{- end }}
{{- end }}
resources:
Expand Down Expand Up @@ -783,7 +779,7 @@ spec:
image: {{ .Values.wsHealthExporter.image.repository }}:{{ .Values.wsHealthExporter.image.tag }}
env:
- name: NODE_URL
value: ws://127.0.0.1:9944
value: ws://127.0.0.1:{{ .Values.node.perNodeServices.apiService.rpcPort | int }}
resources:
{{- toYaml .Values.wsHealthExporter.resources | nindent 12 }}
{{- if .Values.node.enableSidecarReadinessProbe }}
Expand Down
5 changes: 4 additions & 1 deletion charts/node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,11 @@ node:
externalTrafficPolicy: Cluster
type: ClusterIP # or NodePort, LoadBalancer
annotations: {}
rpcPort: 9944
# deprecated, use rpcPort
httpPort: 9933
wsPort: 9944
# deprecated, use rpcPort
wsPort: 9955
prometheusPort: 9615
relayChainPrometheusPort: 9625
externalDns:
Expand Down

0 comments on commit 609bbf6

Please sign in to comment.