Giter Club home page Giter Club logo

alephium-stack's Introduction

Alephium Stack

Code in this repository helps to run the Alephium stack on Google Cloud Platform using Kubernetes Engine. The following sites are setup and exposed using the code in this repository:

Terraform files are GCP specific. Kubernetes YAML files can probably be re-used with other cloud providers.

Prerequisit

Setup

GCP project and GKE cluster

  1. If you have not setup GCP for your google account already, you can try to set it up here. For new users, Google offers 300 USD credits. To start the trial, Google requires registration of payment method. According to the terms and conditions for GCP free trial, mining cryptocurrency is not allowed, but running a full node is not mining. Outside of the trial period however, it is ok to mine cryptocurrency.
  2. After GCP is setup, you can find your billing account id here

After that, go to the terraform folder and run

terraform init
terraform apply -var="project_billing_account=YOUR_BILLING_ACCOUNT"

More powerful machine types can be set up using kubernetes_node_pool_machine_type variable, which might be helpful during mining. More available variables please check the variables.tf file.

Kubernetes Resources

Alephium

Go to the kubernetes folder and run

kubectl apply -k alephium

This will install the Alephium full node, block explorer as well as the CPU miner in the alephium namespace.

Monitoring (Optional)

Go to the kubernetes folder and run

kubectl apply -k monitoring

This will install Prometheus and Grafana in the monitoring namespace. Prometheus server is configured to scrape the metrics endpoint for Alephium full node.

Exposing Sites (Optional)

First we need to install

Specifically:

## Install cert-manager
$ helm install \
  cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --version v1.8.0 \
  --set installCRDs=true

$ kubectl apply -f cert-manager

Specifically:

## Create `cluster-admin` permissions on the cluster
$ kubectl create clusterrolebinding cluster-admin-binding \
    --clusterrole=cluster-admin \
    --user=$(gcloud config get-value core/account)

## Install ingress-nginx
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.2.0/deploy/static/provider/cloud/deploy.yaml

After that, to expose the sites mentioned at the beginning of the README, run

# exposes alephium.softfork.se and alephium.softfork.se/docs
kubectl apply -f alephium/alephium-ingress.yaml

# exposes grafana.softfork.se
kubectl apply -f monitoring/grafana-ingress.yaml

Please take a look at alephium-ingress.yaml and grafana-ingress.yaml, update with the new domain accordingly. Note that you also need to create a DNS A record for your domain to point to the external IP address of the ingress-nginx service.

➜ kubectl get service ingress-nginx-controller --namespace ingress-nginx
NAME                       TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)                      AGE
ingress-nginx-controller   LoadBalancer   10.3.240.206   34.147.83.244   80:32611/TCP,443:31303/TCP   3h37m

Here the external IP is 34.147.83.244, which is the same as alephium.softfork.se as shown below:

➜ kubernetes git:(master) ✗ nslookup alephium.softfork.se
Server:         192.168.1.1
Address:        192.168.1.1#53

Non-authoritative answer:
Name:   alephium.softfork.se
Address: 34.147.83.244

Mining (Optional)

Alephium stack comes with 2 miners: CPU miner and GPU miner (see alephium-miner.yaml).

CPU mining

CPU miner works out of the box.

GPU mining

To do GPU ming on GKE, the terraform file already sets up a seperate GPU enabled nodepool. After the nodepool is created, Nvidia GPU device drivers need to be installed by deploying the following daemonset:

kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/nvidia-driver-installer/cos/daemonset-preloaded.yaml

Note that you might need to request GPU quota from GCP, otherwise terraform can not be executed successfully. Please refer to Running GPUs on GKE

After that, adjust the replica number for GPU miner (see alephium-miner.yaml) to mine using GPUs.

Usage

  • Run Alephium stack in K8S and expose to the public
  • Mining with powerful machines in the cloud
  • Develop against remote Alephium locally, e.g.
# Port forward alephium from Kubernetes cluster
➜ kubectl port-forward svc/alephium 12973
Forwarding from 127.0.0.1:12973 -> 12973
Forwarding from [::1]:12973 -> 12973

# Curl locally
➜ curl localhost:12973/infos/self-clique
{"cliqueId":"03764042ab3c875481e5eed6d7a59027a7232582c189e1c266f57b62591ae0d8e0","networkId":1,"numZerosAtLeastInHash":18,"nodes":[{"address":"127.0.0.1","restPort":12973,"wsPort":11973,"minerApiPort":10973}],"selfReady":true,"synced":true,"groupNumPerBroker":4,"groups":4}

alephium-stack's People

Contributors

h0ngcha0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

zheli heaten

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.