Usage
Requirement of Zprem repo
Requirements
For Ansible Server (Controller Node) -
Minimum 4 CPU,8GB RAMand8GB StorageFor 0prem Server (Managed Node)
For testing purpose -
Minimum 16 CPU,32GB RAMand50GB StorageRecommended -
48 CPU,128GB RAMand150TB Storage
The Operating System of Ansible and 0prem Server should be
Ubuntu 18.04.6 LTSorUbuntu 20.04.4 LTS
SSH
Sudo
This documentation presumes that users will employ the sudo utility for elevating privileges from the login user to the root user; a configuration in the file /etc/sudoers such as this:
# Allow members of group sudo to execute any command
sudo ALL=(ALL:ALL) ALLShare SSH Keys
Login to the Ansible Server -
a) run the following command in ansible server
sudo su -after running the above commands your current directory should be /root you can check by using pwd command.
pwdBefore running ansible-playbook the ansible server should share ssh public key to 0prem server.
To create an SSH key:
Generate the key:
ssh-keygenAppend the public key (~/.ssh/id_rsa.pub by default) to the file ~/.ssh/authorized_keys of each remote server by using :
ssh-copy-id [email protected]or
ssh-copy-id user@IPv4
Check the ansible server can login into 0prem server without asking any password by the following command: ssh [email protected] or ssh user@IPv4
0prem
Clone the repository on ansible server
git clone https://github.com/0chain/Zprem.gitChange the directory
cd Zprem/Your current directory should be
~/Zpremand add IPv4 in inventory fileNOTE: write same IP in kubespray, master and worker groups[kubespray] 104.34.9.187 [master] 104.34.9.187 [worker] 104.34.9.187Edit input.yaml
server: on-prem # option [on-prem, aws] RemoteUser: root # write remote server user `Note: use remote user same as used in ssh-copy-id [email protected]` cluster: zcn # write cluster name it will create same name namespace domain: 0chain.net # write your domain name sharder: 2 # write sharder count miner: 3 # write miner count blobber: 6 # write blobber count magmacount: 0 # write magma count enable_magma: false # enable magma if want to launch provider providercount: 0 # write provider count consumercount: 0 # write consumer count authorizercount: 0 # write authorizer count dns_count: 1 # write 0dns count kube_config_path: /root/.0prem/admin.conf # path where k8s config file present on ansible server nodeCount: 1 # Give number of nodes Zminer: false # do not change it Capacity: 1073741824000 # capacity of blobber in bytes sharder_tag: staging # write sharder tag miner_tag: staging # write miner tag dns_tag: staging # write 0dns tag blobber_tag: staging # write blobber tag explorer_tag: staging # write explorer tag block_tag: staging # write 0block tag box_tag: staging # write 0box tag proxy_tag: staging # write 0proxy tag search_tag: staging # write 0search tag blobber_stake_tag: staging # write blobber-stake tag nft_ui_tag: staging # write 0nft-ui tag nft_server_tag: staging # write 0nft-server tag swap_tag: feature-circle-sandbox-e61f3a3d # write 0swap tag readprice: 0.01 # enter read price writeprice: 0.01 # enter write price zchain_user: "yes" # "yes" for creating account for zchain other-wise "no" Admin_Username: admin_Dashboard # write username [Note - Enter username other then `admin`] Admin_Password: password_Dashboard # write password [Note - Password must be at least 12 characters] slackAPI: https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx # if you want slack messages for you pod OOMKilled issue the enter slack webhook url chart_reference: 0chain-dev # enter helm chart reference repos: - name: 0chain-helm # helm chart repo name url: http://0chain-helm-chart.s3-website.us-east-2.amazonaws.com/staging/ # helm chart repo url - name: jetstack url: https://charts.jetstack.io - name: rancher-stable url: https://releases.rancher.com/server-charts/stable - name: grafana url: https://grafana.github.io/helm-charts - name: 0chain-dev url: http://0chain-helm-chart.s3-website.us-east-2.amazonaws.com/dev/Install pip3
sudo apt update && sudo apt install python3-pip -yInstall Ansible and other tools
sudo pip3 install -r requirements.txtGive aws credentials in
0ansible/aws-credentials.yamlfile -NOTE: This code itself creates DNS records in Route53<cluster>.<domain>rancher.<cluster>.<domain>grafana.<cluster>.<domain>
Example - DNS Looks like zcn.0chain.net , rancher.zcn.0chain.net , grafana.zcn.0chain.net and 0box.zcn.0chain.net
Add Remote User in
ansible.cfgfileNote: use remote user same as used in ssh-copy-id [email protected][defaults] remote_user=root # edit your remote user inventory=inventory # do not change it roles_path=roles # do not change it host_key_checking=False # do not change it ask_pass=False # do not change it ansible_python_interpreter=/usr/bin/python3 # do not change it deprecation_warnings=False # do not change it collections_paths=~/.ansible/collections/ # do not change it [privilege_escalation] become=True # do not change it become_method=sudo # do not change it become_user=root # do not change it become_ask_pass=False # do not change it
Run the Ansible Playbook
Your current directory should be ~/0ansible :
ansible-playbook main.yamlif you want to check broader logs then run :
ansible-playbook main.yaml -vLinks
This link is created by binding host_address and domain in on_prem.json.
Syntax of URL - https://<cluster_name>.<domain>
Explorer -
zcn.0chain.net# link of the network you joined [will be shared once whole network is deployed]Rancher -
rancher.zcn.0chain.net# link of the rancher you launchedGrafana -
grafana.zcn.0chain.net# link of the grafana you launchedDiagnostics Page -
zcn.0chain.net/sharder01/_diagnostics
Update-Resources
After Launching blobbers to a network if you wish to change any value then use update-blobber-resources.yaml file. NOTE: your current path should be ~/0ansible/.
Run the following command for updating blobbers value -
ansible-playbook update-blobber-resources.yamlRun the following command for updating miners & sharders value -
ansible-playbook update-miner&sharder-resources.yamlResetNetwork
For reset of the network [not the cluster] run reset-0chain.yaml file. NOTE: your current path should be ~/0ansible/.
Run the following command for updating value -
ansible-playbook reset-network.yamlRedeployNetwork
After running the reset playbook run after-reset.yaml playbook. NOTE: your current path should be ~/0ansible/.
Run the following command for setting up network again -
ansible-playbook after-reset.yamlA prompt will open which asks for
Y/N[here Y is Yes and N is No]. So typeYif you wish to delete configmaps otherwise typeNand pressENTERkey.About this reset script there are certain points -
Rancher - after redeploy rancher will use password same as used in first deployment [ though there are few ways through which we can create new username & password ]
Grafana - grafana will not pick earlier password after redploying it [ always pick the password given in input file so grafana password can be changed according to set by you ]
Remove-K8SCluster
For removing entire kubernetes cluster change your current directory to /root/kubespray and run the following command -
ansible-playbook -i ~/inventory.yaml reset.ymlLast updated