Debut Infotech
Published in

Debut Infotech

Deploying Hyperledger Fabric v1.2 on Kubernetes Cluster

As a tenacious blockchain developer, you’re likely to be familiar with Hyperledger Fabric and Kubernetes — two of the most prominent open source ecosystems. Just in case you’re not, considering the fact you are yet to embark on your Blockchain journey, let us give you a brief overview about the same.

Hyperledger Fabric is an open-source enterprise-grade Distributed Ledger Technology (DLT) platform designed primarily for permissioned blockchains. It provides developers a framework for building blockchain applications.

Kubernetes, on the other hand, is a portable, extensible open-source platform for automating deployment, scaling, and management of containerized applications. It supports multitenancy, which makes it possible for developers to develop and test Blockchain applications efficiently.

Used collectively, Hyperledger and Kubernetes offer a powerful, secure platform for processing blockchain transactions.

To begin with, we will create a cluster with three nodes (2 worker and 1 master). Make sure ‘swap’ is turned off, as Kubernetes doesn’t work with swap on. You can use any cloud for worker nodes or physical nodes. We will be using VMs in VirtualBox.

To make the process simple and easy for you to understand, we will use just one organization, one channel, one peer, one orderer, and one CouchDB.

Installing Pre-requisites on all the nodes:

  • Install docker by using the following command:
sudo apt-get update \&& sudo apt-get install -qy
  • Install Kubernetes apt repo by using the commands mentioned below:
$ sudo apt-get update \&& sudo apt-get install -y apt-transport-https \&& curl -s | sudo apt-key add -OK$ echo “deb kubernetes-xenial main” \| sudo tee -a /etc/apt/sources.list.d/kubernetes.list \&& sudo apt-get update
  • Now we need to update our packages, which can be done by using the command mentioned below:
  • Now we need to install , & . The is responsible for running containers on your hosts. is a convenience utility for configuring various components that make up a working cluster. And, represents the networking components. Use the following command to install these three components:
sudo apt-get install -y \kubelet \kubeadm \Kubernetes-cni

By default, Docker Swarm provides an overlay networking driver, but with this decision is left to us. We will be using Flannel by CoreOS in Kubernetes for Overlay network.

Initialize the cluster on master node by using the following command:

sudo kubeadm init — pod-network-cidr=

Note: — is required for the flannel driver which specifies an address space for containers.

The , as mentioned below, will take some time to run as it will have to pull several docker images.

After the initialization of cluster, you will get the following output:

To start using your cluster, you need to run the following code as a regular user:mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/configYou should now deploy a pod network to the cluster.Run “kubectl apply -f [podnetwork].yaml” with one of the options listed at: can now join any number of machines by running the following on each node as root:kubeadm join — token oyu3i2.md9znv0p31f5b7ju — discovery-token-ca-cert-hash sha256:2960349cff48d1041ff087735b3dbe995642dad557098bca64717f06959890e7

You’ll be required to copy and paste these three lines so that it can copy the master certificates in $HOME/.kube

mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/config

At the end of logs, you will get the following command:

kubeadm join — token oyu3i2.md9znv0p31f5b7ju — discovery-token-ca-cert-hash sha256:2960349cff48d1041ff087735b3dbe995642dad557098bca64717f06959890e7

This command will help you join to other nodes.

Below is a detailed overview of how you can do that, with the help of an example.

After joining the nodes, you can check the nodes on the master node by using the following command:

$ kubectl get nodes

It will show something like this:

As we can see, our nodes aren’t ready yet and are showing “NotReady” Status.

Now we need to apply the flannel plugin to add network layer.

We can do so by using the following command on the Kubernetes master node:

kubectl apply -f

After applying this code, here’s what we will get as an output:

After applying flannel, if you check your nodes again — they will be in the Ready state.

The nodes are now ready to join the Kubernetes cluster. But first, we need to deploy the Kubernetes dashboard.

To get that done, use the following command:

kubectl create -f

After applying this code, you will get the following output:

To access the dashboard, run Kubernetes proxy using the command

It will display something like this:

You can now access your Kubernetes dashboard on the following URL:


It will show something like this:

Now our cluster is ready!

We will now deploy CouchDB by using the following command:

Then, we will deploy CouchDB service using the following command:

services/couchdb0.yaml uses a nodePort. So, CouchDB will be available at as our nodePort is 30005 and mini01 node IP is

You can also check your pod status on the dashboard:

When we try to access CouchDB on <node-ip>:nodePort, here’s what we will get as a result:

We will now deploy peer, orderer & CLI in the same way we deployed CouchDB.

After doing that, we can check the status of pods from the dashboard.

Now we need to get to the CLI container for further setup.

For that, use the following command:

Now we will follow the default steps of Hyperledger fabric to set up our network.

Use the following commands:

You can see the CouchDB data:

The source code, deployments, services, and PVC can be found on the public repository on the below URL:

The above-mentioned steps will help you deploy your Fabric v1.2 instance on Kubernetes cluster with minimal configuration and efforts. Feel free to leave your thoughts and questions in the comments. For more information regarding the deployment, get in touch with us.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harpreet Singh

A pioneer in Mobile, Blockchain, Managed Services, Oracle, and AI/ML Development