Generative Data Intelligence

A Polkadot validator on Kubernetes

Date:

MIDL.dev

We are introducing polkadot-k8s, an open-source project designed to spin up a secure Polkadot or Kusama validator setup in one-shot. Polkadot is a sharded proof-of-stake blockchain, and Kusama is Polkadot’s canary network.

We have been successfully operating a Kusama validator, Hodl.farm, for two months using this model. We also operate a Tezos bakery on Kubernetes.

In this tutorial we show how to deploy a validator on Google Kubernetes Engine with just a few utilities on your laptop. All is automated and specified in code; no need to compile any Rust code or install any startup script.

This is not a magic bullet! Being a validator requires care and constant attention. But you may find it as a good starting point as you set up your own operations.

Polkadot/Kusama tokens have value. To avoid loss of funds, use judgement and care in your network interactions.

First, familiarize yourself with the concept of staking in Polkadot and read through the guide on how to become a validator.

Create a Google Cloud account. You will get $300 of free credits. That will let you try out this tutorial at no cost.

Next, download the following utilities and install them on your machine:
Google Cloud SDK
Kubectl
Terraform

Authenticate and create local application credentials:

gcloud auth login
gcloud auth application-default login

Then clone the polkadot-k8s repository, and issue the following terraform commands:

cd terrraform
terraform init
terraform plan -out plan.out

Terraform will then ask you to populate a list of variables: a name for your validator, telemetry URL, chain type, bond address, etc… See README for the entire list and a complete example. You may also pre-fill a file named terraform.tfvars with all your variables.

Finally:

terraform apply plan.out

This is the one command that deploys everything. It will:

  • create a Kubernetes cluster,
  • build the necessary containers,
  • download and unzip a pre-synced database for faster bringup, if you passed an URL,
  • spin up the sentry and validator nodes,
  • bring up Polkadot PANIC alerter, preconfigured to send you a Telegram alert when something goes wrong with the setup

From zero to synced in a few minutes

Connect to your cluster

Once the terraform command has run, your environment is configured to connect to your newly-created cluster.

You can use the k9s utility to browse your cluster, display logs and forward ports. Start it with:

k9s

One validator node protected by two sentries

You can hit l to browse the logs and see your nodes syncing:

Validator node is configured to peer only with the two sentries

You may hit shift+f to enable port forwarding on your private node, then set the local and remote ports to 9944 (websocket):

The websocket port, 9944, will be accessible locally

Then open the polkadot.js app in your web browser, click on the top left of the page and select “local node” as your endpoint.

You are now able to bond your DOT tokens and inject your session keys. Then register as a validator as per the guide.

Validating in a proof-of-stake network is not fire-and-forget. You need to be on top of the protocol developments and carefully monitor your infrastructure. Kubernetes provides a powerful abstraction layer and helps focusing on what really matters — the runtime. Its architecture makes it easy to update the software incrementally. It eliminates all classes of “it works on my machine” issues.

Kubernetes also abstracts away the differences between cloud providers (AWS, GCP, Azure). It reduces friction and enables multi-cloud strategies which are good for network decentralization. Projects like k3s make it possible to run it on your own servers as well.

Learning Kubernetes is a worthwile investment for running scalable and distributed proof-of-stake infrastructure.

We are MIDL.dev, a staking-as-a-service company. We help you stake our cryptocurrency. Contact us if you need help with your staking operations.

Source: https://medium.com/better-programming/a-polkadot-validator-on-kubernetes-3e694cb43841?source=rss——-8—————–cryptocurrency

spot_img

Latest Intelligence

spot_img