Option 1: Install the Docker and cri-dockerd (Recommended)
To install the Docker Container Runtime and the cri-dockerd, follow the steps below:
Install the Docker:
Install cri-dockerd:
Option 2: Install the Docker and theContainerd
Install the Docker:
To install Containerd on your system:
Optional-Setup a docker registry server
If you are using the docker and you have only one node, the step can be skipped.
If you have deployed a Kubernetes cluster with multiple nodes, it is recommended to set up a private Docker Registry to allow other nodes to quickly pull images within the intranet.
Create a directory /docker_repo on your docker server. It will be mounted on the registry container as persistent storage for our docker registry.
<Your_registry_server_IP>: the intranet IP address of your registry server.
Finally, you can check the installation by the command:
docker system info
Create a Kubernetes Cluster
To create a Kubernetes cluster, you can use a container management tool like kubeadm. The below steps can be followed:
Install the Network Plugin
Calico is an open-source networking and network security solution for containers, virtual machines, and native host-based workloads. Calico supports a broad range of platforms including Kubernetes, OpenShift, Mirantis Kubernetes Engine (MKE), OpenStack, and bare metal services.
step 1: Install the Tigera Calico operator and custom resource definitions
If your computing provider wants to provide a GPU resource, the NVIDIA Plugin should be installed, please follow the steps:
Recommend NVIDIA Linux drivers version should be 470.xx+
If you have installed it correctly, you can see the result shown in the figure by the command kubectl get po -n kube-system
Install the Ingress-nginx Controller
The ingress-nginx is an ingress controller for Kubernetes using NGINX as a reverse proxy and load balancer. You can run the following command to install it:
If you want to support the deployment of jobs with IP whitelists, you need to change the configuration of the configmap of the Ingress-nginx Controller and apply it. First download the deploy.yaml file, modify the ConfigMap resource object in the configuration file, and add a line underdata:
use-forwarded-headers: "true"
If you have installed it correctly, you can see the result shown in the figure by the command:
Run kubectl get po -n ingress-nginx
Run kubectl get svc -n ingress-nginx
Install and config the Nginx
Install Nginx service to the Server
sudo apt update
sudo apt install nginx
Add a configuration for your Domain name Assume your domain name is *.example.com
vi /etc/nginx/conf.d/example.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name *.example.com; # need to your domain
return 301 https://$host$request_uri;
#client_max_body_size 1G;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # need to config SSL certificate
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # need to config SSL certificate
server_name *.example.com; # need to config your domain
location / {
proxy_pass http://127.0.0.1:<port>; # Need to configure the Intranet port corresponding to ingress-nginx-controller service port 80
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cookie_path / "/; HttpOnly; Secure; SameSite=None";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Note:
server_name: a generic domain name
ssl_certificate and ssl_certificate_key: certificate for https.
proxy_pass: The port should be the Intranet port corresponding to ingress-nginx-controller service port 80
Reload the Nginx config
sudo nginx -s reload
Map your "catch-all (wildcard) subdomain(*.example.com)" to a public IP address
Install the Hardware resource-exporter
The resource-exporter plugin is developed to collect the node resource constantly, computing provider will report the resource to the Lagrange Auction Engine to match the space requirement. To get the computing task, every node in the cluster must install the plugin. You just need to run the following command:
By default, the CP's repo is ~/.swan/computing, you can configure it by export CP_PATH="<YOUR_CP_PATH>"
The CP service port (8085 by default) must be mapped to the public IP address and port
Update config.toml
Edit the necessary configuration files according to your deployment requirements.
[API]
Port = 8085 # The port number that the web server listens on
MultiAddress = "/ip4/<public_ip>/tcp/<port>" # The multiAddress for libp2p
Domain = "" # The domain name
NodeName = "" # The computing-provider node name
WalletWhiteList = "" # CP only accepts user addresses from this whitelist for space deployment
WalletBlackList = "" # CP reject user addresses from this blacklist for space deployment
Pricing = "true" # default True, indicating acceptance of smart pricing orders, which may include orders priced lower than self-determined pricing.
AutoDeleteImage = false # Default false, automatically delete unused images
ClearLogDuration = 24 # The interval for automatically clearing the log, the unit is hours
PortRange= ["40000-40050","40070"] # Externally exposed port number for deploying ECP image tasks
[UBI]
UbiEnginePk = "0xB5aeb540B4895cd024c1625E146684940A849ED9" # UBI Engine's public key, CP only accept the task from this UBI engine
EnableSequencer = true # Submit the proof to Sequencer service(default: true)
AutoChainProof = true # When Sequencer doesn't have enough funds or the service is unavailable, automatically submit proof to the Swan chain
SequencerUrl = "https://sequencer.swanchain.io" # Sequencer service's API address
EdgeUrl = "https://edge-api.swanchain.io/v1" # Edge service's API address
VerifySign = true # Verify that the task signature is from Engine
[LOG]
CrtFile = "/YOUR_DOMAIN_NAME_CRT_PATH/server.crt" # Your domain name SSL .crt file path
KeyFile = "/YOUR_DOMAIN_NAME_KEY_PATH/server.key" # Your domain name SSL .key file path
[HUB]
BalanceThreshold= 10 # The cp’s collateral balance threshold
OrchestratorPk = "0xd875bD44158208fD0FDD46729Aab6709f62C7821" # Orchestrator's public key, CP only accept the task from this Orchestrator
VerifySign = true # Verify that the task signature is from Orchestrator
[MCS]
ApiKey = "" # Acquired from "https://www.multichain.storage" -> setting -> Create API Key
BucketName = "" # Acquired from "https://www.multichain.storage" -> bucket -> Add Bucket
Network = "polygon.mainnet" # polygon.mainnet for mainnet, polygon.mumbai for testnet
[Registry]
ServerAddress = "" # The docker container image registry address, if only a single node, you can ignore
UserName = "" # The login username, if only a single node, you can ignore
Password = "" # The login password, if only a single node, you can ignore
[RPC]
SWAN_CHAIN_RPC = "https://mainnet-rpc-01.swanchain.org" # Swan chain RPC
Note:
Initialize a Wallet and Deposit SwanETH
Generate a new wallet address or import the previous wallet:
computing-provider wallet new
Example output:
0x7791f48931DB81668854921fA70bFf0eB85B8211
or import your wallet:
# Import wallet using the private key
computing-provider wallet import <YOUR_PRIVATE_KEY_FILE>
Note:<YOUR_PRIVATE_KEY_FILE> is a file that contains the private key
Note:--task-types: Supports 5 task types (1: Fil-C2, 2: Mining, 3: AI, 4: Inference, 5: NodePort), separated by commas. For FCP, it needs to be set to 3.
Note: If you want to withdraw the funds from FCP, you can run the above command
Start the Computing Provider
You can run computing-provider using the following command
export CP_PATH=<YOUR_CP_PATH>
nohup computing-provider run >> cp.log 2>&1 &
[OPTIONAL] Install AI Inference Dependency
It is necessary for the Computing Provider to deploy the AI inference endpoint. But if you do not want to support the feature, you can skip it.
export CP_PATH=<YOUR_CP_PATH>
./install.sh
[OPTIONAL] Install Node-Port Dependency
Install Resource Isolation service on the k8s cluster In order to view the actual available resources of the container, you need to install a resource isolation service on the cluster.
Generate Network Policy (location at $CP_PATH/network-policy.yaml )
computing-provider network generate
Deploy Network Policy
kubectl apply -f $CP_PATH/network-policy.yaml
Confirm that all of the network policy are running with the following command.
# kubectl get gnp
NAME CREATED AT
global-01kls78xh7dk4n 2024-09-25T04:00:59Z
global-ao9kq72mjc0sl3 2024-09-25T04:00:59Z
global-e59cad59af9c65 2024-09-25T04:00:59Z
global-pd6sdo8cjd61yd 2024-09-25T04:00:59Z
global-pod1namespace1 2024-09-25T04:01:00Z
global-s92ms87dl3j6do 2024-09-25T04:01:00Z
# kubectl get globalnetworksets
NAME CREATED AT
netset-2300e518e9ad45 2024-09-25T04:00:59Z
Note: The nodes for deploying CP need to open ports in the range of 30000-32767
This section mainly introduces how to enable the function of receiving ZK tasks on FCP, which is equivalent to running an ECP. This function is optional. Once enabled, FCP can earn double benefits simultaneously, but it will also consume certain resources.
Use computing-provider account subcommands to update CP details:
computing-provider account -h
NAME:
computing-provider account - Manage account info of CP
USAGE:
computing-provider account command [command options] [arguments...]
COMMANDS:
create Create a cp account to chain
changeMultiAddress Update MultiAddress of CP (/ip4/<public_ip>/tcp/<port>)
changeOwnerAddress Update OwnerAddress of CP
changeWorkerAddress Update workerAddress of CP
changeBeneficiaryAddress Update beneficiaryAddress of CP
changeTaskTypes Update taskTypes of CP (1:Fil-C2, 2:Mining, 3: AI, 4:Inference, 5:NodePort, 100:Exit), separated by commas
help, h Show a list of commands or help for one command
OPTIONS:
--help, -h show help
Step 6: Check the Status of ZK task
To check the ZK task list, use the following command:
You can run computing-provider using the following command
export CP_PATH=<YOUR_CP_PATH>
nohup computing-provider run >> cp.log 2>&1 &
CLI of Computing Provider
Check the current list of tasks running on CP, display detailed information for tasks using -v
computing-provider task list --fcp
Retrieve detailed information for a specific task using job_uuid
computing-provider task get --fcp [job_uuid]
Delete task by job_uuid
computing-provider task delete --fcp [job_uuid]
Getting Help
License
Apache
If you plan to run a Kubernetes cluster, you need to install a container runtime into each node in the cluster so that Pods can run there, refer to . And you just need to choose one option to install the Container Runtime Environment
Please refer to the official documentation from .
cri-dockerd is a CRI (Container Runtime Interface) implementation for Docker. You can install it refer to .
Please refer to the official documentation from .
Containerd is an industry-standard container runtime that can be used as an alternative to Docker. To install containerd on your system, follow the instructions on .
1
2
.
To install Calico, you can follow the below steps, more information can be found .
3
.
.
4
5
6
7
Example [api].WalletWhiteList hosted on GitHub can be found .
Example [api].WalletBlackList hosted on GitHub can be found .
Note: If you don't have SwanETH and SWAN, please follow to .
For more device choices, please refer to this page:
For usage questions or issues reach out to the Swan team either in the or open a new issue here on GitHub.