From a91f86cd72117812b9c4353a00776ce5f1609b64 Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Sun, 24 Jun 2018 00:51:32 +0100 Subject: [PATCH] add new deployment --- .gitignore | 5 ++-- deployment/README.md | 24 ++++++++-------- deployment/deployment-d.yml | 35 ----------------------- deployment/deployment-lcd.yml | 34 ---------------------- deployment/deployments/deployment-d.yml | 31 ++++++++++++++++++++ deployment/deployments/deployment-lcd.yml | 30 +++++++++++++++++++ deployment/init/Dockerfile | 5 ++++ deployment/init/init.sh | 19 ++++++++++++ deployment/job.yml | 32 ++++++++++++++------- deployment/service.yml | 8 +++--- deployment/volume.yml | 4 +-- docker-compose.yml | 10 +++---- 12 files changed, 131 insertions(+), 106 deletions(-) delete mode 100644 deployment/deployment-d.yml delete mode 100644 deployment/deployment-lcd.yml create mode 100644 deployment/deployments/deployment-d.yml create mode 100644 deployment/deployments/deployment-lcd.yml create mode 100644 deployment/init/Dockerfile create mode 100644 deployment/init/init.sh diff --git a/.gitignore b/.gitignore index 41238d6f..f2fae544 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,5 @@ vendor *.sublime-project *.sublime-workspace -# Exclude chain data -.kvd/ -.kvcli/ +# Exclude kubernetes secrets +deployment/secret*.yml diff --git a/deployment/README.md b/deployment/README.md index 09cd33fc..7060aa75 100644 --- a/deployment/README.md +++ b/deployment/README.md @@ -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 :46657 --chain-id kava` - - Send coins `gaiacli send --name --to --amount 10kavaToken --node :46657 --chain-id kava` - - Run the rest server `gaiacli rest-server --node :46657 --chain-id kava` - -Notes - - - There's two persistant volumes, for `.gaiad` and for `.gaiacli`, because their default locations are awkward. \ No newline at end of file + - Get the status `kvcli status --node :46657 --chain-id test-kava` + - Send coins `kvcli send --name --to --amount 100KVA --node :46657 --chain-id test-kava` + - Run the light client daemon `kvcli rest-server --node :46657 --chain-id test-kava` + \ No newline at end of file diff --git a/deployment/deployment-d.yml b/deployment/deployment-d.yml deleted file mode 100644 index c5d28a72..00000000 --- a/deployment/deployment-d.yml +++ /dev/null @@ -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 diff --git a/deployment/deployment-lcd.yml b/deployment/deployment-lcd.yml deleted file mode 100644 index 91d2e073..00000000 --- a/deployment/deployment-lcd.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/deployment/deployments/deployment-d.yml b/deployment/deployments/deployment-d.yml new file mode 100644 index 00000000..500d2866 --- /dev/null +++ b/deployment/deployments/deployment-d.yml @@ -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 diff --git a/deployment/deployments/deployment-lcd.yml b/deployment/deployments/deployment-lcd.yml new file mode 100644 index 00000000..8ed5d36f --- /dev/null +++ b/deployment/deployments/deployment-lcd.yml @@ -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 \ No newline at end of file diff --git a/deployment/init/Dockerfile b/deployment/init/Dockerfile new file mode 100644 index 00000000..a1ec8fd3 --- /dev/null +++ b/deployment/init/Dockerfile @@ -0,0 +1,5 @@ +FROM kava/kava +WORKDIR / +COPY init.sh ./ +# Expects init data to be mounted at /init-data +CMD ["sh", "init.sh"] diff --git a/deployment/init/init.sh b/deployment/init/init.sh new file mode 100644 index 00000000..de41a45a --- /dev/null +++ b/deployment/init/init.sh @@ -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 diff --git a/deployment/job.yml b/deployment/job.yml index 3326a142..caaa7f20 100644 --- a/deployment/job.yml +++ b/deployment/job.yml @@ -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 + diff --git a/deployment/service.yml b/deployment/service.yml index 35229e47..b345c28c 100644 --- a/deployment/service.yml +++ b/deployment/service.yml @@ -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 diff --git a/deployment/volume.yml b/deployment/volume.yml index a1daa145..de0c970c 100644 --- a/deployment/volume.yml +++ b/deployment/volume.yml @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index ae4f1b3b..a0979c1f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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