Skip to content

Commit 6f7b034

Browse files
authored
Merge pull request #3 from hirosystems/develop
feat: add bitcoin-core helm chart
2 parents 27556ae + fa5eae1 commit 6f7b034

20 files changed

+1608
-5
lines changed

hirosystems/bitcoin-core/.helmignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj

hirosystems/bitcoin-core/Chart.lock

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: common
3+
repository: https://charts.bitnami.com/bitnami
4+
version: 1.16.1
5+
digest: sha256:bcc717c6a14262fac51e6434020ee5dd6148b864fe6cff6266c1d481df4a0c91
6+
generated: "2022-08-03T17:52:22.883723-04:00"

hirosystems/bitcoin-core/Chart.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
annotations:
2+
category: Blockchain
3+
apiVersion: v2
4+
appVersion: 22.0
5+
dependencies:
6+
- name: common
7+
repository: https://charts.bitnami.com/bitnami
8+
tags:
9+
- bitnami-common
10+
version: 1.x.x
11+
description: Bitcoin Core Node
12+
engine: gotpl
13+
home: https://github.com/bitcoin/bitcoin
14+
icon: https://bitcoin.org/img/icons/opengraph.png?1657703267
15+
keywords:
16+
- bitcoin
17+
- bitcoind
18+
- btc
19+
- blockchain
20+
maintainers:
21+
- name: Hiro Systems
22+
url: https://github.com/hirosystems/charts
23+
name: bitcoind
24+
sources:
25+
- https://github.com/bitcoin/bitcoin
26+
- https://github.com/ruimarinho/docker-bitcoin-core
27+
- https://bitcoin.org
28+
version: 0.1.0

hirosystems/bitcoin-core/README.md

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Bitcoin-core
2+
3+
## TL;DR
4+
5+
```console
6+
$ helm repo add hirosystems https://charts.hiro.so/hirosystems
7+
$ helm install my-release hirosystems/bitcoin-core
8+
```
9+
10+
## Introduction
11+
12+
This chart bootstraps a [bitcoin-core node](https://github.com/bitcoin/bitcoin) deployment on a [Kubernetes](https://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
13+
14+
## Prerequisites
15+
16+
- Kubernetes 1.19+
17+
- Helm 3.2.0+
18+
- PV provisioner support in the underlying infrastructure
19+
20+
## Installing the Chart
21+
22+
To install the chart with the release name `my-release`:
23+
24+
```console
25+
helm install my-release hirosystems/bitcoin-core
26+
```
27+
28+
The command deploys a bitcoin-core node on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation.
29+
30+
> **Tip**: List all releases using `helm list`
31+
32+
## Uninstalling the Chart
33+
34+
To uninstall/delete the `my-release` deployment:
35+
36+
```console
37+
helm delete my-release
38+
```
39+
40+
The command removes all the Kubernetes components associated with the chart and deletes the release.
41+
42+
## Parameters
43+
44+
See https://github.com/hirosystems-labs/readme-generator-for-helm to create the table
45+
46+
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
47+
48+
```console
49+
helm install my-release \
50+
--set image.tag=22.0 \
51+
--set image.debug=true \
52+
--set replicaCount=2 \
53+
hirosystems/bitcoin-core
54+
```
55+
56+
The above command sets the bitcoin-core image tag to `22.0`, enables `debug` logging, and deploys two nodes.
57+
58+
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
59+
60+
```console
61+
helm install my-release -f values.yaml hirosystems/bitcoin-core
62+
```
63+
64+
> **Tip**: You can use the default [values.yaml](values.yaml)
65+
66+
## Configuration and installation details
67+
68+
### [Rolling VS Immutable tags](https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/)
69+
70+
It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.
71+
72+
Hiro Systems will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.
73+
74+
### Ingress
75+
76+
This chart provides support for Ingress resources. If you have an ingress controller installed on your cluster, you can utilize the ingress controller to serve your application.
77+
78+
To enable Ingress integration, set `ingress.enabled` to `true`. The `ingress.hostname` property can be used to set the host name. The `ingress.tls` parameter can be used to add the TLS configuration for this host. It is also possible to have more than one host, with a separate TLS configuration for each host.
79+
80+
### TLS secrets
81+
82+
The chart also facilitates the creation of TLS secrets for use with the Ingress controller, with different options for certificate management.
83+
84+
## Persistence
85+
86+
The [bitcoin-core](https://github.com/ruimarinho/docker-bitcoin-core) image stores the Bitcoin Blockchain data and configurations at the `/hirosystems` path of the container. Persistent Volume Claims are used to keep the data across deployments.
87+
88+
### Additional environment variables
89+
90+
In case you want to add extra environment variables (useful for advanced operations like custom init scripts), you can use the `extraEnvVars` property.
91+
92+
```yaml
93+
extraEnvVars:
94+
- name: FOO
95+
value: bar
96+
```
97+
98+
Alternatively, you can use a ConfigMap or a Secret with the environment variables. To do so, use the `extraEnvVarsCM` or the `extraEnvVarsSecret` values.
99+
100+
### Sidecars
101+
102+
If additional containers are needed in the same pod as the bitcoin-core pod (such as additional metrics or logging exporters), they can be defined using the `sidecars` parameter. If these sidecars export extra ports, extra port definitions can be added using the `service.extraPorts` parameter.
103+
104+
### Pod affinity
105+
106+
This chart allows you to set your custom affinity using the `affinity` parameter. Find more information about Pod affinity in the [kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity).
107+
108+
As an alternative, use one of the preset configurations for pod affinity, pod anti-affinity, and node affinity available at the [bitnami/common](https://github.com/bitnami/charts/tree/master/bitnami/common#affinities) chart. To do so, set the `podAffinityPreset`, `podAntiAffinityPreset`, or `nodeAffinityPreset` parameters.
109+
110+
## License
111+
112+
Copyright © 2022 Hiro Systems
113+
114+
Licensed under the Apache License, Version 2.0 (the "License");
115+
you may not use this file except in compliance with the License.
116+
You may obtain a copy of the License at
117+
118+
http://www.apache.org/licenses/LICENSE-2.0
119+
120+
Unless required by applicable law or agreed to in writing, software
121+
distributed under the License is distributed on an "AS IS" BASIS,
122+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123+
See the License for the specific language governing permissions and
124+
limitations under the License.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
CHART NAME: {{ .Chart.Name }}
2+
CHART VERSION: {{ .Chart.Version }}
3+
APP VERSION: {{ .Chart.AppVersion }}
4+
5+
** Please be patient while the chart is being deployed **
6+
7+
{{- if .Values.diagnosticMode.enabled }}
8+
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
9+
10+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
11+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
12+
13+
Get the list of pods by executing:
14+
15+
kubectl get pods --namespace {{ include "common.names.namespace" . | quote }} -l app.kubernetes.io/instance={{ .Release.Name }}
16+
17+
Access the pod you want to debug by executing
18+
19+
kubectl exec --namespace {{ include "common.names.namespace" . | quote }} -ti <NAME OF THE POD> -- bash
20+
21+
In order to replicate the container startup scripts execute this command:
22+
23+
bitcoind
24+
25+
{{- else }}
26+
27+
The bitcoin-core node(s) can be accessed via port {{ include "bitcoinCore.service.ports.rpc" . }} on the following DNS names from within your cluster:
28+
29+
{{- if .Values.singleService }}
30+
{{ template "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local - connection to bitcoin-core pod(s)
31+
{{- end }}
32+
33+
{{- if .Values.uniqueServices }}
34+
{{- $replicaCount := .Values.replicaCount | int }}
35+
{{- range $i, $e := until $replicaCount }}
36+
{{ template "common.names.fullname" $ }}-{{ $i }}.{{ $.Release.Namespace }}.svc.cluster.local - connection to bitcoin-core pod {{ $i }}
37+
{{- end }}
38+
{{- end }}
39+
40+
{{- end }}
41+
42+
{{- include "common.warnings.rollingTag" .Values.image }}
43+
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{{/*
2+
Return the proper bitcoinCore image name
3+
*/}}
4+
{{- define "bitcoinCore.image" -}}
5+
{{- include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) -}}
6+
{{- end -}}
7+
8+
{{/*
9+
Return the proper image name (for the init container volume-permissions image)
10+
*/}}
11+
{{- define "bitcoinCore.volumePermissions.image" -}}
12+
{{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}}
13+
{{- end -}}
14+
15+
{{/*
16+
Return the proper Docker Image Registry Secret Names
17+
*/}}
18+
{{- define "bitcoinCore.imagePullSecrets" -}}
19+
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}}
20+
{{- end -}}
21+
22+
{{/*
23+
Create the name of the service account to use
24+
*/}}
25+
{{- define "bitcoinCore.serviceAccountName" -}}
26+
{{- if .Values.serviceAccount.create -}}
27+
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
28+
{{- else -}}
29+
{{ default "default" .Values.serviceAccount.name }}
30+
{{- end -}}
31+
{{- end -}}
32+
33+
{{/*
34+
The name of the service to use
35+
*/}}
36+
{{- define "bitcoinCore.service.name" -}}
37+
{{- template "common.names.fullname" . -}}
38+
{{- end -}}
39+
40+
{{/*
41+
The RPC service port
42+
*/}}
43+
{{- define "bitcoinCore.service.ports.rpc" -}}
44+
{{ default 8332 .Values.service.ports.rpc }}
45+
{{- end -}}
46+
47+
{{/*
48+
Return true if cert-manager required annotations for TLS signed certificates are set in the Ingress annotations
49+
Ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations
50+
*/}}
51+
{{- define "bitcoinCore.ingress.certManagerRequest" -}}
52+
{{ if or (hasKey . "cert-manager.io/cluster-issuer") (hasKey . "cert-manager.io/issuer") }}
53+
{{- true -}}
54+
{{- end -}}
55+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
kind: ClusterRoleBinding
2+
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
3+
metadata:
4+
name: {{ template "common.names.fullname" . }}
5+
labels: {{- include "common.labels.standard" . | nindent 4 }}
6+
app.kubernetes.io/component: bitcoin-core
7+
{{- if .Values.commonLabels }}
8+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
9+
{{- end }}
10+
{{- if .Values.commonAnnotations }}
11+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
12+
{{- end }}
13+
roleRef:
14+
apiGroup: rbac.authorization.k8s.io
15+
kind: ClusterRole
16+
name: {{ template "common.names.fullname" . }}
17+
subjects:
18+
- kind: ServiceAccount
19+
name: {{ template "bitcoinCore.serviceAccountName" . }}
20+
namespace: {{ include "common.names.namespace" . | quote }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if not .Values.existingSecretForConfig -}}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
app.kubernetes.io/component: bitcoin-core
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
{{- if .Values.commonAnnotations }}
13+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
14+
{{- end }}
15+
data:
16+
bitcoin.conf: {{- tpl (.Values.config | toYaml) . | nindent 4 }}
17+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{- range .Values.extraDeploy }}
2+
---
3+
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
4+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{- if .Values.ingress.enabled }}
2+
apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }}
3+
kind: Ingress
4+
metadata:
5+
name: {{ template "common.names.fullname" . }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
app.kubernetes.io/component: bitcoin-core
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
{{- if or .Values.ingress.annotations .Values.commonAnnotations }}
13+
annotations:
14+
{{- if .Values.ingress.annotations }}
15+
{{- include "common.tplvalues.render" ( dict "value" .Values.ingress.annotations "context" $) | nindent 4 }}
16+
{{- end }}
17+
{{- if .Values.commonAnnotations }}
18+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
19+
{{- end }}
20+
{{- end }}
21+
spec:
22+
{{- if and .Values.ingress.ingressClassName (eq "true" (include "common.ingress.supportsIngressClassname" .)) }}
23+
ingressClassName: {{ .Values.ingress.ingressClassName | quote }}
24+
{{- end }}
25+
rules:
26+
{{- if .Values.ingress.hostname }}
27+
- host: {{ .Values.ingress.hostname }}
28+
http:
29+
paths:
30+
{{- if .Values.ingress.extraPaths }}
31+
{{- toYaml .Values.ingress.extraPaths | nindent 10 }}
32+
{{- end }}
33+
- path: {{ .Values.ingress.path }}
34+
{{- if eq "true" (include "common.ingress.supportsPathType" .) }}
35+
pathType: {{ .Values.ingress.pathType }}
36+
{{- end }}
37+
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" .) "servicePort" "http-rpc" "context" $) | nindent 14 }}
38+
{{- end }}
39+
{{- range .Values.ingress.extraHosts }}
40+
- host: {{ .name | quote }}
41+
http:
42+
paths:
43+
- path: {{ default "/" .path }}
44+
{{- if eq "true" (include "common.ingress.supportsPathType" $) }}
45+
pathType: {{ default "ImplementationSpecific" .pathType }}
46+
{{- end }}
47+
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" $) "servicePort" "http-rpc" "context" $) | nindent 14 }}
48+
{{- end }}
49+
{{- if .Values.ingress.extraRules }}
50+
{{- include "common.tplvalues.render" (dict "value" .Values.ingress.extraRules "context" $) | nindent 4 }}
51+
{{- end }}
52+
{{- if or (and .Values.ingress.tls (or (include "common.ingress.certManagerRequest" ( dict "annotations" .Values.ingress.annotations )) .Values.ingress.selfSigned)) .Values.ingress.extraTls }}
53+
tls:
54+
{{- if and .Values.ingress.tls (or (include "common.ingress.certManagerRequest" ( dict "annotations" .Values.ingress.annotations )) .Values.ingress.selfSigned) }}
55+
- hosts:
56+
- {{ .Values.ingress.hostname | quote }}
57+
secretName: {{ printf "%s-tls" .Values.ingress.hostname }}
58+
{{- end }}
59+
{{- if .Values.ingress.extraTls }}
60+
{{- include "common.tplvalues.render" (dict "value" .Values.ingress.extraTls "context" $) | nindent 4 }}
61+
{{- end }}
62+
{{- end }}
63+
{{- end }}

0 commit comments

Comments
 (0)