Created
June 3, 2019 17:51
-
-
Save ninjaahhh/843a3ca333ca14705ef30914f5e37044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# exposed load balancer | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: qkc-cluster-exposed | |
spec: | |
type: LoadBalancer | |
externalTrafficPolicy: Local | |
selector: | |
statefulset.kubernetes.io/pod-name: qkc-cluster-0 | |
ports: | |
- port: 38291 | |
name: p2p-udp | |
protocol: UDP | |
- port: 38291 | |
name: p2p | |
- port: 38391 | |
name: jrpc-public | |
- port: 38491 | |
name: jrpc-private | |
--- | |
# headless service for dns lookup | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: qkc-cluster | |
spec: | |
clusterIP: None | |
selector: | |
app: qkc-cluster | |
--- | |
# stateful set for 3-node cluster config | |
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: qkc-cluster | |
spec: | |
replicas: 3 | |
podManagementPolicy: Parallel | |
selector: | |
matchLabels: | |
app: qkc-cluster | |
serviceName: qkc-cluster | |
template: | |
metadata: | |
labels: | |
app: qkc-cluster | |
spec: | |
containers: | |
- name: qkc-cluster | |
image: quarkchaindocker/pyquarkchain:mainnet1.0.1 | |
command: | |
- bash | |
- "-c" | |
- | | |
set -ex | |
export QKC_CONFIG="/code/pyquarkchain/mainnet/singularity/cluster_config_template.json" | |
python quarkchain/tools/miner_address.py 100000000000000000000000000000000000000000000000 | |
python3 quarkchain/tools/config_slave.py \ | |
qkc-cluster-1.qkc-cluster.default.svc.cluster.local 38000 38001 \ | |
qkc-cluster-2.qkc-cluster.default.svc.cluster.local 38000 38001 | |
# server ID, ordinal 0 is master and others will run slave servers | |
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1 | |
ordinal=${BASH_REMATCH[1]} | |
if [[ $ordinal -eq 0 ]]; then | |
python3 quarkchain/cluster/master.py --cluster_config ${QKC_CONFIG} | |
else | |
slave=$(( ($ordinal - 1) * 2 )) | |
python3 quarkchain/cluster/slave.py --cluster_config ${QKC_CONFIG} --node_id=S$(( slave )) & | |
python3 quarkchain/cluster/slave.py --cluster_config ${QKC_CONFIG} --node_id=S$(( slave + 1 )) & | |
wait | |
fi | |
ports: | |
- containerPort: 38291 | |
name: p2p-udp | |
protocol: UDP | |
- containerPort: 38291 | |
name: p2p | |
- containerPort: 38391 | |
name: jrpc-public | |
- containerPort: 38491 | |
name: jrpc-private |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment