We’re giving away 1,500 DJI Tello drones. Enter to win ›
By Saif ur Rehman | Published March 23, 2018 - Updated March 23, 2018
Ethereum is a open source blockchain platform that lets anyone build decentralized applications that run on blockchain. Ethereum provides a decentralized Turing-complete virtual machine called Ethereum Virtual Machine (EVM), which can execute scripts using an international network of public nodes. Ethereuem is adaptable and flexible to use, and it also has the feature of deploying smart contracts on the blockchain using the Solidity programming language.
Like Docker, IBM Cloud Kubernetes Service is an open source development tool that enables you to package your application and run it anywhere with a barebone Linux machine and all required dependencies to run your application. Containerization means that your application runs in an isolated container, an explicitly defined, reproducible, and portable environment. The analogy is taken from freight transport where you ship your goods in containers. A container of an app is the app’s operating environment in our computing scenario. With Docker, you ship the operating environment along with your application. With IBM Cloud Kubernetes Service, you can leverage Docker containers to containerize your application and run it on IBM Cloud.
Learn how to easily deploy a private Ethereum blockchain on IBM Cloud.
Roughly one hour deploy the blockchain network to the IBM Cloud.
Create a new directory and navigate to it.
Create an empty Docker file using touch Dockerfile, and paste the following in the Dockerfile:
# Get the Ethereum Stuffs
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get install -y build-essential git
RUN add-apt-repository ppa:longsleep/golang-backports
RUN apt-get update
RUN apt-get install -y golang-go
RUN git clone https://github.com/ethereum/go-ethereum
RUN make geth
# House the data here
RUN mkdir /block-data
# Pass in the genesis block.
COPY GenesisBlock.json GenesisBlock.json
RUN ln -sf /go-ethereum/build/bin/geth /bin/geth
EXPOSE 22 8088 50070 8545
ENTRYPOINT geth --datadir /block-data init /GenesisBlock.json; geth --port 3000 --networkid 58342 --nodiscover --datadir=./block-data --maxpeers=0 --rpc --rpcaddr 0.0.0.0 --rpcport 8545 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner"
Create an empty file that helps to configure your blockchain network using touch GenesisBlock.json, and paste the following into your new configuration file:
Build your Docker image:
docker build -t myimage .
Ensure the image is built by running the docker images command:
Go to IBM Cloud’s Kubernetes-based container service and create a new cluster. Provide your cluster with a unique name; let’s call it ether for now.
Wait until the service is fully deployed before using it.
Install the IBM Cloud CLI plugin for the container service by running this command:
bx plugin install container-service -r Bluemix
Log in to your IBM Cloud account with the IBM Cloud CLI:
bx login -a https://api.ng.bluemix.net
Set your terminal context to your cluster:
bx cs cluster-config <cluster_name_or_id>
After downloading the configuration files, a command is displayed that you can use to set the path to the local Kubernetes configuration file as an environment variable. For example:
Now push your image to the Container Registry on IBM Cloud. To do this, you will tag an image to point to this registry, choose a local image, target a namespace, and target a repository.
Choose a name for your first namespace, and create that namespace. For example:
bx cr namespace-add etherprivate
Log your local Docker daemon into the IBM Cloud Container Registry:
bx cr login
Tag your Docker image. For example:
docker tag myimage registry.ng.bluemix.net/etherprivate/myimage
Push the image to IBM private registry. For example:
docker push registry.ng.bluemix.net/etherprivate/myimage
Create an empty file that will configure your Kubernetes deployment by using touch service.deployment.yml, and paste the following into your new configuration file:
name: blockchain-server-test # give any name
- name: ether
image: "registry.ng.bluemix.net/etherprivate/myimage" # your registery name
name: my-service-test-11 # give a service name
- protocol: TCP
port: 8545 # it shall be 8545 and no other port !!!!!
nodePort: 30090 # Give a port to access the application publically
A few things to consider changing:
The node port (it can be any port from 30000 to 60000)
Save the Kubernetes configuration of your cluster and run the following:
kubectl create -f service-deployment.yml
Once it is deployed, you can access the application with the public IP of a worker node:
To ensure your application is running, issue a curl command. (Don’t worry if you don’t see any output; it will not return you anything just yet.)
Access your private Ethereum blockchain running on IBM Cloud Kubernetes Service by using geth:
geth attach http://184.108.40.206:30090
You now have an Ethereum blockchain running on IBM Cloud!
personal.unlockAccount(web3.eth.coinbase, "password", 15000)
Congratulations! You have successfully set up your private Ethereum blockchain on IBM Cloud! You can now access the blockchain and deploy Solidity smart contracts to create your distributed applications on IBM Cloud.
April 3, 2019
October 9, 2018
November 27, 2018
Back to top