Browse Source

Merge pull request #1 from tendermint/master

Merging from tendermint/tools
pull/1943/head
Greg Szabo 8 years ago
committed by GitHub
parent
commit
9577fb0ca4
8 changed files with 75 additions and 360 deletions
  1. +4
    -4
      mintnet-kubernetes/app.template.yaml
  2. +2
    -2
      mintnet-kubernetes/examples/basecoin/README.md
  3. +58
    -44
      mintnet-kubernetes/examples/basecoin/app.yaml
  4. +2
    -0
      mintnet-kubernetes/examples/basecoin/lightclient.md
  5. +5
    -8
      mintnet-kubernetes/examples/counter/app.yaml
  6. +4
    -4
      mintnet-kubernetes/examples/dummy/app.yaml
  7. +0
    -10
      mintnet-kubernetes/examples/localchain/Makefile
  8. +0
    -288
      mintnet-kubernetes/examples/localchain/app.yaml

+ 4
- 4
mintnet-kubernetes/app.template.yaml View File

@ -64,7 +64,7 @@ spec:
annotations:
pod.beta.kubernetes.io/init-containers: '[{
"name": "tm-gen-validator",
"image": "tendermint/tendermint:0.9.0",
"image": "tendermint/tendermint:0.10.0",
"imagePullPolicy": "IfNotPresent",
"command": ["bash", "-c", "
set -ex\n
@ -82,7 +82,7 @@ spec:
containers:
- name: tm
imagePullPolicy: IfNotPresent
image: tendermint/tendermint:0.9.0
image: tendermint/tendermint:0.10.0
resources:
requests:
cpu: 50m
@ -111,7 +111,7 @@ spec:
configMapKeyRef:
name: tm-config
key: validators
- name: TMROOT
- name: TMHOME
value: /tendermint
command:
- bash
@ -152,7 +152,7 @@ spec:
done
seeds=$(IFS=','; echo "${seeds[*]}")
tendermint node --seeds="$seeds" --moniker="`hostname`" --proxy_app="unix:///socks/app.sock"
tendermint node --p2p.seeds="$seeds" --moniker="`hostname`" --proxy_app="unix:///socks/app.sock"
volumeMounts:
- name: tmdir
mountPath: /tendermint


+ 2
- 2
mintnet-kubernetes/examples/basecoin/README.md View File

@ -25,13 +25,13 @@ make create
3. get account's address of the second pod
```
ADDR=`kubectl exec -c app tm-1 -- cat /app/key.json | grep "address" | tr -d "\""`
ADDR=`kubectl exec -c app tm-1 -- cat /app/key.json | jq ".address" | tr -d "\""`
```
4. send 5 coins to it from the first pod
```
kubectl exec -c app tm-0 -- basecoin tx send --to "0x$ADDR" --amount 5
kubectl exec -c app tm-0 -- basecoin tx send --to "0x$ADDR" --amount 5mycoin --from /app/key.json --chain_id chain-tTH4mi
```


+ 58
- 44
mintnet-kubernetes/examples/basecoin/app.yaml View File

@ -46,38 +46,49 @@ metadata:
name: app-config
data:
genesis.json: |-
[
"base/chainID",
"test_chain_id",
"base/account",
{
"coins" : [
{"denom": "blank", "amount": 1000}
],
"pub_key" : ["tm-0"]
},
"base/account",
{
"coins" : [
{"denom": "blank", "amount": 1000}
],
"pub_key" : ["tm-1"]
},
"base/account",
{
"coins" : [
{"denom": "blank", "amount": 1000}
],
"pub_key" : ["tm-2"]
},
"base/account",
{
"coins" : [
{"denom": "blank", "amount": 1000}
],
"pub_key" : ["tm-3"]
{
"chain_id": "chain-tTH4mi",
"app_options": {
"accounts": [
{
"pub_key": "tm-0",
"coins": [
{
"denom": "mycoin",
"amount": 1000000000
}
]
},
{
"pub_key": "tm-1",
"coins": [
{
"denom": "mycoin",
"amount": 1000000000
}
]
},
{
"pub_key": "tm-2",
"coins": [
{
"denom": "mycoin",
"amount": 1000000000
}
]
},
{
"pub_key": "tm-3",
"coins": [
{
"denom": "mycoin",
"amount": 1000000000
}
]
}
]
}
]
}
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
@ -103,7 +114,7 @@ spec:
annotations:
pod.beta.kubernetes.io/init-containers: '[{
"name": "tm-gen-validator",
"image": "tendermint/tendermint:0.9.0",
"image": "tendermint/tendermint:0.10.0",
"imagePullPolicy": "IfNotPresent",
"command": ["bash", "-c", "
set -ex\n
@ -119,7 +130,7 @@ spec:
},
{
"name": "app-gen-key",
"image": "tendermint/basecoin:latest",
"image": "tendermint/basecoin:0.5.1",
"imagePullPolicy": "IfNotPresent",
"command": ["bash", "-c", "
set -ex\n
@ -137,7 +148,7 @@ spec:
containers:
- name: tm
imagePullPolicy: IfNotPresent
image: tendermint/tendermint:0.9.0
image: tendermint/tendermint:0.10.0
ports:
- containerPort: 46656
name: p2p
@ -159,7 +170,7 @@ spec:
configMapKeyRef:
name: tm-config
key: validators
- name: TMROOT
- name: TMHOME
value: /tendermint
command:
- bash
@ -200,7 +211,7 @@ spec:
done
seeds=$(IFS=','; echo "${seeds[*]}")
tendermint node --seeds="$seeds" --moniker="`hostname`" --proxy_app="unix:///socks/app.sock"
tendermint node --p2p.seeds="$seeds" --moniker="`hostname`" --proxy_app="unix:///socks/app.sock"
volumeMounts:
- name: tmdir
mountPath: /tendermint
@ -212,7 +223,10 @@ spec:
- name: app
imagePullPolicy: IfNotPresent
image: tendermint/basecoin:latest
image: tendermint/basecoin:0.5.1
env:
- name: BCHOME
value: /app
workingDir: /app
command:
- bash
@ -224,11 +238,11 @@ spec:
cp /etc/app/genesis.json genesis.json
fqdn_suffix=$(hostname -f | sed 's#[^.]*\.\(\)#\1#')
# for every "base/account"
i=3
length=$(cat genesis.json | jq ". | length")
i=0
length=$(cat genesis.json | jq ".app_options.accounts | length")
while [[ $i -lt $length ]]; do
# extract pod name ("tm-0")
pod=$(cat genesis.json | jq -r ".[$i].pub_key[0]")
pod=$(cat genesis.json | jq -r ".app_options.accounts[$i].pub_key")
# wait until pod starts to serve its pub_key
set +e
@ -245,16 +259,16 @@ spec:
# get its pub_key
curl -s "http://$pod.$fqdn_suffix/app_pub_key.json" | jq "." > k.json
# replace pod name with it (["tm-0"] => "[1, XXXXXXXXXXXXXXXXXXXX]")
cat genesis.json | jq ".[$i].pub_key = $(cat k.json | jq '.')" > tmpgenesis && mv tmpgenesis genesis.json
# replace pod name with it ("tm-0" => "{"type": ..., "data": ...}")
cat genesis.json | jq ".app_options.accounts[$i].pub_key = $(cat k.json | jq '.')" > tmpgenesis && mv tmpgenesis genesis.json
rm -f k.json
i=$((i+2)) # skip "base/account" field itself
i=$((i+1))
done
rm -f /socks/app.sock # remove old socket
basecoin start --address="unix:///socks/app.sock"
basecoin start --address="unix:///socks/app.sock" --without-tendermint
volumeMounts:
- name: appdir
mountPath: /app


+ 2
- 0
mintnet-kubernetes/examples/basecoin/lightclient.md View File

@ -1,3 +1,5 @@
**OUTDATED**
# Using with lightclient
We have an awesome cluster running, let's try to test this out without


+ 5
- 8
mintnet-kubernetes/examples/counter/app.yaml View File

@ -63,7 +63,7 @@ spec:
annotations:
pod.beta.kubernetes.io/init-containers: '[{
"name": "tm-gen-validator",
"image": "tendermint/tendermint:0.9.0",
"image": "tendermint/tendermint:0.10.0",
"imagePullPolicy": "IfNotPresent",
"command": ["bash", "-c", "
set -ex\n
@ -81,7 +81,7 @@ spec:
containers:
- name: tm
imagePullPolicy: IfNotPresent
image: tendermint/tendermint:0.9.0
image: tendermint/tendermint:0.10.0
ports:
- containerPort: 46656
name: p2p
@ -103,7 +103,7 @@ spec:
configMapKeyRef:
name: tm-config
key: validators
- name: TMROOT
- name: TMHOME
value: /tendermint
command:
- bash
@ -144,7 +144,7 @@ spec:
done
seeds=$(IFS=','; echo "${seeds[*]}")
tendermint node --seeds="$seeds" --moniker="`hostname`" --proxy_app="unix:///socks/app.sock"
tendermint node --p2p.seeds="$seeds" --moniker="`hostname`" --proxy_app="unix:///socks/app.sock"
volumeMounts:
- name: tmdir
mountPath: /tendermint
@ -163,10 +163,7 @@ spec:
- |
set -ex
go get -d github.com/tendermint/abci/cmd/counter
cd $GOPATH/src/github.com/tendermint/abci/
make get_deps
make install
go get github.com/tendermint/abci/cmd/counter
rm -f /socks/app.sock # remove old socket


+ 4
- 4
mintnet-kubernetes/examples/dummy/app.yaml View File

@ -63,7 +63,7 @@ spec:
annotations:
pod.beta.kubernetes.io/init-containers: '[{
"name": "tm-gen-validator",
"image": "tendermint/tendermint:0.9.0",
"image": "tendermint/tendermint:0.10.0",
"imagePullPolicy": "IfNotPresent",
"command": ["bash", "-c", "
set -ex\n
@ -81,7 +81,7 @@ spec:
containers:
- name: tm
imagePullPolicy: IfNotPresent
image: tendermint/tendermint:0.9.0
image: tendermint/tendermint:0.10.0
ports:
- containerPort: 46656
name: p2p
@ -103,7 +103,7 @@ spec:
configMapKeyRef:
name: tm-config
key: validators
- name: TMROOT
- name: TMHOME
value: /tendermint
command:
- bash
@ -144,7 +144,7 @@ spec:
done
seeds=$(IFS=','; echo "${seeds[*]}")
tendermint node --seeds="$seeds" --moniker="`hostname`" --proxy_app="dummy"
tendermint node --p2p.seeds="$seeds" --moniker="`hostname`" --proxy_app="dummy"
volumeMounts:
- name: tmdir
mountPath: /tendermint


+ 0
- 10
mintnet-kubernetes/examples/localchain/Makefile View File

@ -1,10 +0,0 @@
create:
@echo "==> Creating deployment"
@kubectl create -f app.yaml
destroy:
@echo "==> Destroying deployment"
@kubectl delete -f app.yaml
@kubectl delete pvc -l app=tm
.PHONY: create destroy

+ 0
- 288
mintnet-kubernetes/examples/localchain/app.yaml View File

@ -1,288 +0,0 @@
---
# Single pod installation (see basecoin for distributed setup)
apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
name: localchain
labels:
app: localchain
spec:
ports:
- port: 46656
name: p2p
- port: 46657
name: rpc
clusterIP: None
selector:
app: tm
---
apiVersion: v1
kind: ConfigMap
metadata:
name: tm-config
data:
validators: "tm-0"
validator.power: "10"
genesis.json: |-
{
"genesis_time": "2016-03-24T23:29:20.457Z",
"chain_id": "chain-iqwZgb",
"validators": [],
"app_hash": ""
}
pub_key_nginx.conf: |-
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
location /pub_key.json { root /usr/share/nginx/; }
location /app_pub_key.json { root /usr/share/nginx/; }
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
genesis.json: |-
[
"base/chainID",
"test_chain_id",
"base/account",
{
"pub_key": ["tm-0"],
"coins": [
{"denom":"CITI/USD","amount":1000},
{"denom":"UBS/EURO","amount":1000}
]
}
]
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: tm-budget
spec:
selector:
matchLabels:
app: tm
minAvailable: 2
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: tm
spec:
serviceName: localchain
replicas: 1
template:
metadata:
labels:
app: tm
annotations:
pod.beta.kubernetes.io/init-containers: '[{
"name": "tm-gen-validator",
"image": "tendermint/tendermint:0.9.0",
"imagePullPolicy": "IfNotPresent",
"command": ["bash", "-c", "
set -ex\n
if [ ! -f /tendermint/priv_validator.json ]; then\n
tendermint gen_validator > /tendermint/priv_validator.json\n
# pub_key.json will be served by pub-key container\n
cat /tendermint/priv_validator.json | jq \".pub_key\" > /tendermint/pub_key.json\n
fi\n
"],
"volumeMounts": [
{"name": "tmdir", "mountPath": "/tendermint"}
]
},
{
"name": "app-gen-key",
"image": "tendermint/basecoin:latest",
"imagePullPolicy": "IfNotPresent",
"command": ["bash", "-c", "
set -ex\n
if [ ! -f /app/key.json ]; then\n
basecoin key new > /app/key.json\n
# pub_key.json will be served by app-pub-key container\n
cat /app/key.json | jq \".pub_key\" > /app/pub_key.json\n
fi\n
"],
"volumeMounts": [
{"name": "appdir", "mountPath": "/app"}
]
}]'
spec:
containers:
- name: tm
imagePullPolicy: IfNotPresent
image: tendermint/tendermint:0.9.0
ports:
- containerPort: 46656
name: p2p
- containerPort: 46657
name: rpc
env:
- name: VALIDATOR_POWER
valueFrom:
configMapKeyRef:
name: tm-config
key: validator.power
- name: VALIDATORS
valueFrom:
configMapKeyRef:
name: tm-config
key: validators
- name: TMROOT
value: /tendermint
command:
- bash
- "-c"
- |
set -ex
# copy template
cp /etc/tendermint/genesis.json /tendermint/genesis.json
# fill genesis file with validators
IFS=',' read -ra VALS_ARR <<< "$VALIDATORS"
fqdn_suffix=$(hostname -f | sed 's#[^.]*\.\(\)#\1#')
for v in "${VALS_ARR[@]}"; do
# wait until validator generates priv/pub key pair
set +e
curl -s "http://$v.$fqdn_suffix/pub_key.json" > /dev/null
ERR=$?
while [ "$ERR" != 0 ]; do
sleep 5
curl -s "http://$v.$fqdn_suffix/pub_key.json" > /dev/null
ERR=$?
done
set -e
# add validator to genesis file along with its pub_key
curl -s "http://$v.$fqdn_suffix/pub_key.json" | jq ". as \$k | {pub_key: \$k, amount: $VALIDATOR_POWER, name: \"$v\"}" > pub_validator.json
cat /tendermint/genesis.json | jq ".validators |= .+ [$(cat pub_validator.json)]" > tmpgenesis && mv tmpgenesis /tendermint/genesis.json
rm pub_validator.json
done
tendermint node --moniker="`hostname`" --proxy_app="unix:///socks/app.sock"
volumeMounts:
- name: tmdir
mountPath: /tendermint
- mountPath: /etc/tendermint/genesis.json
name: tmconfigdir
subPath: genesis.json
- name: socksdir
mountPath: /socks
- name: app
imagePullPolicy: IfNotPresent
image: tendermint/basecoin:latest
workingDir: /app
command:
- bash
- "-c"
- |
set -ex
# replace "tm-N" with public keys in genesis file
cp /etc/app/genesis.json genesis.json
fqdn_suffix=$(echo $(hostname -f) | sed 's#[^.]*\.\(\)#\1#')
# for every "base/account"
i=3
length=$(cat genesis.json | jq ". | length")
while [ $i -lt $length ]; do
# extract pod name ("tm-0")
pod=$(cat genesis.json | jq -r ".[$i].pub_key[0]")
# wait until pod starts to serve its pub_key
set +e
curl -s "http://$pod.$fqdn_suffix/app_pub_key.json" > /dev/null
ERR=$?
while [ "$ERR" != 0 ]; do
sleep 5
curl -s "http://$pod.$fqdn_suffix/app_pub_key.json" > /dev/null
ERR=$?
done
set -e
# get its pub_key
curl -s "http://$pod.$fqdn_suffix/app_pub_key.json" | jq "." > k.json
# replace pod name with it (["tm-0"] => "[1, XXXXXXXXXXXXXXXXXXXX]")
cat genesis.json | jq ".[$i].pub_key = $(cat k.json | jq '.')" > genesis.json
rm -f k.json
i=$((i+2)) # skip "base/account" field itself
done
rm -f /socks/app.sock # remove old socket
basecoin start --address="unix:///socks/app.sock"
volumeMounts:
- name: appdir
mountPath: /app
- mountPath: /etc/app/genesis.json
name: appconfigdir
subPath: genesis.json
- name: socksdir
mountPath: /socks
- name: pub-key
imagePullPolicy: IfNotPresent
image: nginx:latest
ports:
- containerPort: 80
name: pub-key
command:
- bash
- "-c"
- |
set -ex
# fixes 403 Permission Denied (open() "/tendermint/pub_key.json" failed (13: Permission denied))
# => we cannot serve from /tendermint, so we copy the file
mkdir -p /usr/share/nginx
cp /tendermint/pub_key.json /usr/share/nginx/pub_key.json
cp /app/pub_key.json /usr/share/nginx/app_pub_key.json
nginx -g "daemon off;"
volumeMounts:
- name: tmdir
mountPath: /tendermint
- name: appdir
mountPath: /app
- mountPath: /etc/nginx/conf.d/pub_key.conf
name: tmconfigdir
subPath: pub_key_nginx.conf
volumes:
- name: tmconfigdir
configMap:
name: tm-config
- name: appconfigdir
configMap:
name: app-config
- name: socksdir
emptyDir: {}
volumeClaimTemplates:
- metadata:
name: tmdir
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 2Gi
- metadata:
name: appdir
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 12Mi

Loading…
Cancel
Save