FCP Setup
Table of Content
Prerequisites
Before you install the Computing Provider, you need to know there are some resources required:
Possess a public IP
Have a domain name (*.example.com)
Have an SSL certificate
Go
version must 1.21+, you can refer here:
Install the Kubernetes
The Kubernetes version should be v1.24.0+
Install Container Runtime Environment
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 here. And you just need to choose one option to install the Container Runtime Environment
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
:Please refer to the official documentation from here.
Install
cri-dockerd
:cri-dockerd
is a CRI (Container Runtime Interface) implementation for Docker. You can install it refer to here.
Option 2: Install the Docker
and theContainerd
Install the
Docker
:Please refer to the official documentation from here.
To install
Containerd
on your system:Containerd
is an industry-standard container runtime that can be used as an alternative to Docker. To installcontainerd
on your system, follow the instructions on getting started with containerd.
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.
Launch the docker registry container:
Add the registry server to the node
If you have installed the
Docker
andcri-dockerd
(Option 1), you can update every node's configuration:
Then restart the docker service
If you have installed the
containerd
(Option 2), you can update every node's configuration:
Then restart containerd
service
<Your_registry_server_IP>: the intranet IP address of your registry server.
Finally, you can check the installation by the command:
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.
To install Calico, you can follow the below steps, more information can be found here.
step 1: Install the Tigera Calico operator and custom resource definitions
step 2: Install Calico by creating the necessary custom resource
step 3: Confirm that all of the pods are running with the following command
step 4: Remove the taints on the control plane so that you can schedule pods on it.
If you have installed it correctly, you can see the result shown in the figure by the command kubectl get po -A
Note:
If you are a single-host Kubernetes cluster, remember to remove the taint mark, otherwise, the task can not be scheduled to it.
Install the NVIDIA Plugin
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:
Note
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 theConfigMap
resource object in the configuration file, and add a line underdata
:
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
Add a configuration for your Domain name Assume your domain name is
*.example.com
Note:
server_name
: a generic domain namessl_certificate
andssl_certificate_key
: certificate for https.proxy_pass
: The port should be the Intranet port corresponding toingress-nginx-controller
service port 80
Reload the
Nginx
configMap 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:
If you have installed it correctly, you can see the result shown in the figure by the command: kubectl get po -n kube-system
Build and config the Computing Provider
Build the Computing Provider
Firstly, clone the code to your local:
Then build the Computing provider on the Swan Mainnet by following the below steps:
If you want to test the CP in the testnet, please build a testnet version:
Initialize CP repo and Update Configuration
Initialize repo
Note:
By default, the CP's repo is
~/.swan/computing
, you can configure it byexport 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.
Note:
Example
[api].WalletWhiteList
hosted on GitHub can be found here.Example
[api].WalletBlackList
hosted on GitHub can be found here.
Initialize a Wallet and Deposit SwanETH
SwanETH
Generate a new wallet address or import the previous wallet:
Example output:
or import your wallet:
Note:
<YOUR_PRIVATE_KEY_FILE>
is a file that contains the private keyDeposit
SwanETH
to the wallet address:Note: If you don't have
SwanETH
andSWANU
, please follow the guideline to bridge ETH to Swan Mainnet.
Initialization CP Account
Deploy a CP account contract:
Note: --task-types
: Supports 4 task types (1
: Fil-C2-512M, 2
: Mining, 3
: AI, 4
: Fil-C2-32G, 5
: NodePort), separated by commas. For FCP, it needs to be set to 3.
Output:
Collateral SWANU
for FCP
SWANU
for FCPNote: Please deposit enough collaterals for the tasks
Withdraw SWANU
from FCP
SWANU
from FCPNote: 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
[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.
[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.
For Ubuntu 20.04:
For Ubuntu 22.04 and higher.
Edit
/etc/default/grub
and modify it to the following content:
Update grub configuration
Reboot the system
Install resource-isolation service on k8s
Install network policies
Generate Network Policy (location at $CP_PATH/network-policy.yaml )
Deploy Network Policy
Confirm that all of the network policy are running with the following command.
Note: The nodes for deploying CP need to open ports in the range of
30000-32767
Change the
tasktypes
Note:
--task-types
Supports 4 task types:
1
: FIL-C2-512M
2
: Mining
3
: AI
4
: FIL-C2-32G
5
: NodePort
[OPTIONAL] Config and Receive ZK Tasks
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.
Step 1: Prerequisites: Perform Filecoin Commit2 (fil-c2) ZK tasks.
Download parameters (specify the path with PARENT_PATH variable):
Configure environment variables in
fil-c2.env
under CP repo ($CP_PATH
):
Adjust the value of
RUST_GPU_TOOLS_CUSTOM_GPU
based on the GPU used by the CP's Kubernetes cluster for fil-c2 tasks.For more device choices, please refer to this page:https://github.com/filecoin-project/bellperson
Step 2: Collateral SWANU
for ZK tasks
SWANU
for ZK tasksIf you want to withdraw the collateral
SWANU
:
Step 3: Change the tasktypes
tasktypes
Note:
--task-types
Supports 4 task types:
1
: FIL-C2-512M
2
: Mining
3
: AI
4
: FIL-C2-32G
5
: NodePort
If you need to run FCP and ECP at the same time, you need to set it to
1,2,3,4
Step 4: Deposit SwanETH
for Sequencer Account
SwanETH
for Sequencer AccountIf you want to Withdraw SwanETH from Sequencer Account
Step 5: Account Management
Use computing-provider account
subcommands to update CP details:
Step 6: Check the Status of ZK task;
To check the ZK task list, use the following command:
Example output:
Restart the Computing Provider
You can run computing-provider
using the following command
CLI of Computing Provider
Check the current list of tasks running on CP, display detailed information for tasks using
-v
Retrieve detailed information for a specific task using
job_uuid
Delete task by
job_uuid
Getting Help
For usage questions or issues reach out to the Swan team either in the Discord channel or open a new issue here on GitHub.
License
Apache
Last updated