# Deploy Kusama Validator

### Deploy Kusama Node

The following manifest describes Kusama node that syncs Kusama relay chain `network: kusama`, in archive mode `pruning: false`, and uses [Parity Polkadot](https://github.com/paritytech/polkadot) client:

{% hint style="info" %}
By default, Validator nodes are in archive mode, but Kotal requires that node explicitly mark the node as archive node by setting `pruning: false`.
{% endhint %}

{% code title="kusama.yaml" %}

```yaml
apiVersion: polkadot.kotal.io/v1alpha1
kind: Node
metadata:
  name: kusama-node
spec:
  network: kusama
  pruning: false
```

{% endcode %}

Apply `kusama.yaml` manifest:

```bash
kubectl apply -f kusama.yaml
```

Kotal operator will notice your `kusama-node` and will create all the necessary pods, persistent volumes, services, configmaps, and secrets neccessary.

You can fetch the deployed Polkadot `Node` using:

```bash
kubectl get nodes.polkadot
```

It will return an output similar to the following:

```bash
NAME             NETWORK     VALIDATOR
kusama-node      kusama      fasle
```

### Fetch Node Logs

Get the pods that has been created by Kotal for the node:

```bash
kubectl get pods
```

It will return an output similar to the following:

```bash
NAME                  READY   STATUS    RESTARTS   AGE
kusama-node-0         1/1     Running   0          1m
```

Get the logs of the running node:

```bash
kubectl logs -f kusama-node-0
```

It will return node logs similar to the following:

```
2021-10-18 15:32:38 ----------------------------
2021-10-18 15:32:38 This chain is not in any way
2021-10-18 15:32:38       endorsed by the
2021-10-18 15:32:38      KUSAMA FOUNDATION
2021-10-18 15:32:38 ----------------------------
2021-10-18 15:32:38 Parity Polkadot
2021-10-18 15:32:38 ✌️  version 0.9.11-bfd38ed62-x86_64-linux-gnu
2021-10-18 15:32:38 ❤️  by Parity Technologies <admin@parity.io>, 2017-2021
2021-10-18 15:32:38 📋 Chain specification: Kusama
2021-10-18 15:32:38 🏷 Node name: validator-node-sample
2021-10-18 15:32:38 👤 Role: AUTHORITY
2021-10-18 15:32:38 💾 Database: RocksDb at /polkadot/kotal-data/chains/ksmcc3/db/full
2021-10-18 15:32:38 ⛓  Native runtime: kusama-9110 (parity-kusama-0.tx7.au2)
2021-10-18 15:32:38 🔨 Initializing Genesis block/state (state: 0xb000…ef6b, header-hash: 0xb0a8…dafe)
2021-10-18 15:32:38 👴 Loading GRANDPA authority set from genesis on what appears to be first startup.
2021-10-18 15:32:39 ⏱  Loaded block-time = 6s from block 0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe
2021-10-18 15:32:39 👶 Creating empty BABE epoch changes on what appears to be first startup.
2021-10-18 15:32:39 🏷 Local node identity is: 12D3KooWFEHU9FXqGCL6ify4rqcon31WYViCnUfA6aVYTjRXqJ5F
2021-10-18 15:32:39 📦 Highest known block at #0
2021-10-18 15:32:39 〽️ Prometheus exporter started at 0.0.0.0:9615
2021-10-18 15:32:39 Listening for new connections on 127.0.0.1:9944.
2021-10-18 15:32:39 👶 Starting BABE Authorship worker
...
```

### Enable Validator

Once the node is fully synced, enable validator by updating the node with `validator: true`:

{% code title="kusama.yaml" %}

```yaml
apiVersion: polkadot.kotal.io/v1alpha1
kind: Node
metadata:
  name: kusama-node
spec:
  network: kusama
  pruning: false
  validator: true
```

{% endcode %}

Apply the updated `kusama.yaml` Node manifest:

```bash
kubectl apply -f kusama.yaml
```

Fetch the deployed Polkadot `Node` using:

```bash
kubectl get nodes.polkadot
```

It will return an output similar to the following:

```bash
NAME             NETWORK     VALIDATOR
kusama-node      kusama      true
```

Note that validator has changed from false to true.

### Remaining Steps

The remainig steps in setting up a validator are:

* Bonding KSM
* Generating Session Keys
* Setting Session Keys by signing and submitting an extrinsic
* Relax 🏝️

These steps are documented in [Polkadot Wiki](https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot).

We will cover next how to generate a session key.

#### Generating Session Key

{% hint style="danger" %}
Validator nodes can't enable external HTTP or WS JSON-RPC servers.
{% endhint %}

Session key can be generated by calling `author_rotateKeys` JSON-RPC method.

Forward localhost:9933 calls to the node pod because `rpcPort: 9933`:

```bash
kubectl port-forward polkadot-node-0 9933
```

{% hint style="info" %}
9933 is the default HTTP JSON-RPC server listening port, can be changed by setting node `.spec.rpcPort`
{% endhint %}

In another terminal window call `author_rotateKeys` JSON-RPC method to get a new session key:

```bash
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://127.0.0.1:9933
```

You will get JSON result similar to the following:

```json
{
  "jsonrpc": "2.0",
  "result": "0x159256d69a61b523a211d7845a92d5a238f6a97b53627c4aa92665eb6bc2959dc88c9c279ad01b8acf90573ca005f6565c4a0d88d19951740b8f8ec38c63b344b2c186e703ce88f0f4b628263265ffefa1cdc148c79a5608ccc7734e6a0bfb077076c5f370491331819d17884b9aa4e41d4e2bec774b5c31251203266c446a2ec02d89f5ecefcc75777d4de74766a57fbafe65b1850500875e8cf2fed3325f65",
  "id": 1
}
```

You can set the sesison key as documented in [Polkadot Wiki](https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot).

Finally you can delete the node by:

```bash
kubectl delete -f kusama.yaml

node.polkadot.kotal.io "kusama-node" deleted
```

Kubernetes garbage collector will delete all the resources that has been created by Kotal Polkadot `Node` controller.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kotal.co/tutorials/polkadot/validator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
