Coder Social home page Coder Social logo

bitcoin-gcp-k8s's Introduction

Bitcoin Full Node on GCP Kubernetes Cluster

There are many reasons to run a Bitcoin full node. Running it in the cloud has a few extra benefits:

  • A fully indexed Bitcoin full node can take up to 300Gi disk space and non-trivial amount of CPU and memory, which is quite a bit for an everyday laptop which is also used for other purposes.
  • A cloud based Bitcoin full node can be accessed from anywhere through multiple devices, using standard tooling such as gcloud and kubectl.
  • If you want to develop or test a Bitcoin application, it is easy to point local development environment to the Bitcoin full node through port forwarding and then smoothly deploy it to the cloud later.

Code contained this repository helps to run a Bitcoin full node in Google Cloud Platform using Kubernetes Engine. It can be used as a starting point to build and deploy Bitcoin powered applications.

Prerequisit

Setup

  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.
  2. After GCP is setup, you can find your billing account id here
  3. Bitcoind RPC requires basic authentication. Use rpcauth.py to generate the rpcauth value, as shown below:
$ ./rpcauth.py username password
String to be appended to bitcoin.conf:
rpcauth=username:6436a49a71eabc219d79c38980be0a54$7bc37525a942213ee5ac1ae8cf7f802616b96bf2dd01a1e0121629be86c5d425
  1. Go into terraform directory, run
terraform init
terraform plan -var 'project_id=YOUR_PROJECT_ID' \
               -var 'project_billing_account=YOUR_BILLING_ACCOUNT_ID_FROM_STEP_2' \
               -var 'bitcoin_rpcauth=YOUR_RPCAUTH_CREATED_FROM_STEP_3' \
               -out plan.out
               
## Confirm the output and then run
terraform apply "plan.out"

By default, machine type e2-standard-2 is used, you can change it to something else using kubernetes_node_pool_machine_type variable. Similiarly, project_name, region, zone and bitcoin_version can be configured as well through terraform variables.

If everything is executed successfully, a Bitcoin node should be running in the bitcoin namespace in the kubernetes cluster.

Usage

If you want to access the Bitcoin full node locally, you need to have simply run the following command:

kubectl port-forward svc/bitcoind 8332

Then you can interact with the bitcoind as if it is running locally on your machine

$ bitcoin-cli getrawtransaction e13d407be6085f1d0a0513f47577340f41f45d0b7250f3c554e8e05590113d7a true
  "txid": "e13d407be6085f1d0a0513f47577340f41f45d0b7250f3c554e8e05590113d7a",
  "hash": "7871c106d47a4d45784d427d990adc7e221aa6fade5d3c0bf39314812cea9ee6",
  "version": 1,
  "size": 371,
  "vsize": 206,
  "weight": 821,
  "locktime": 0,
  "vin": [
    {

  ....

Cost

Issues

If you see something like this after you run terraform apply

Error: googleapi: Error 403: Kubernetes Engine API is not enabled for this project. Please ensure it is enabled in Google Cloud Console and try again: visit https://console.cloud.google.com/apis/api/container.googleapis.com/overview?projec
t=YOUR_PROJECT_ID to do so., forbidden

You maybe need to run the following command to enable it.

gcloud services enable container.googleapis.com --project=YOUR_PROJECT_ID

bitcoin-gcp-k8s's People

Contributors

h0ngcha0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rafaelturon

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.