Skip to content

Commit

Permalink
Merge pull request #5 from santiment/add-bitcoind
Browse files Browse the repository at this point in the history
Add bitcoind helm chart
  • Loading branch information
kalkov authored Nov 17, 2022
2 parents feac2c3 + 3f8210d commit 084a0ac
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 0 deletions.
21 changes: 21 additions & 0 deletions charts/bitcoind/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
23 changes: 23 additions & 0 deletions charts/bitcoind/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
appVersion: 0.15.1
description: Bitcoin is an innovative payment network and a new kind of money.
engine: gotpl
home: https://bitcoin.org/
icon: https://bitcoin.org/img/icons/logotop.svg
keywords:
- bitcoind
- cryptocurrency
- blockchain
maintainers:
- email: [email protected]
name: daniel-yavorovich
- email: [email protected]
name: govale
- email: [email protected]
name: Valentin Mihov
name: bitcoind
sources:
- https://github.com/kubernetes/charts
- https://github.com/kuberstack/bitcoind
- https://github.com/kylemanna/docker-bitcoind
version: 0.1.4
91 changes: 91 additions & 0 deletions charts/bitcoind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Bitcoind

[Bitcoin](https://bitcoin.org/) uses peer-to-peer technology to operate with no central authority or banks;
managing transactions and the issuing of bitcoins is carried out collectively by the network.

## Introduction

This chart bootstraps a single node Bitcoin deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
Docker image was taken from [Bitcoind for Docker](https://github.com/kylemanna/docker-bitcoind) - many thanks!

## Prerequisites

- Kubernetes 1.8+
- PV provisioner support in the underlying infrastructure

## Installing the Chart

To install the chart with the release name `my-release`:

```bash
$ helm install --name my-release stable/bitcoind
```

The command deploys bitcoind on the Kubernetes cluster in the default configuration.
The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```bash
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following table lists the configurable parameters of the bitcoind chart and their default values.

Parameter | Description | Default
----------------------- | ---------------------------------- | ----------------------------------------------------------
`image.repository` | Image source repository name | `arilot/docker-bitcoind`
`image.tag` | `bitcoind` release tag. | `0.15.1`
`image.pullPolicy` | Image pull policy | `IfNotPresent`
`service.rpcPort` | RPC port | `8332`
`service.p2pPort` | P2P port | `8333`
`service.testnetPort` | Testnet port | `18332`
`service.testnetP2pPort` | Testnet p2p ports | `18333`
`service.selector` | Node selector | `tx-broadcast-svc`
`persistence.enabled` | Create a volume to store data | `true`
`persistence.accessMode` | ReadWriteOnce or ReadOnly | `ReadWriteOnce`
`persistence.size` | Size of persistent volume claim | `300Gi`
`resources` | CPU/Memory resource requests/limits| `{}`
`configurationFile` | Config file ConfigMap entry |

For more information about Bitcoin configuration please see [Bitcoin.conf_Configuration_File](https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File).

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

```bash
$ helm install --name my-release -f values.yaml stable/bitcoind
```

> **Tip**: You can use the default [values.yaml](values.yaml)
## Persistence

The bitcoind image stores the Bitcoind node data (Blockchain and wallet) and configurations at the `/bitcoin` path of the container.

By default a PersistentVolumeClaim is created and mounted into that directory. In order to disable this functionality
you can change the values.yaml to disable persistence and use an emptyDir instead.

> *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."*
!!! WARNING !!!

Please NOT use emptyDir for production cluster! Your wallets will be lost on container restart!

## Customize bitcoind configuration file

```yaml
configurationFile:
bitcoind.conf: |-
server=1
printtoconsole=1
rpcuser=rpcuser
rpcpassword=rpcpassword
```
12 changes: 12 additions & 0 deletions charts/bitcoind/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bitcoind RPC can be accessed via port {{ .Values.service.rpcPort }} on the following DNS name from within your cluster:
{{ template "bitcoind.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local

To connect to bitcoind RPC:

1. Forward the port for the node:

$ kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "bitcoind.name" . }},release={{ .Release.Name }}" -o jsonpath="{ .items[0].metadata.name }") {{ .Values.service.rpcPort }}

2. Test connection with user and password provided in configuration file:

$ curl --user rpcuser:rpcpassword -k http://127.0.0.1:{{ .Values.service.rpcPort }} --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;'
32 changes: 32 additions & 0 deletions charts/bitcoind/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "bitcoind.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "bitcoind.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "bitcoind.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
11 changes: 11 additions & 0 deletions charts/bitcoind/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "bitcoind.fullname" . }}
labels:
app: {{ template "bitcoind.name" . }}
chart: {{ template "bitcoind.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
{{ toYaml .Values.configurationFile | indent 2 }}
75 changes: 75 additions & 0 deletions charts/bitcoind/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "bitcoind.fullname" . }}
labels:
app: {{ template "bitcoind.name" . }}
chart: {{ template "bitcoind.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: {{ template "bitcoind.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "bitcoind.name" . }}
release: {{ .Release.Name }}
spec:
{{- if .Values.configurationFile }}
initContainers:
- name: copy-bitcoind-config
image: busybox
command: ['sh', '-c', "cp /configmap/bitcoin.conf {{ .Values.path }}/.bitcoin/bitcoin.conf"]
volumeMounts:
- name: configmap
mountPath: /configmap
- name: config
mountPath: "{{ .Values.path }}/.bitcoin/"
{{- end }}
containers:
- name: {{ template "bitcoind.fullname" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.env }}
env:
{{ toYaml .Values.env | indent 10 }}
{{- end }}
ports:
- name: rpc
containerPort: {{ .Values.service.rpcPort }}
- name: p2p
containerPort: {{ .Values.service.p2pPort }}
- name: testnet
containerPort: {{ .Values.service.testnetPort }}
- name: testnetp2pport
containerPort: {{ .Values.service.testnetP2pPort }}
volumeMounts:
- name: data
mountPath: {{ .Values.dataPath }}
{{- if .Values.configurationFile }}
- name: config
mountPath: "{{ .Values.path }}/.bitcoin/bitcoin.conf"
subPath: bitcoin.conf
{{- end }}
volumes:
{{- if .Values.configurationFile }}
- name: config
emptyDir: {}
- name: configmap
configMap:
name: {{ template "bitcoind.fullname" . }}
{{- end }}
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (include "bitcoind.fullname" .) }}
{{- else }}
emptyDir: {}
{{- end -}}
26 changes: 26 additions & 0 deletions charts/bitcoind/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "bitcoind.fullname" . }}
annotations:
"helm.sh/resource-policy": keep
labels:
app: {{ template "bitcoind.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
24 changes: 24 additions & 0 deletions charts/bitcoind/templates/svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "bitcoind.fullname" . }}
labels:
app: {{ template "bitcoind.name" . }}
chart: {{ template "bitcoind.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
ports:
- name: rpc
port: {{ .Values.service.rpcPort }}
targetPort: rpc
- name: p2p
port: {{ .Values.service.p2pPort }}
targetPort: p2p
- name: testnet
port: {{ .Values.service.testnetPort }}
- name: testnet-p2p
port: {{ .Values.service.testnetP2pPort }}
selector:
app: {{ template "bitcoind.name" . }}
release: {{ .Release.Name }}
56 changes: 56 additions & 0 deletions charts/bitcoind/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Default values for bitcoind.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

image:
repository: arilot/docker-bitcoind
tag: 0.15.1
pullPolicy: IfNotPresent

service:
rpcPort: 8332
p2pPort: 8333
testnetPort: 18332
testnetP2pPort: 18333

persistence:
enabled: true
## database data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
accessMode: ReadWriteOnce
size: 300Gi

## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
resources: {}
# requests:
# memory: 512Mi
# cpu: 300m

# Define env for the node
# env:
# - name: SOME_VAR
# value: SOME_VALUE

path: /home/bitcoin
dataPath: /data

# Custom bitcoind configuration file used to override default bitcoind settings
configurationFile:
bitcoin.conf: |-
server=1
printtoconsole=1
rpcuser=rpcuser
rpcpassword=rpcpassword
rpcbind=0.0.0.0
rpcallowip=0.0.0.0/0
maxconnections=25
rpcthreads=10
disablewallet=1

0 comments on commit 084a0ac

Please sign in to comment.