Skip to content

Tutorial for running an ETH 2.0 client on Kubernetes

License

Notifications You must be signed in to change notification settings

theSchein/eth2-kubernetes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ethereum 2.0 Staking with Kubernetes of GCP

⚠️ This is for Staking on Testnet and has not been tested on mainnet.

Overview

This is a reference implementation for managing ETH2 staking on Kubernetes. This implementation uses geth as the ETH1 client and lighthouse as the ETH2 client. Use this repo for educational purposes only. Nothing here should be considered "mainnet ready," it's purely designed to be an example for running ETH2 on Kubernetes and has only been tested on testnet.

The Stack

  • Geth - Ethereum 1.0 full node
  • Lighthouse - Ethereum 2.0 client for running beacon and validator clients
  • Prometheus - Digest metrics from Lighthouse
  • Grafana - Monitoring and alerting for Lighthouse metrics

User Guide

⚠️ This is a work in progress so the user guide are pretty vague.

  1. Watch this great video from ETHOnline about ETH2 staking from SuperFiz
  2. Review Lighthouse Book
  3. Follow the setup process on the Pyrmont Eth2 Launchpad, this should provide you with a ./validator_keys directory
  4. Create a directory in this repo for the pyrmont network and your validators
mkdir -p pyrmont/validators
  1. Move your validator_keys in pyrmont/validators
mv ./validator_keys ./pyrmont/validators/
  1. Use lighthouse with Docker to import your validators. You will need to run this locally and enter the password protecting your validator keys.
docker run -it -v /path/to/eth2-kubernetes/:/root/.lighthouse/ sigp/lighthouse lighthouse --network pyrmont account validator import --directory /root/.lighthouse/pyrmont/validators/validator_keys

Which should look like:

Running account manager for pyrmont network
validator-dir path: "/root/.lighthouse/pyrmont/validators"
validator-dir path: "/root/.lighthouse/pyrmont/validators"
WARNING: DO NOT USE THE ORIGINAL KEYSTORES TO VALIDATE WITH ANOTHER CLIENT, OR YOU WILL GET SLASHED.

Keystore found at "/root/.lighthouse/pyrmont/validators/validator_keys/keystore-m_XXXXXXXXXXXXX.json":

 - Public key: 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 - UUID: XXXXXXXXXXXX

If you enter the password it will be stored as plain-text in validator_definitions.yml so that it is not required each time the validator client starts.

Enter the keystore password, or press enter to omit it:

Password is correct.

Successfully imported keystore.
Successfully updated validator_definitions.yml.
  1. Confirm pyrmont/validators/validator_definitions.yaml exists and that there is a directory in pyrmont/validators for the validator that contains the keystore file. For example:
├── pyrmont
    └── validators
    |   └── 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    └── keystore-XXXXXX.json
    └── validator_definitions.yaml

⚠️ Do not commit this directory to Github!

  1. Create a new project on GCP with a unique project ID. For this example, you will see YOUR_PROJECT_ID, you'll replace this with the project ID you select in this step.

  2. Create a Storage bucket with the name of the form: YOUR_PROJECT_ID-lighthouse

  3. Upload the ./prymont folder into the newly created bucket

  4. Create a new Kubernetes cluster. I used a single node cluster with a standard N2 instance, 2 CPU, 8 GB memory for testing on testnet.

  5. Open the Cloud Shell Terminal in GCP and connect to the cluster. This can also be done from your local terminal if you have gcloud installed.

  6. Clone your eth2 repo into the terminal and go into it:

git clone https://github.com/your_username/eth2-kubernetes
cd eth2-kubernetes
  1. Use gsutil to copy your validators folder from storage into the lighthouse directory in the clone repo:
gsutil cp -r gs://YOUR_PROJECT_ID-lighthouse/pyrmont ./lighthouse
  1. Build the lighthouse docker image with your validator config and push into Google Container Registery:
docker build -t us.gcr.io/YOUR_PROJECT_ID/lighthouse:latest ./lighthouse/ --build-arg VALIDATOR_PATH=pyrmont/validators

docker push us.gcr.io/YOUR_PROJECT_ID/lighthouse:latest
  1. :Telemetry: - Prometheus and Grafana are include for monitoring your ETH2 setup. You will need to build and push those images as well:
docker build -t us.gcr.io/YOUR_PROJECT_ID/prometheus:latest ./prometheus
docker build -t us.gcr.io/YOUR_PROJECT_ID/grafana:latest ./grafana

docker push us.gcr.io/YOUR_PROJECT_ID/prometheus:latest
docker push us.gcr.io/YOUR_PROJECT_ID/grafana:latest
  1. Use helm to deploy geth and lighthouse to Kubernetes
helm upgrade --install --set lighthouse.image.tag=latest --set lighthouse.image.repository=us.gcr.io/eth2-development/lighthouse --set grafana.image.repository=us.gcr.io/eth2-development/grafana --set prometheus.image.repository=us.gcr.io/eth2-development/prometheus eth2-pyrmont infrastructure/
  1. Check that the deployment was successful in the GKE dashboard
  2. The storage disks created will persist, should you need to delete and redeploy the infrastructure, you can run:
helm delete eth2-pyrmont

Followed by:

helm upgrade --install --set lighthouse.image.tag=latest --set lighthouse.image.repository=us.gcr.io/eth2-development/lighthouse --set grafana.image.repository=us.gcr.io/eth2-development/grafana --set prometheus.image.repository=us.gcr.io/eth2-development/prometheus eth2-pyrmont infrastructure/

About

Tutorial for running an ETH 2.0 client on Kubernetes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 100.0%