add new deployment

This commit is contained in:
rhuairahrighairigh 2018-06-24 00:51:32 +01:00
parent 7eda45c6d7
commit a91f86cd72
12 changed files with 131 additions and 106 deletions

5
.gitignore vendored
View File

@ -18,6 +18,5 @@ vendor
*.sublime-project
*.sublime-workspace
# Exclude chain data
.kvd/
.kvcli/
# Exclude kubernetes secrets
deployment/secret*.yml

View File

@ -2,18 +2,18 @@ To initialise a network:
- delete everything (including persistant volume claim)
- deploy everything except the deployments
- wait until the job has finished, then deploy deployment-d
- check job pod logs for the validator account backup phrase :(
- use `kubectl exec` on the deployment-d pod and use gaiacli to recover the validator
- do the same to add other keys and move tokens around
- start up lcd pod (looks like only one instance of gaiacli can access the keys DB)
- wait until the job has finished, then deploy the deployments
Note on config
- Secrets and configmaps need to be generated from files
- Ideally everything would be in one file but kubectl doesn't scan directories yet: https://github.com/kubernetes/kubernetes/issues/62421
- `kubectl create secret generic kava-user-keys --from-file=./init/init-data --dry-run -o yaml > secret-user.yml`
- `kubectl create secret generic kava-node-config --from-file=./init/init-data/.kvd/config --dry-run -o yaml > secret-config.yml`
Examples of using light client with the node:
- Get the status `gaiacli status --node <node's-ip-address>:46657 --chain-id kava`
- Send coins `gaiacli send --name <your-key-name> --to <receiver's-address> --amount 10kavaToken --node <node's-ip-address>:46657 --chain-id kava`
- Run the rest server `gaiacli rest-server --node <node's-ip-address>:46657 --chain-id kava`
- Get the status `kvcli status --node <node's-url>:46657 --chain-id test-kava`
- Send coins `kvcli send --name <your-key-name> --to <receiver's-address> --amount 100KVA --node <node's-url>:46657 --chain-id test-kava`
- Run the light client daemon `kvcli rest-server --node <node's-url>:46657 --chain-id test-kava`
Notes
- There's two persistant volumes, for `.gaiad` and for `.gaiacli`, because their default locations are awkward.

View File

@ -1,35 +0,0 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: kava-d-deployment
labels:
app: kava
spec:
replicas: 1
selector:
matchLabels:
app: kava-d
template:
metadata:
labels:
app: kava-d
spec:
containers:
- name: gaiad
image: kava/cosmos-sdk:ilp-demo
command: ["gaiad", "start"]
ports:
- containerPort: 46656
- containerPort: 46657
volumeMounts:
- name: kava-persistent-storage-gaiad
mountPath: /root/.gaiad
- name: kava-persistent-storage-gaiacli
mountPath: /root/.gaiacli
volumes:
- name: kava-persistent-storage-gaiad
persistentVolumeClaim:
claimName: kava-pvc-gaiad
- name: kava-persistent-storage-gaiacli
persistentVolumeClaim:
claimName: kava-pvc-gaiacli

View File

@ -1,34 +0,0 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: kava-lcd-deployment
labels:
app: kava
spec:
replicas: 1
selector:
matchLabels:
app: kava-lcd
template:
metadata:
labels:
app: kava-lcd
spec:
containers:
- name: gaiacli-lcd
image: kava/cosmos-sdk:ilp-demo
command: ["gaiacli", "rest-server", "--chain-id=kava", "--node=kava-d-service:46657", "--laddr=tcp://0.0.0.0:1317"]
ports:
- containerPort: 1317
volumeMounts:
- name: kava-persistent-storage-gaiad
mountPath: /root/.gaiad
- name: kava-persistent-storage-gaiacli
mountPath: /root/.gaiacli
volumes:
- name: kava-persistent-storage-gaiad
persistentVolumeClaim:
claimName: kava-pvc-gaiad
- name: kava-persistent-storage-gaiacli
persistentVolumeClaim:
claimName: kava-pvc-gaiacli

View File

@ -0,0 +1,31 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: kava-d-deployment2
labels:
app: kava
spec:
replicas: 1
selector:
matchLabels:
pod: kvd
template:
metadata:
labels:
app: kava
pod: kvd
spec:
containers:
- name: kvd
image: kava/kava
command: ["kvd", "start"]
ports:
- containerPort: 46656
- containerPort: 46657
volumeMounts:
- name: persistent-storage-kvd
mountPath: /root/.kvd
volumes:
- name: persistent-storage-kvd
persistentVolumeClaim:
claimName: kava-pvc-kvd2

View File

@ -0,0 +1,30 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: kava-lcd-deployment2
labels:
app: kava
spec:
replicas: 1
selector:
matchLabels:
pod: kvcli-lcd
template:
metadata:
labels:
app: kava
pod: kvcli-lcd
spec:
containers:
- name: kvcli-lcd
image: kava/kava
command: ["kvcli", "rest-server", "--chain-id=test-kava", "--node=kava-d-service2:46657", "--laddr=tcp://0.0.0.0:1317"]
ports:
- containerPort: 1317
volumeMounts:
- name: persistent-storage-kvcli
mountPath: /root/.kvcli
volumes:
- name: persistent-storage-kvcli
persistentVolumeClaim:
claimName: kava-pvc-kvcli2

View File

@ -0,0 +1,5 @@
FROM kava/kava
WORKDIR /
COPY init.sh ./
# Expects init data to be mounted at /init-data
CMD ["sh", "init.sh"]

19
deployment/init/init.sh Normal file
View File

@ -0,0 +1,19 @@
# Setup node and light client.
echo "This assumes you have wiped old data"
echo "copying kvd config to the default location ($HOME/.kvd)"
initData=./init-data
cp -vR $initData/.kvd/. $HOME/.kvd/ # copy contents of .kvd into .kvd, creating dir if necessary
echo "setup validator key from seed"
validatorPassword="$(cat $initData/validatorPassword)"
echo $validatorPassword
validatorBackupPhrase="$(cat $initData/validatorBackupPhrase)"
printf "$validatorPassword\n$validatorBackupPhrase\n" | kvcli keys add --recover validator
echo "setup user1 key from seed"
user1Password="$(cat ./init-data/user1Password)"
user1BackupPhrase="$(cat ./init-data/user1BackupPhrase)"
printf "$user1Password\n$user1BackupPhrase\n" | kvcli keys add --recover user1

View File

@ -1,7 +1,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: start-new-chain-job
name: kava-init-data2
labels:
app: kava
spec:
@ -9,18 +9,28 @@ spec:
spec:
containers:
- name: run-init
image: kava/cosmos-sdk:ilp-demo
command: ["gaiad", "init", "--chain-id", "kava", "--name", "kava"]
image: kava/kava-init
volumeMounts:
- name: kava-persistent-storage-gaiad
mountPath: /root/.gaiad
- name: kava-persistent-storage-gaiacli
mountPath: /root/.gaiacli
- name: kava-persistent-storage-kvd
mountPath: /root/.kvd
- name: kava-persistent-storage-kvcli
mountPath: /root/.kvcli
- name: user-keys
mountPath: /init-data/
- name: node-config
mountPath: /init-data/.kvd/config/
restartPolicy: Never
volumes:
- name: kava-persistent-storage-gaiad
- name: kava-persistent-storage-kvd
persistentVolumeClaim:
claimName: kava-pvc-gaiad
- name: kava-persistent-storage-gaiacli
claimName: kava-pvc-kvd2
- name: kava-persistent-storage-kvcli
persistentVolumeClaim:
claimName: kava-pvc-gaiacli
claimName: kava-pvc-kvcli2
- name: user-keys
secret:
secretName: kava-user-keys
- name: node-config
secret:
secretName: kava-node-config

View File

@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: kava-d-service
name: kava-d-service2
labels:
app: kava
spec:
@ -16,12 +16,12 @@ spec:
protocol: TCP
targetPort: 46656
selector:
app: kava-d
pod: kvd
---
apiVersion: v1
kind: Service
metadata:
name: kava-lcd-service
name: kava-lcd-service2
labels:
app: kava
spec:
@ -32,4 +32,4 @@ spec:
protocol: TCP
targetPort: 1317
selector:
app: kava-lcd
pod: kvcli-lcd

View File

@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: kava-pvc-gaiad
name: kava-pvc-kvd2
labels:
app: kava
spec:
@ -14,7 +14,7 @@ spec:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: kava-pvc-gaiacli
name: kava-pvc-kvcli2
labels:
app: kava
spec:

View File

@ -6,16 +6,16 @@ services:
ports:
- 46657:46657
volumes:
- ./.kvd:/root/.kvd
- ./.kvcli:/root/.kvcli
- ~/.kvd:/root/.kvd
- ~/.kvcli:/root/.kvcli
# Avoid printing out all the tendermint logs
logging:
driver: "none"
lcd:
image: kava/kava
command: "kvcli rest-server --chain-id test-kava-1 --node kvd:46657 --laddr tcp://0.0.0.0:1317"
command: "kvcli rest-server --chain-id test-kava --node kvd:46657 --laddr tcp://0.0.0.0:1317"
ports:
- 1317:1317
volumes:
- ./.kvd:/root/.kvd
- ./.kvcli:/root/.kvcli
- ~/.kvd:/root/.kvd
- ~/.kvcli:/root/.kvcli