Deploy Bitcoin RPC Node

Generate JSON-RPC password secret

Bitcoin nodes that enable JSON-RPC server are required to use basic authentication while calling JSON-RPC methods.

rpc-user-password.yaml
# WARNING: DON'T use the following secret in production
apiVersion: v1
kind: Secret
metadata:
  name: kotal-rpc-user-password
stringData:
  password: s3cr3t

Apply rpc-user-password.yaml to create the password secret:

kubectl apply -f rpc-user-password.yaml

Deploy Bitcoin RPC Node

The following manifest describes a Bitcoin node that syncs Bitcoin mainnet network: mainnet, enables HTTP JSON-RPC server rpc: true, defines JSON-RPC user credentials rpcUsers: ... and uses Bitcoin Core client:

bitcoin.yaml
apiVersion: bitcoin.kotal.io/v1alpha1
kind: Node
metadata:
  name: bitcoin-node
spec:
  network: mainnet
  rpc: true
  rpcUsers:
    - username: kotal
      passwordSecretName: kotal-rpc-user-password

Apply bitcoin.yaml manifest:

Kotal operator will notice your bitcoin-node and will create all the necessary pods, persistent volumes, services, configmaps, and secrets neccessary.

You can fetch the deployed Bitcoin Node using:

It will return an output similar to the following:

Fetch Node Logs

Get the pods that has been created by Kotal for the node:

It will return an output similar to the following:

Get the logs of the running node:

It will return node logs similar to the following:

Call JSON-RPC Method

By default, Bitcoin node JSON-RPC server port is 8332, which can be changed using rpcPort.

Forward localhost:8332 calls to the node pod:

In another terminal window call getblockhash JSON-RPC method to get the genesis block hash:

You will get JSON result similar to the following:

Finally you can delete the node by:

Kubernetes garbage collector will delete all the resources that has been created by Bitcoin Node controller.

Last updated

Was this helpful?