Skip to content

Instantly share code, notes, and snippets.

@zquestz
Last active May 20, 2022 02:42
Show Gist options
  • Save zquestz/0007d1ede543478d44556280fdf238c9 to your computer and use it in GitHub Desktop.
Save zquestz/0007d1ede543478d44556280fdf238c9 to your computer and use it in GitHub Desktop.
GCE Kubernetes Bitcoin Configs

Bitcoin Kubernetes Configs

The following guide will walk you through creating a bitcoin full node within GKE (Google Container Engine).

By default Bitcoin ABC is used, however this can be swapped for any other node quite easily.

If you wish to run another version of bitcoind, just change the image reference in bitcoin-deployment.yml. There are tons of images available on the Docker Hub. Better yet, build your own. =)

The source for the included image is available at: https://github.com/zquestz/docker-bitcoin

Steps:

  1. Add a new blank disk on GCE called bitcoin-data that is 200GB. You can always expand it later.
  2. Save the following code snippets and place them in a new directory kube.
  3. Change the rpcuser and rpcpass values in bitcoin-secrets.yml. They are base64 encoded. To base64 a string, just run echo -n SOMESTRING | base64.
  4. Run kubectl create -f /path/to/kube
  5. Profit!

bitcoin-deployment.yml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  namespace: default
  labels:
    service: bitcoin
  name: bitcoin
spec:
  strategy:
    type: Recreate
  replicas: 1
  template:
    metadata:
      labels:
        service: bitcoin
    spec:
      containers:
      - env:
        - name: BITCOIN_RPC_USER
          valueFrom:
            secretKeyRef:
              name: bitcoin
              key: rpcuser
        - name: BITCOIN_RPC_PASSWORD
          valueFrom:
            secretKeyRef:
              name: bitcoin
              key: rpcpass
        image: zquestz/bitcoin-abc
        name: bitcoin
        volumeMounts:
          - mountPath: /data
            name: bitcoin-data
        resources:
          requests:
            memory: "2Gi"
      restartPolicy: Always
      volumes:
        - name: bitcoin-data
          gcePersistentDisk:
            pdName: bitcoin-data
            fsType: ext4

bitcoin-secrets.yml

apiVersion: v1
kind: Secret
metadata:
  name: bitcoin
type: Opaque
data:
  rpcuser: YWRtaW4=
  rpcpass: aXRvbGR5b3V0b2NoYW5nZXRoaXM=

bitcoin-srv.yml

apiVersion: v1
kind: Service
metadata:
  name: bitcoin
  namespace: default
spec:
  ports:
    - port: 8333
      targetPort: 8333
  selector:
    service: bitcoin
  type: LoadBalancer
  externalTrafficPolicy: Local
@avarmaavarma
Copy link

Nice! Did you have any recommendations for the VM size (2 vCPUS?, 4 vCPUs...?) and RAM ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment