Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Ansible Rewrite #2123

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions deploy/ansible/playbooks/iroha-k8s/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# To use:
```
ansible-playbook playbooks/iroha-k8s/main.yml

```
* Tested to work on Google Kubernetes Engine


# To destroy the k8s environment created by iroha:

## If you went with the default namespace
```
kubectl delete -f path/to/iroha-k8s-peer-keys.yml \
-f path/to/iroha-k8s-services.yml \
-f path/to/iroha-k8s-configmap.yml \
-f path/to/iroha-k8s.yml
```

## If you deployed with a custom namespace
```
kubectl delete namespace <namespace>
kubectl delete service <iroha_pod_basename>
```
e.g. based on default config
```
kubectl delete namespace iroha-network
kubectl delete service iroha-peer
```

Convenient way to restart all pods in a deployment/statefulset

> *grahamdumpleton* in k8s community slack:
"Update an annotation in the pod template spec part":
```
$ kubectl patch statefulset/iroha-peer --patch \
"{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"last-restart\":\"`date +'%s'`\"}}}}}"
```
4 changes: 0 additions & 4 deletions deploy/ansible/playbooks/iroha-k8s/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
replicas: 4
iroha_port: 50051
pod_basename: iroha
service_name: iroha
5 changes: 0 additions & 5 deletions deploy/ansible/playbooks/iroha-k8s/iroha-deploy.yml

This file was deleted.

7 changes: 7 additions & 0 deletions deploy/ansible/playbooks/iroha-k8s/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: localhost
connection: local
roles:
- { role: iroha-k8s, tags: [] }

# TODO: tag each/most tasks and assign here so tasks can be selectively performed
Binary file not shown.
87 changes: 0 additions & 87 deletions deploy/ansible/playbooks/iroha-k8s/scripts/genesis-add-peers.py

This file was deleted.

29 changes: 0 additions & 29 deletions deploy/ansible/roles/iroha-k8s/README.md

This file was deleted.

28 changes: 21 additions & 7 deletions deploy/ansible/roles/iroha-k8s/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# config.sample
max_proposal_size: 3000
proposal_delay: 300
vote_delay: 5000
load_delay: 5000
# k8s-iroha.yaml
iroha_image: hyperledger/iroha:develop
iroha_block_store_path: "/tmp/block-store/"
iroha_internal_port: 10001
iroha_torii_port: 50051
iroha_pg_opt: "host=localhost port=5432 user=postgres password=mysecretpassword"
iroha_max_proposal_size: 10
iroha_proposal_delay: 5000
iroha_vote_delay: 5000
iroha_mst_enable: 'true'
iroha_mst_expiration_time: 1440 # 24 hours; default;

iroha_pod_basename: iroha-peer
iroha_governing_service_domain_name: iroha # https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id
iroha_replicas: 8 # Minimum number of peers is 6 (5f+1) for consensus to work properly.
iroha_image: hyperledger/iroha:1.0.0_rc3
postgres_image: postgres:9.5
postgres_volume_size: 1Gi
blockstore_volume_size: 1Gi
iroha_internal_port_name: internal-port
iroha_torii_port_name: torii-port
iroha_configmap_name: iroha-config

create_custom_namespace: true # TODO: not yet working; set `iroha_namespace` below, e.g `iroha_namespace: default`
iroha_namespace: iroha-peer-network # ignored when `create_custom_namespace`='false'
8 changes: 4 additions & 4 deletions deploy/ansible/roles/iroha-k8s/files/conf/config.docker
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"torii_port" : 50051,
"internal_port" : 10001,
"pg_opt" : "host=localhost port=5432 user=postgres password=mysecretpassword",
"max_proposal_size" : 3000,
"proposal_delay" : 300,
"max_proposal_size" : 10,
"proposal_delay" : 5000,
"vote_delay" : 5000,
"load_delay" : 5000,
"mst_enable" : false
"mst_enable" : true,
"mst_expiration_time" : 1440
}
2 changes: 1 addition & 1 deletion deploy/ansible/roles/iroha-k8s/files/conf/genesis.block
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"blockV1": {"payload": {"height": "1", "prevBlockHash": "0000000000000000000000000000000000000000000000000000000000000000", "transactions": [{"payload": {"reducedPayload": {"commands": [{"createRole": {"permissions": ["can_add_peer", "can_add_signatory", "can_create_account", "can_create_domain", "can_get_all_acc_ast", "can_get_all_acc_ast_txs", "can_get_all_acc_detail", "can_get_all_acc_txs", "can_get_all_accounts", "can_get_all_signatories", "can_get_all_txs", "can_get_blocks", "can_get_roles", "can_read_assets", "can_remove_signatory", "can_set_quorum"], "roleName": "admin"}}, {"createRole": {"permissions": ["can_add_signatory", "can_get_my_acc_ast", "can_get_my_acc_ast_txs", "can_get_my_acc_detail", "can_get_my_acc_txs", "can_get_my_account", "can_get_my_signatories", "can_get_my_txs", "can_grant_can_add_my_signatory", "can_grant_can_remove_my_signatory", "can_grant_can_set_my_account_detail", "can_grant_can_set_my_quorum", "can_grant_can_transfer_my_assets", "can_receive", "can_remove_signatory", "can_set_quorum", "can_transfer"], "roleName": "user"}}, {"createRole": {"permissions": ["can_add_asset_qty", "can_create_asset", "can_receive", "can_transfer"], "roleName": "money_creator"}}, {"createDomain": {"defaultRole": "user", "domainId": "test"}}, {"createAsset": {"assetName": "coin", "domainId": "test", "precision": 2}}, {"createAccount": {"accountName": "admin", "domainId": "test", "publicKey": "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910"}}, {"createAccount": {"accountName": "test", "domainId": "test", "publicKey": "716fe505f69f18511a1b083915aa9ff73ef36e6688199f3959750db38b8f4bfc"}}, {"appendRole": {"accountId": "admin@test", "roleName": "admin"}}, {"appendRole": {"accountId": "admin@test", "roleName": "money_creator"}}, {"addPeer": {"peer": {"address": "iroha-0.iroha:10001", "peerKey": "c1328b090617992581ca9bc4b2466f58634b067dd345c783e4a1ab02a691302c"}}}, {"addPeer": {"peer": {"address": "iroha-1.iroha:10001", "peerKey": "15c09a6019ace7b98c8a5606a8cbca583d6442e84b5faaf57f97245f3d575ef5"}}}, {"addPeer": {"peer": {"address": "iroha-2.iroha:10001", "peerKey": "f11f7bd883674e7745fb88b8b2ff7e917fac2ebc44f4740bd791a87113169a00"}}}, {"addPeer": {"peer": {"address": "iroha-3.iroha:10001", "peerKey": "87a97b63b30ef48736c19b5e6a50504e4eb57d582861c25f5c9e0a56a22d8dd3"}}}], "quorum": 1}}}], "txNumber": 1}}}
{"block_v1":{"payload":{"height":"1","prevBlockHash":"0000000000000000000000000000000000000000000000000000000000000000","transactions":[{"payload":{"reducedPayload":{"commands":[{"createRole":{"permissions":["can_add_peer","can_add_signatory","can_create_account","can_create_domain","can_get_all_acc_ast","can_get_all_acc_ast_txs","can_get_all_acc_detail","can_get_all_acc_txs","can_get_all_accounts","can_get_all_signatories","can_get_all_txs","can_get_blocks","can_get_roles","can_read_assets","can_remove_signatory","can_set_quorum"],"roleName":"admin"}},{"createRole":{"permissions":["can_add_signatory","can_get_my_acc_ast","can_get_my_acc_ast_txs","can_get_my_acc_detail","can_get_my_acc_txs","can_get_my_account","can_get_my_signatories","can_get_my_txs","can_grant_can_add_my_signatory","can_grant_can_remove_my_signatory","can_grant_can_set_my_account_detail","can_grant_can_set_my_quorum","can_grant_can_transfer_my_assets","can_receive","can_remove_signatory","can_set_quorum","can_transfer"],"roleName":"user"}},{"createRole":{"permissions":["can_add_asset_qty","can_create_asset","can_receive","can_transfer"],"roleName":"money_creator"}},{"createDomain":{"defaultRole":"user","domainId":"test"}},{"createAsset":{"assetName":"coin","domainId":"test","precision":2}},{"createAccount":{"accountName":"admin","domainId":"test","publicKey":"f98baa265831780855e80d0dbe271eb916a89fc7c6078ba55f3f111aec3baf40"}},{"createAccount":{"accountName":"test","domainId":"test","publicKey":"705d21dc33c06f821ae32a2c9c188481471c567028ec999f8027a2b923c6b6aa"}},{"appendRole":{"accountId":"admin@test","roleName":"admin"}},{"appendRole":{"accountId":"admin@test","roleName":"money_creator"}},{"addPeer":{"peer":{"address":"iroha-peer-0.iroha:10001","peerKey":"def1742b8293536ac0ecf3c04e4a7305963dc85e927a9742b5d915fde27e1399"}}},{"addPeer":{"peer":{"address":"iroha-peer-1.iroha:10001","peerKey":"4c84670a4c8b1a9513604986f80dab085d5373bb7bfba9d14ecc3a46fbc8797e"}}},{"addPeer":{"peer":{"address":"iroha-peer-2.iroha:10001","peerKey":"76af9fa68bb3b839f2bab63e67ac77a4f5dcc0d0842bea3787b5f9189ad1136e"}}},{"addPeer":{"peer":{"address":"iroha-peer-3.iroha:10001","peerKey":"94cf1c22325e2d6d4200ce9779833f103c3d2461b6d4684b124ad91b64b79fdb"}}},{"addPeer":{"peer":{"address":"iroha-peer-4.iroha:10001","peerKey":"43d6ae141f277e1309be0f5912a5a879c317f0d91202befd6fe872f49d51c7a2"}}},{"addPeer":{"peer":{"address":"iroha-peer-5.iroha:10001","peerKey":"0f7de3d0cd57a286160571c50ffb9c6e73f2070a58479a21751a12f0863a103e"}}},{"addPeer":{"peer":{"address":"iroha-peer-6.iroha:10001","peerKey":"bc3cec44a09c129532dcf51568fe45bb568f76af48b4cdec85e3728dd438ae93"}}}],"quorum":1}}}],"txNumber":1}}}
1 change: 0 additions & 1 deletion deploy/ansible/roles/iroha-k8s/files/genesis.block

This file was deleted.

20 changes: 20 additions & 0 deletions deploy/ansible/roles/iroha-k8s/files/iroha-k8s-configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
data:
config.docker: |
{
"block_store_path" : "/tmp/block_store/",
"torii_port" : 50051,
"internal_port" : 10001,
"pg_opt" : "host=localhost port=5432 user=postgres password=mysecretpassword",
"max_proposal_size" : 10,
"proposal_delay" : 5000,
"vote_delay" : 5000,
"mst_enable" : true,
"mst_expiration_time" : 1440
}
genesis.block: '{"block_v1":{"payload":{"height":"1","prevBlockHash":"0000000000000000000000000000000000000000000000000000000000000000","transactions":[{"payload":{"reducedPayload":{"commands":[{"createRole":{"permissions":["can_add_peer","can_add_signatory","can_create_account","can_create_domain","can_get_all_acc_ast","can_get_all_acc_ast_txs","can_get_all_acc_detail","can_get_all_acc_txs","can_get_all_accounts","can_get_all_signatories","can_get_all_txs","can_get_blocks","can_get_roles","can_read_assets","can_remove_signatory","can_set_quorum"],"roleName":"admin"}},{"createRole":{"permissions":["can_add_signatory","can_get_my_acc_ast","can_get_my_acc_ast_txs","can_get_my_acc_detail","can_get_my_acc_txs","can_get_my_account","can_get_my_signatories","can_get_my_txs","can_grant_can_add_my_signatory","can_grant_can_remove_my_signatory","can_grant_can_set_my_account_detail","can_grant_can_set_my_quorum","can_grant_can_transfer_my_assets","can_receive","can_remove_signatory","can_set_quorum","can_transfer"],"roleName":"user"}},{"createRole":{"permissions":["can_add_asset_qty","can_create_asset","can_receive","can_transfer"],"roleName":"money_creator"}},{"createDomain":{"defaultRole":"user","domainId":"test"}},{"createAsset":{"assetName":"coin","domainId":"test","precision":2}},{"createAccount":{"accountName":"admin","domainId":"test","publicKey":"f98baa265831780855e80d0dbe271eb916a89fc7c6078ba55f3f111aec3baf40"}},{"createAccount":{"accountName":"test","domainId":"test","publicKey":"705d21dc33c06f821ae32a2c9c188481471c567028ec999f8027a2b923c6b6aa"}},{"appendRole":{"accountId":"admin@test","roleName":"admin"}},{"appendRole":{"accountId":"admin@test","roleName":"money_creator"}},{"addPeer":{"peer":{"address":"iroha-peer-0.iroha:10001","peerKey":"def1742b8293536ac0ecf3c04e4a7305963dc85e927a9742b5d915fde27e1399"}}},{"addPeer":{"peer":{"address":"iroha-peer-1.iroha:10001","peerKey":"4c84670a4c8b1a9513604986f80dab085d5373bb7bfba9d14ecc3a46fbc8797e"}}},{"addPeer":{"peer":{"address":"iroha-peer-2.iroha:10001","peerKey":"76af9fa68bb3b839f2bab63e67ac77a4f5dcc0d0842bea3787b5f9189ad1136e"}}},{"addPeer":{"peer":{"address":"iroha-peer-3.iroha:10001","peerKey":"94cf1c22325e2d6d4200ce9779833f103c3d2461b6d4684b124ad91b64b79fdb"}}},{"addPeer":{"peer":{"address":"iroha-peer-4.iroha:10001","peerKey":"43d6ae141f277e1309be0f5912a5a879c317f0d91202befd6fe872f49d51c7a2"}}},{"addPeer":{"peer":{"address":"iroha-peer-5.iroha:10001","peerKey":"0f7de3d0cd57a286160571c50ffb9c6e73f2070a58479a21751a12f0863a103e"}}},{"addPeer":{"peer":{"address":"iroha-peer-6.iroha:10001","peerKey":"bc3cec44a09c129532dcf51568fe45bb568f76af48b4cdec85e3728dd438ae93"}}}],"quorum":1}}}],"txNumber":1}}}'
kind: ConfigMap
metadata:
creationTimestamp: null
name: iroha-config
namespace: iroha-peer-network
Loading