Deploying Iroha to Azure Kubernetes

We need a blockchain technology for one of our projects. We chose Hyperledger Iroha because of its simplicity and it can handle all of our required use cases. Next thing is deploying this to Azure Kubernetes Service, which is what this blog is about.
If you are using Amazon EKS, you can just follow iroha’s own guide found here. If you stumbled in this blog searching for instructions to deploy Iroha to Azure K8S then read on.
Assumptions:
- You already have running Azure K8S cluster.
- I will be using kubectl so you should already configured your kubectl client
- Basic understanding of Iroha and its APIs
- Basic understanding of blockchain
Start by cloning this github project https://github.com/hyperledger/iroha-deploy. This contains the files you will need to deploy Iroha. Once cloned, go to ansible/roles/iroha-k8s/files/. You will need the following files
- ./k8s-iroha.yaml — contains a StatefulSet which is needed to deploy Iroha. There is also a Service here so other pods can connect to Iroha. This configuration will deploy 4 replicas so 4 peers. If you want to decrease, change the value of spec.replicas
- ./k8s-peers-keys.yaml — contains the public and private keys for our peers. This supports up to 4 peers so up to 4 pods. If you want more, just add additional public/private key pairs.
- ./conf/config.docker — default configuration of an Iroha instance.
- ./conf/genesis.block — a genesis block is required for Iroha. This will be the initial state of your Iroha instance. This file is just a JSON file so you can just use any editor that can handle JSON files. There are 4 addPeer calls in this file. If you changed the number of peers, you should also update these calls as well
We can now start the deployment. First, let’s create a config map
kubectl create configmap iroha-config --from-file=path/to/your/conf/
Verify by running
kubectl get configmap iroha-config
Your newly created config map should be there
Next, let’s create the Secrets for our peers’ keys
kubectl create -f path/to/your/k8s-peer-keys.yaml
Verify by running
kubectl get secrets
All of your peer keys should be there.
Lastly, its time to actually deploy Iroha
kubectl create -f path/to/your/k8s-iroha.yaml
You just need to wait about 5 to 10 minutes (depending on the number of your peers) for the deployment to finish.
You can verify by running
kubectl get pods
All of your peers should be there and should have a status of Running.
That’s it! You now have a running Iroha instance on Azure K8S cluster. Note that you cannot publicly access your Iroha instance. You will need to deploy your app in the same network. If you want to use your Iroha instance publicly, you can create a new service with a public IP address like this
Then you can publicly access your instance using your-iroha-public-address:50051
If you want to uninstall, just follow these steps
- Delete “iroha” service
- Delete “iroha” statefulset
- Delete all pvc associated with your iroha instance
- If you want full cleanup, delete the secrets and config map as well