Corda Network on Kubernetes
The core of any Blockchain application is the network on which it runs. Orchestrating this network in a secured environment which can be easily managed is the key for any successful deployment. There are many practices emerged to orchestrate and manage the network. Today we will focus on how Kubernetes can be used to orchestrate Corda Open Source Network.
First step in the Kubernetes orchestration is to create a cluster of nodes. Use the below article to create a Kubernetes cluster with a single Master and 3 Worker Nodes.
Dockerzise the Node
Kubernetes is a container orchestration tool which helps in deploying, managing and monitoring the containers. There are many open source images available for Corda, however we will create our own image so that we can mount required artifacts.
While creating the docker image for container orchestration, one needs to divide the artifacts into 2 categories, common and specific to the participants. The common artifacts for Corda nodes are the Cordapps and Corda jar files. The specific to nodes are node.conf, network-parameters and node certificates.
In our case we will mount additional-node-infos files for the network. If we use the CENM tool then we don’t need to build Docker images with additional-node-infos files.
We will also open some ports for node communication like port 30000 is for P2P communication and port 2222 for node ssh. Finally the node startup script which will be used to start the node service once the container is up.
It’s a unique IP address assigned to the Kubernetes services. This IP address is tied to the service and will not change till the lifespan of the service. We will assign static Cluster IP to all the services for the Corda Network. This will avoid editing the node.conf file for all the participants.
Below are the static cluster IP assigned to the network participants.
notary ClusterIP 10.96.0.50
partya ClusterIP 10.96.0.100
partyb ClusterIP 10.96.0.150
Clone the below repository on master node for better understanding.
git clone https://github.com/dineshrivankar/corda-network-on-kubernetes.git
Edit the .env file to add details of docker image name and hostname for each participant.
If hostnames are unknown then use the “ kubectl get nodes ” command on master. Name column in the output is the hostname for the node..
Since we are making use of Cluster IP concepts, we don’t need to change the P2P addresses for all the node.conf files. For bootstrapping the node, use below commands.
Before deploying the network, add the CorDapp jar files in the cordapps directory of the repository. These jar files will be mounted in the container. For exploration add IOU jar files. Use the below tutorial for building an IOU jar.
Running the example CorDapp
Running an example CorDapp To help you get up and running on Corda, a number of example CorDapps for both Java and…
The “ ./deploye.sh “ script located in the root directory of the repository will deploy the network on respected VM’s. Kubernetes secrets created during the network bootstrap will be used to mount the node.conf, network-parameters and node certificates.
Login to PartyA container and ssh to the node shell. Replace <<container-id>> in the below command with PartyA node container ID
docker exec -it <<container-id>> bash
ssh -p 2222 localhost -l user1
Invoke a transaction with PartyB
start IOUFlow iouValue: 99, otherParty: "O=PartyB,L=New York,C=US"
Requesting signature by notary service
Requesting signature by Notary service
Validating response from Notary service
✓ Broadcasting transaction to participants
Flow completed with result: kotlin.Unit
Query a transaction
run vaultQuery contractStateType: com.template.states.IOUState
lender: "O=PartyA, L=London, C=GB"
borrower: "O=PartyB, L=New York, C=US"
notary: "O=Notary, L=London, C=GB"
notary: "O=Notary, L=London, C=GB"