Running a Mina block producer in minutes with Pulumi

MIDL.dev
2 min readJan 28, 2021

--

Mina is a constant-size blockchain written in OCaml. We were eager to try itprogramatically before their mainnet release.

We decided to give it a try in a Kubernetes cluster on Amazon EKS. Mina already maintains Helm charts, so deployment was easy.

We normally use Terraform, but we recently got familiar with Pulumi, a newer infrastructure-as-code framework. There are key differences with Terraform: while Terraform requires using its own DSL, Pulumi lets you use a variety of programming languages. That being said, the ecosystem seems to be mostly focused on TypeScript, so this is what we will be using.

Pulumi is a fairly recent project, born when Kubernetes use was already mainstream. A typical cloud deployment nowadays consists of a Kubernetes cluster as its core and some “satellite” cloud-specific services. It is very easy to deploy a cluster and a helm chart programatically with Pulumi: this is what we will be doing as part of this tutorial.

Deploy a block producer

You need to download and install Pulumi, the AWS CLI and Kubectl. We also use k9s to easily access the cluster.

Clone our mina-pulumi repository.

Login to the AWS cli using your account credentials.

Clone our Mina repository.

Install the Typescript dependencies:

yarn install

Populate three files with your Testworld key:

  • in a file called key.pub , write your public key
  • in a file called key, write your encrypted private key
  • in a file called password , write the password for your private key

Then simply run:

pulumi up

This will take some time since it will:

  • deploy an EKS cluster
  • Deploy the block-producer helm chart
  • Start the block producing container with your credentials

When done, you can export the kubeconfig file for your new cluster:

pulumi stack export kubeconfig > kubeconfig.yaml

Then launch k9s:

k9s --kubeconfig=kubeconfig.yaml

You will see your pod running:

Mina block producer running in an EKS cluster

You can press Enter to observe the containers, then press key down to select the install_key container and observe that it succesfully imported your key:

Using password from environment variable CODA_PRIVKEY_PASS
Using coda keypair private-key password from environment variable CODA_PRIVKEY_PASS
😄 Imported account!
Public key: B62qnBJBhcEUC4i1Pfo5ko46Q4UXpnzA1TZwyePsPwWhudaEQ8Lw1FE stream closed

Then you may select the coda container and press s key to open a shell.

Then run

coda client status

You should see your node in state “Bootstrapped” then “Catchup” and finally “Synced”.

Congratulations! You are now running a Mina node in the cloud.

About MIDL.dev

We are a proof-of-stake infrastructure company. We create and maintain open-source framework for safe staking operations. We support the leading proof-of-stake cryptocurrencies: Tezos, Polkadot. We are eager to improve our Mina tooling to make it production-ready once the mainnet launches, and submit Helm chart improvements upstream as we go!

--

--