0CHAIN
Search…
0miner
0miner enables service providers to join the 0Chain decentralized network to buy and sell storage on an open market. By easily scaling functionalities of 0Chain components( miners, sharders and blobbers),0miner ensures fast operations in an automated manner.

Features

Simplified Operations with MicroK8s

0miner deployment leverages Microk8s- a small, lightweight, Kubernetes distribution from Canonical for simplicity and performance. Microk8s supports easy deployment with a single command install on Linux, Windows, and macOS and provides pain-free storage scaling for 0Chain data. 0miner storage also allows the addition of storage disks to provide a convenient way to request and consume 0chain data.

Pod Management with Rancher

0miner deployment can be managed using the Rancher dashboard which shows all the relevant information about pods at a glance, including enabled features, providers, entry points, and routers. In addition, it enables easy inspection and error reporting for Kubernetes resources

Logging with Kibana

0miner improves 0Chain functionality by utilizing Kibana for data visualization and exploration. Kibana can be run on-premises, on Amazon EC2 to interactively inspect large log files, and drill down on reports to extract actionable insights from your data. Using Kibana’s pre-built aggregations and filters, dashboards and reports are easily viewed in the browser for cluster overview.

Resource Monitoring with Grafana

0miner enables grafana capabilities to provide a straightforward, easy-to-use way to manage resource usage between microservices on a cluster. Features include histograms, Geo maps, alerts, and triggers

Getting Started

This section covers 0Chain concepts, repository configuration, and installation which automates deployment using Kubernetes to start 0chain components

Concepts

0Chain
A blockchain-based decentralized storage network
0Chain Service Providers
Users (Miners, Sharders, and Blobbers) that perform several duties necessary for functional blockchain and storage systems,
Miners
They build, verify, notarize, and finalize blocks based on consensus. Miners need to store wallet and smart contract states on their ledger to ensure submitted transactions are executed correctly. •
Sharders
They store blocks, keep records of View Changes through magic blocks, and respond to queries from users. Anyone joining the network queries the Sharders to determine the active members of the blockchain. •
Blobbers
They store data of any size and provide a single source of truth for that data
Consensus
Mechanisms used in blockchain systems to achieve the necessary agreement/conditions on a single state of the network
ZCN
0Chain's native token for rewarding service providers

System requirements

To properly deploy 0Chain components, you must have a Virtual Machine setup with the following requirements:
  • Linux with ubuntu 18.04 preferred
  • 4 vCPU, 8 Gb Memory at minimum
  • 200 GB of space to store the initial 0chain deployment components. Expandable block storage to handle the network growing needs.
Note: These are the minimal requirements to run the deployment.

Required Software dependencies

Installing and running the 0chain components requires deployment-specific dependencies to be preinstalled

MicroK8s:

Installing MicroK8s
0miner automates 0chain deployment using Kubernetes distribution MicroK8s.
The easiest way to install MicroK8s as a root user is :
1
sudo snap install microk8s --classic --channel=1.17/stable
Copied!
Here we have used an older 1.17 stable release of microk8s by using the --channel option. For example, to install the latest stable version, simply run:
1
snap install microk8s --classic
Copied!
Starting MicroK8s
To check whether MicroK8s has properly installed. Simply start the service using:
1
sudo snap start microk8s
Copied!
and check its status using
1
sudo microk8s status --wait-ready
Copied!
Output for status command will be this:
1
microk8s is running
2
addons:
3
cilium: disabled
4
dashboard: disabled
5
dns: disabled
6
fluentd: disabled
7
gpu: disabled
8
helm: disabled
9
ingress: disabled
10
istio: disabled
11
jaeger: disabled
12
knative: disabled
13
linkerd: disabled
14
metrics-server: disabled
15
prometheus: disabled
16
rbac: disabled
17
registry: disabled
18
storage: disabled
Copied!
As you can see, MicroK8s is running as expected and we can see a long list of addon components provided in microK8s
Jq(JSON processor)
0miner deployment needs. The easiest way to install it is:
1
sudo apt update && sudo apt install jq -y
Copied!
Kubectl
kubectl, is a command-line tool that allows the running of commands against Kubernetes clusters. kubectl in 0miner deployment can be used to inspect and manage cluster resources.
To install Kubectl in ubuntu, Execute the following commands
1
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
2
3
chmod +x ./kubectl
4
sudo mv ./kubectl /usr/local/bin/kubectl
Copied!
The curl commands will download the kubectl package while the other two commands will replace the binary distribution of kubectl with the corresponding distribution for the Operating System (OS).
Python3 & pip3
To build 0chain components, you need a working installation of python libraries. Get it by executing the following commands
1
sudo apt update && sudo apt install python3-pip -y
2
pip3 install -U PyYAML
Copied!
Helm
To mantain 0miner Kubernetes components, Helm is required as a package manager. To install helm use the following command
1
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
Copied!

Installing 0Chain components on microK8s

Once all the software dependencies are installed
  1. 1.
    Configure kubectl on the host by generating the required config :
1
sudo su
2
mkdir ~/.kube
3
microk8s config > ~/.kube/config
4
kubectl get po -A
Copied!
2.Clone the repository:
1
git clone https://github.com/0chain/0miner.git
Copied!
3.Change directory to 0miner/0chain_setup
1
cd 0miner/0chain_setup
Copied!
4.Run the batch file located in the directory to install k8s components
1
bash utility/local_k8s.sh
Copied!
5.Also, install the required python packages mentioned in the requirements text file
1
pip3 install -r utility/requirements.txt
Copied!
  1. 1.
    For installation, you will be required to input your VM IP and public IP range.
    For an IP range, If having VM IP of 3.134.116.182 enter 3.134.116.182-3.134.116.182

Configuring 0Chain components

The configuration for 0Chain components is done statically via the on-prem_input_microk8s_standalone.json file located in 0chain_setup/utility/config folder
  1. 1.
    Navigate to the 0chain_setup/utility/config folder
    1
    cd utility/config
    Copied!
  2. 2.
    Edit the config file using nano editor
    1
    nano on-prem_input_microk8s_standalone.json
    Copied!
​ Here is a sample on-prem_input_microk8s_standalone.json file .
1
{
2
"cloud_provider": "on-premise",
3
"cluster_name": "test", // Namespace in which all your resources will be created
4
"sharder_count": "1", // number of sharder you want to deploy
5
"miner_count": "1", // number of miner you want to deploy
6
"blobber_count": "1", // number of blobber you want to deploy
7
"deploy_main": true,
8
"deploy_auxiliary": true,
9
"host_address": "<your-domain>", // Host url for your public IP
10
"host_ip": "18.217.219.7", // Host ip
11
"kubeconfig_path": "", // path to your kubeconfig, keep it empty to use system configured kubeconfig
12
"n2n_delay": "", // Delay between node to slow down block creation
13
"fs_type": "microk8s-hostpath", // valid file system type (On-premise) [standard/ microk8s-hostpath/ openebs-cstore-sc]
14
"repo_type": "0chaintest", // Repository to use 0chainkube or 0chaintest
15
"image_tag": "latest", // image version to be used
16
"record_type": "A", // Dns record type supported by cloud provider (AWS) [CNAME] || (OCI) [A]
17
"deployment_type": "public", // Use of deployment "PUBLIC" or "PRIVATE"
18
"monitoring": {
19
"elk": "true", // always true
20
"elk_address": "elastic.<your-domain>", // leave empty if you want to access elk on nodeport
21
"rancher": "true",
22
"rancher_address": "rancher.<your-domain>",
23
"grafana": "true",
24
"grafana_address": "grafana.<your-domain>" // leave empty if you want to access grafana on nodeport
25
},
26
"on_premise": {
27
"environment": "microk8s",
28
"host_ip": "18.217.219.7" // Host ip
29
},
30
"standalone": {
31
"public_key": "",
32
"private_key": "",
33
"network_url": "two.devnet-0chain.net", // url of the network you want to join
34
"blobber_delegate_ID": "20bd2e8feece9243c98d311f06c354f81a41b3e1df815f009817975a087e4894",
35
"read_price": "",
36
"write_price": "",
37
"capacity": ""
38
}
39
}
Copied!
3.Necessary Configuration Changes *
  • The elk_address,rancher_address,grafana_adresss has to be updated with registered domain name
  • host_ipfield has to be updated with Virtual Machine public IPv4 address.
  • host_address field has to be updated with a registered domain name.
  • To change the network network_url field has to be replaced with url of the network you want to join. In this case it should be beta.0chain.net.
4. Create DNS records for your registered domain name under domain settings for your VM instance. .
5. Add the following A-type DNS records for connecting the domain to IP associated with the VM.
DNS Record Name
DNS Record Type
Value/Route Traffic to
<DOMAIN_NAME>
A
<VM_INSTANCE_IP>
<grafana.DOMAIN_NAME>
A
<VM_INSTANCE_IP>
<kibana.DOMAIN_NAME>
A
<VM_INSTANCE_IP>
<rancher.DOMAIN_NAME>
A
<VM_INSTANCE_IP>
Here is an example with a sample domain (zerominer.xyz) and Instance IP(3.22.152.211)
DNS Record Name
DNS Record Type
Value/Route Traffic to
zerominer.xyz
A
3.22.152.211
grafana.zerominer.xyz
A
3.22.152.211
kibana.zerominer.xyz
A
3.22.152.211
rancher.zerominer.xyz
A
3.22.152.211
7. After creation of the four records mentioned above you should be automatically provided with NS DNS record which contains name servers that should be copied/updated under your domain registrar (GoDaddy,HostGator,NameCheap) nameserver settings. For example check the screenshot below of AWS domain settings for our VM instance . In this case AWS is providing nameservers(ns-1466.awsdns-55.org) under NS DNS record type which should be updated in the domain registrar nameserver settings.

Start the 0Chain components

  1. 1.
    Execute the JSON script file using the bash command
1
bash 0chain-standalone-setup.sh --input-file utility/config/on-prem_input_microk8s_standalone.json
Copied!
During the first run, the necessary parameter data will be initialized and all the necessary components will be installed. This can be gigabytes of data installed once. We recommend waiting until the whole process is completed.
2. Once the installation is complete, verify and validate the deployment throughhttps://<network_url>/sharder01/_diagnostics
3. Here is a sample output when you visit the network URL (https://beta.0chain.net/sharder01/_diagnostics). Note that the network URL changes with configuration in the JSON file.

Managing 0Chain Components

Once the script is executed, Kibana and Grafana dashboards are available at URL's specified in the configuration file for metrics and Logging. Cluster pods can be managed using the Rancher which will be available at the rancher.<domain-name>.
Below are examples of how Grafana, Kibana, and Rancher look after the deployment
Grafana
1.Enter the Grafana domain you have specified in the config file for example(grafana.example.com) into your browser. On successful response you will see a window to log in to the dashboard.
2.Sign in with your credentials.
3.After successful login. you will see graphs and resource Usage(CPU,Memory) for the blobbers deployed using 0miner. You can see the test namespace being created Also to provide a durable location for all blobbers,sharders .and miners data persistent volume claims(pvc) are created.
4.As you navigate down you will see resource Usage ( CPU and memory Usage) for Sharders, and Miners as well. Whenever the data will be accessed or a number of deployed 0miner components are increased these resource usage will change.
4.You can also create custom dashboards by clicking on the plus button on upper left (see the dashboard screenshot on step 3) and try to see usage for certain metrics. For instance if you try to find etcd(key/value) object counts for API objects or state of pods in the cluster. It will return visualizing graphs.You only have to select that metric in the dropdown here in this below dashboard screenshot we have select `etcd_object_counts

Logs using Kibana

1.Enter the Elastic Kibana domain you have specified in the config file for example (kibana.example.com) into your browser and log in to the dashboard.
2.Sign in with your credentials.
*Note for every deployment a new password is generated, so have a look at your command shell during the script execution for the password.
3.After successful login you will see logging activity for sharders and other components. The graph count describes the total logging events.You can see the test namespace being created You can filter these logs based on fields and visualize graphs by searching in the search field names box on the upper left corner.
4.For example lets try to see logging events forkubernetes.pod.namefield Once you search this field in the search field names box. It will be listed in available fields to add.
5 Click on the field. You will see a visualizing graph of logging activities in descending order for different types of pods in the cluster.

Manage Pods using Rancher

1.Enter the Rancher domain you have specified in the config file for example(rancher.example.com) into your browser and log in to the dashboard.
2.Rancher will ask you to create a random or specific password for the admin user, default view for the dashboard, and agree to terms and conditions.
3.After successful login .it will ask you to select your test cluster and you will see your cluster dashboard listed with cluster statistics(pods, namespaces, services, etc). The metrics count describes the number of pods used, cores, and, memory reserved.
4.From here you can click on the upper right shell logo which will execute the kubectl shell for running cluster commands.
5.Here is a screenshot of kubectl shell running the rancher dashboard.
6..For managing pods in the cluster to increase cpu and memory resources for 0Chain components simply click on the pods in the left of the dropdown menu. You will see a list of pods already created. To create a new pod click on create from yaml on the upper right corner.
7.You will see a sample yaml config for pods. Make any desired changes and click create. You will see your new pods listed in the pods section.
Also, you can edit existing deployments to increase cpu and memory resources.Go to Deployments drop-down menu on the left > Click on three dots opposite edit > Edit Yaml > Change resource values and save.

💻 Community

For support related to 0miner deployment check our community forum at [https://community.0chain.net/].
If you are interested in manually setup 0Chain please have a look at 0chain and blobber repos.
You might also want to check our 0Chain blog here

Contribute

All of our code for 0Chain is open source. No matter your level of expertise. Help us make 0Chain better by sending a pull request here
  • Mine Data: For those looking to provide services as a storage provider
  • Store Data: For those looking for decentralized storage.

Chat

For discussions, join our community chat directly on
Telegram
Twitter
Reddit
Last modified 2mo ago