Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Add support geth websockets rcp. (#28)
Browse files Browse the repository at this point in the history
Add support for connecting to geth via websockets rpc. The default port is set to `8546` and will always be set, but in order to use websockets they need to be enabled in the `geth.Geth_Startup_Param` inside the config yaml, e.g. --ws --wsorigins=\"*\" --wsaddr 0.0.0.0 see examples/config/qubernetes-ingress-ws.yaml

To override the default set it in the config under `geth.Node_WSPort`.

note:
If trying to connect externally via an ingress be aware that depending on the backend k8s service and how the load balancing is implemented the health checks may fail, e.g. for GKE currently has a health check that uses http, and setting a configurable health check in k8s is not supported yet,
but will be available soon: kubernetes/ingress-gce#1067.

* Change RPCPort 7nodes from 8546->8545.

change the 7nodes examples configs RPCPort to the default geth rpc port
so that it doesn't clash with the default websocket port (8546).
  • Loading branch information
libby committed May 1, 2020
1 parent 85be53f commit 869a992
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ quorum:
Capacity: 200Mi
# generic geth related options
geth:
Node_RPCPort: 8546
Node_RPCPort: 8545
NodeP2P_ListenAddr: 21000
network:
# network id (1: mainnet, 3: ropsten, 4: rinkeby ... )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ quorum:
Capacity: 200Mi
# generic geth related options
geth:
Node_RPCPort: 8546
Node_RPCPort: 8545
NodeP2P_ListenAddr: 21000
network:
# network id (1: mainnet, 3: ropsten, 4: rinkeby ... )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ quorum:
Capacity: 200Mi
# generic geth related options
geth:
Node_RPCPort: 8546
Node_RPCPort: 8545
NodeP2P_ListenAddr: 21000
network:
# network id (1: mainnet, 3: ropsten, 4: rinkeby ... )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ quorum:
Capacity: 200Mi
# generic geth related options
geth:
Node_RPCPort: 8546
Node_RPCPort: 8545
NodeP2P_ListenAddr: 21000
network:
# network id (1: mainnet, 3: ropsten, 4: rinkeby ... )
Expand Down
41 changes: 41 additions & 0 deletions examples/config/qubernetes-ingress-ws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#namespace:
# name: quorum-test
# number of nodes to deploy
sep_deployment_files: true
nodes:
number: 4
service:
# NodePort | ClusterIP | LoadBalancer
type: NodePort
Ingress:
# OneToMany | OneToOne
Strategy: OneToMany
Host: "quorum.testnet.com"
quorum:
# supported: (raft | istanbul)
consensus: istanbul
# related to quorum containers
quorum:
# container images at https://hub.docker.com/u/quorumengineering/
Quorum_Version: 2.2.5
# related to transaction manager containers
tm:
# container images at https://hub.docker.com/u/quorumengineering/
# (tessera|constellation)
Name: tessera
Tm_Version: 0.11
# persistent storage is handled by Persistent Volume Claims (PVC) https://kubernetes.io/docs/concepts/storage/persistent-volumes/
# test locally and on GCP
# The data dir is persisted here
storage:
# PVC (Persistent_Volume_Claim - tested with GCP).
Type: PVC
## when redeploying cannot be less than previous values
Capacity: 200Mi
# generic geth related options
geth:
Node_WSPort: 8546
# general verbosity of geth [1..5]
verbosity: 9
# additional startup params to pass into geth/quorum
Geth_Startup_Params: --rpccorsdomain=\"*\" --rpcvhosts=\"*\" --ws --wsorigins=\"*\" --wsaddr 0.0.0.0
5 changes: 5 additions & 0 deletions qubernetes
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ if @config["geth"] and @config["geth"]["Node_RPCPort"]
@Node_RPCPort = @config["geth"]["Node_RPCPort"]
end

@Node_WSPort = 8546
if @config["geth"] and @config["geth"]["Node_WSPort"]
@Node_WSPort = @config["geth"]["Node_WSPort"]
end

@NodeP2P_ListenAddr = 30303
if @config["geth"] and @config["geth"]["NodeP2P_ListenAddr"]
@NodeP2P_ListenAdd = @config["geth"]["NodeP2P_ListenAddr"]
Expand Down
3 changes: 3 additions & 0 deletions templates/k8s/network-policy.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
- port: <%= @TM_Port %>
- port: 9080
- port: <%= @Raft_Port %>
- port: <%= @Node_WSPort %>
- port: <%= @Node_RPCPort %>
- port: <%= @NodeP2P_ListenAddr %>
egress:
Expand All @@ -31,6 +32,7 @@ spec:
- port: 9080
- port: <%= @Raft_Port %>
- port: <%= @Node_RPCPort %>
- port: <%= @Node_WSPort %>
- port: <%= @NodeP2P_ListenAddr %>

---
Expand All @@ -55,3 +57,4 @@ spec:
- port: <%= @TM_Port %>
- port: 9080
- port: <%= @Node_RPCPort %>
- port: <%= @Node_WSPort %>
13 changes: 9 additions & 4 deletions templates/k8s/quorum-deployment.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,13 @@ spec:

touch $QUORUM_DATA_DIR/password.txt;
NETWORK_ID=<%= @Geth_Network_Id %>
RPC_APIS=admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum
<%- if @config["quorum"]["consensus"] == "raft" -%>
args=\" --gcmode archive --raft --raftport <%= @Raft_Port %> --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,raft \";
args=\" --gcmode archive --raft --raftport <%= @Raft_Port %> \";
RPC_APIS=\"$RPC_APIS,raft\";
<%- elsif @config["quorum"]["consensus"] == "istanbul" -%>
args=\" --gcmode archive --istanbul.blockperiod 3 --syncmode full --mine --minerthreads 1 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul \";
<%- else -%>
args=\"--rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum \";
args=\" --gcmode archive --istanbul.blockperiod 3 --syncmode full --mine --minerthreads 1 \";
RPC_APIS=\"$RPC_APIS,istanbul\";
<%- end -%>
/usr/local/bin/geth \
--datadir $QUORUM_DATA_DIR \
Expand All @@ -251,12 +252,16 @@ spec:
--rpc \
--rpcaddr 0.0.0.0 \
--rpcport <%= @Node_RPCPort %> \
--rpcapi $RPC_APIS \
--wsapi $RPC_APIS \
--wsport <%= @Node_WSPort %> \
--port <%= @NodeP2P_ListenAddr %> \
<%= @Geth_Startup_Params %> \
--password $QUORUM_DATA_DIR/password.txt 2>&1 | tee -a <%= @Node_DataDir%>/logs/quorum.log;"
ports:
- containerPort: <%= @Raft_Port %>
- containerPort: <%= @Node_RPCPort %>
- containerPort: <%= @Node_WSPort %>
- containerPort: <%= @NodeP2P_ListenAddr %>
env:
- name: PRIVATE_CONFIG
Expand Down
12 changes: 12 additions & 0 deletions templates/k8s/quorum-ingress.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ spec:
backend:
serviceName: <%= @Node_UserIdent %>
servicePort: <%= @Node_RPCPort %>
- path: /quorum-ws
backend:
serviceName: <%= @Node_UserIdent %>
servicePort: <%= @Node_WSPort %>
tls:
- hosts:
- "<%= @Node_UserIdent %>.<%= @Ingress_Host %>"
Expand All @@ -46,6 +50,10 @@ spec:
backend:
serviceName: <%= @Node_UserIdent %>
servicePort: <%= @Node_RPCPort %>
- path: /quorum-ws
backend:
serviceName: <%= @Node_UserIdent %>
servicePort: <%= @Node_WSPort %>
<%- end -%> <%# End Host conditional %>
<% end -%> <%# end this node iteration %>
<%- end -%> <%# End Ingress OneForEach (this node's ingress) %>
Expand Down Expand Up @@ -76,6 +84,10 @@ spec:
backend:
serviceName: <%= @Node_UserIdent %>
servicePort: <%= @Node_RPCPort %>
- path: /<%= @Node_UserIdent %>/quorum-ws
backend:
serviceName: <%= @Node_UserIdent %>
servicePort: <%= @Node_WSPort %>
<%- end -%> <%# end setting path for each node %>
<%- if @Ingress_Host -%>
tls:
Expand Down
4 changes: 4 additions & 0 deletions templates/k8s/quorum-services.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ spec:
protocol: TCP
port: <%= @Node_RPCPort %>
targetPort: <%= @Node_RPCPort %>
- name: wsport
protocol: TCP
port: <%= @Node_WSPort %>
targetPort: <%= @Node_WSPort %>
- name: quorum-listener
protocol: TCP
port: <%= @NodeP2P_ListenAddr %>
Expand Down

0 comments on commit 869a992

Please sign in to comment.