# L1 Node Operation Tutorial

Welcome to our tutorial, where you will be guided step-by-step through the installation of the K3s and the configuration and startup of the Titan L1 node. Please follow the steps below to ensure your system configuration meets all requirements.

## Prerequisite: Install K3s

### 1. Install K3s:

Run the following command in your terminal to install K3s. In this step, K3s will be automatically downloaded and installed with unnecessary components disabled.

```bash
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik" sh -s -
```

### 2. Configure kubeconfig: <a href="#titan-node-installation-and-launch-tutorial" id="titan-node-installation-and-launch-tutorial"></a>

Configure the permission of kubeconfig command line tool

```
mkdir ~/.kube
sudo cat /etc/rancher/k3s/k3s.yaml | tee ~/.kube/config >/dev/null
```

### 3. Verify the installation: <a href="#titan-node-installation-and-launch-tutorial" id="titan-node-installation-and-launch-tutorial"></a>

After installation, using the following command to verify K3s is correctly installed and operational.&#x20;

```bash
kubectl get nodes
```

### 4. Install Helm tool: <a href="#titan-node-installation-and-launch-tutorial" id="titan-node-installation-and-launch-tutorial"></a>

Helm is a Kubernetes application management tool. Use the following command to install Helm:

```bash
wget https://get.helm.sh/helm-v3.11.0-linux-amd64.tar.gz
tar -zxvf helm-v3.11.0-linux-amd64.tar.gz
install linux-amd64/helm /usr/local/bin/helm
```

### 5. Install Ingress Nginx: <a href="#titan-node-installation-and-launch-tutorial" id="titan-node-installation-and-launch-tutorial"></a>

Install Ingress Nginx via Helm to add HTTP routing rules for the application:

```bash
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm upgrade --install ingress-nginx ingress-nginx \
  --repo https://kubernetes.github.io/ingress-nginx \
  --namespace ingress-nginx --create-namespace
```

### 6. Using mounted disk `/mnt/storage` <a href="#titan-node-installation-and-launch-tutorial" id="titan-node-installation-and-launch-tutorial"></a>

* Remove default `local-path StorageClass` annotations:

```
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
```

* Create the new storage class and set it as the default:

Create `storageclass.yaml` file and put in the following info:

```
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
parameters:
  path: "/mnt/storage"
```

Apply StorageClass to the K3s cluster:

```
kubectl apply -f storageclass.yaml
```

* Update ConfigMap path to `/mnt/storage`

```
// Some codekubectl patch configmap local-path-config -n kube-system --type=json -p='[{"op": "replace", "path": "/data/config.json", "value":"{\n  \"nodePathMap\":[\n  {\n    \"node\":\"DEFAULT_PATH_FOR_NON_LISTED_NODES\",\n    \"paths\":[\"/mnt/storage\"]\n  }\n  ]\n}"}]'
```

## Titan L1 Node Installation and Startup

### <mark style="color:red;">**Network Requirements**</mark> <a href="#network-requirements" id="network-requirements"></a>

Before you begin, make sure the following ports are open on your firewall or router to ensure that the nodes communicate properly:

* **9000 TCP**: Used for communication between nodes.
* **2345 TCP/UDP**: Used for broadcast and data synchronization of the nodes.
* 80 TCP: For HTTP communication.
* 443 TCP: For HTTPS communication.

<mark style="color:red;">**\*If the node's network settings do not meet our requirements, the node will not work properly and you will not be able to earn any rewards.\***</mark>

### **Step 1: Download `titan-L1` program** <a href="#step-1-download-titan-l1-program" id="step-1-download-titan-l1-program"></a>

Open the Linux terminal and download the latest version of `titan-L1` program using the following command:

{% code overflow="wrap" %}

```
wget https://github.com/Titannet-dao/titan-node/releases/download/v0.1.21/titan-l1-guardian
```

{% endcode %}

### Step 2: Set execution permissions <a href="#step-2-set-execution-permissions" id="step-2-set-execution-permissions"></a>

After the download is complete, you need to set proper execution permissions for this program file to ensure that it can run smoothly. Please enter the following command:

```
chmod 0755 titan-guardian
```

### Step 3: Configure storage environment variables <a href="#step-3-configure-storage-environment-variables" id="step-3-configure-storage-environment-variables"></a>

The Titan program needs to know where to store its data. Please select the appropriate storage path according to your system environment, and then set the environment variable. For example, if you want to use `/mnt/storage` as the storage path, you can use the following command:

```
export TITAN_METADATAPATH=/mnt/storage
export TITAN_ASSETSPATHS=/mnt/storage
```

Be sure to replace `/mnt/storage` with your actual path.

### Step 4: Run the program in the background <a href="#step-4-run-the-program-in-the-background" id="step-4-run-the-program-in-the-background"></a>

After setting the environment variables, you are ready to start the Titan program. This step requires you to provide a valid <mark style="color:red;">`code_id`</mark><mark style="color:red;">, which can be viewed in your</mark> <mark style="color:red;"></mark><mark style="color:red;">**Telegram or Email**</mark><mark style="color:red;">.</mark> Use the following command to start the program in the background and save the output log to a file:

{% code overflow="wrap" %}

```
nohup ./titan-guardian daemon start --init --url https://cassini-locator.titannet.io:5000/rpc/v0 --code <code_id> > /var/log/guardian.log 2>&1 &
```

{% endcode %}

Please replace `<code_id>` with your actual code ID

### Step 5: 👉[<mark style="color:green;">Apply Identity Code</mark>](https://titannet.gitbook.io/titan-network-en/huygens-testnet/about-huygens-testnet/installation-and-earnings/bind-the-identity-code)<mark style="color:green;">bind</mark>👈 <a href="#step-5-apply-identity-code" id="step-5-apply-identity-code"></a>

### Step 6: Bind the identity code <a href="#step-6-bind-the-identity-code" id="step-6-bind-the-identity-code"></a>

Replace the <mark style="color:red;">your-hash-here</mark> with the <mark style="color:red;">identity code</mark>

{% code overflow="wrap" %}

```
./titan-guardian bind --hash=your-hash-here https://api-test1.container1.titannet.io/api/v2/device/binding
```

{% endcode %}

#### Caution: <a href="#caution" id="caution"></a>

* Ensure that the storage path you are using exists and has write permissions.
* All output from the run will be redirected to `/var/log/guardian.log`, which you can view at any time to monitor the status of the program.
* If you encounter problems with any of the steps, please recheck that you have entered the commands correctly, or contact technical support for assistance.

The above is a complete tutorial for setting up and running a Titan node, including a detailed description of the network requirements. Following these steps will ensure that your node is installed and running correctly. Please do not hesitate to contact us if you have any questions or need further assistance.
