Skip to content

Commit

Permalink
Merge pull request #8 from paritytech/node-p2p-port
Browse files Browse the repository at this point in the history
Node port p2p services auto configuration
  • Loading branch information
PierreBesson authored Aug 27, 2021
2 parents 6aaf5ad + e2adec5 commit 2e8848a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: node
description: A Helm chart to deploy Substrate/Polkadot nodes
type: application
version: 0.7.0
version: 0.8.0
appVersion: "0.0.1"
21 changes: 19 additions & 2 deletions charts/node/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ spec:
name: p2p
---
{{range $i := until (.Values.node.replicas | int) }}
{{- if $.Values.node.perNodeServices.createClusterIPService }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -39,7 +40,23 @@ spec:
name: websocket-rpc
- port: 9615
name: prometheus
- port: 30333
name: p2p
{{- end }}
---
{{- if $.Values.node.perNodeServices.createP2pNodePortService }}
apiVersion: v1
kind: Service
metadata:
name: {{ $fullname }}-{{ $i }}-p2p
spec:
type: NodePort
selector:
{{- $selectorLabels | nindent 4 }}
statefulset.kubernetes.io/pod-name: {{ $fullname }}-{{ $i }}
ports:
- name: p2p
port: {{ add $.Values.node.perNodeServices.p2pNodePortStartRange $i }}
nodePort: {{ add $.Values.node.perNodeServices.p2pNodePortStartRange $i }}
targetPort: 30333
{{- end }}
---
{{ end }}
1 change: 1 addition & 0 deletions charts/node/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
statefulset.kubernetes.io/pod-name: {{ $fullname }}-{{ $i }}
endpoints:
- port: prometheus
path: /metrics
{{- if $.Values.node.serviceMonitor.interval }}
interval: {{ $.Values.node.serviceMonitor.interval }}
{{- end }}
Expand Down
27 changes: 20 additions & 7 deletions charts/node/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,27 @@ spec:
- name: {{ .Values.node.chain }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.node.perNodeServices.createP2pNodePortService }}
command: [ "/bin/sh" ]
args:
- -c
- >
POD_INDEX="${HOSTNAME##*-}";
P2P_PORT=$(({{ .Values.node.perNodeServices.p2pNodePortStartRange }}+POD_INDEX));
echo "P2P_PORT=${P2P_PORT}";
exec polkadot \
--name=${POD_NAME} \
--base-path=/data/ \
--chain=${CHAIN} \
--listen-addr={{ .Values.node.perNodeServices.listenAddressBase }}${P2P_PORT} \
{{- join " " .Values.node.flags | nindent 18 }}
{{- else }}
args:
- "--name"
- "$(POD_NAME)"
- "--base-path"
- "/data/"
- "--chain"
- "$(CHAIN)"
{{- toYaml .Values.node.flags | nindent 12 }}
- "--name=$(POD_NAME)"
- "--base-path=/data/"
- "--chain=$(CHAIN)"
{{- toYaml .Values.node.flags | nindent 12 }}
{{- end }}
env:
- name: CHAIN
value: {{ .Values.node.chain }}
Expand Down
6 changes: 6 additions & 0 deletions charts/node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ node:
#namespace: monitoring
#interval: 10s
# scrapeTimeout: 10s
perNodeServices:
createClusterIPService: true
createP2pNodePortService: false
p2pNodePortStartRange: "30000"
# Set to 0.0.0.0 to enable auto discovery of the IP address
listenAddressBase: "/ip4/0.0.0.0/tcp/"

substrateApiSidecar:
enabled: false
Expand Down

0 comments on commit 2e8848a

Please sign in to comment.