Skip to content
Draft
47 changes: 47 additions & 0 deletions examples/networks/6_node_btcd/network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
nodes:
- name: tank-0001
implementation: btcd
image:
repository: lucasdbr05/btcd
tag: "latest"
addnode:
- tank-0002
- tank-0003
- name: tank-0002
implementation: btcd
image:
repository: lucasdbr05/btcd
tag: "latest"
addnode:
- tank-0003
- tank-0004
- name: tank-0003
implementation: btcd
image:
repository: lucasdbr05/btcd
tag: "latest"
addnode:
- tank-0004
- tank-0005
- name: tank-0004
implementation: btcd
image:
repository: lucasdbr05/btcd
tag: "latest"
addnode:
- tank-0005
- tank-0006
- name: tank-0005
implementation: btcd
image:
repository: lucasdbr05/btcd
tag: "latest"
addnode:
- tank-0006
- name: tank-0006
implementation: btcd
image:
repository: lucasdbr05/btcd
tag: "latest"
caddy:
enabled: true
18 changes: 18 additions & 0 deletions examples/networks/6_node_btcd/node-defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
chain: regtest

implementation: btcd
restartPolicy: OnFailure

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c47fbbb

Is this required for btcd? For lnd for example we expect it to crash and restart a few times on deployment while it waits for the bitcoin core node to come up. However, for bitcoin core itself we usually don't want this, because if bitcoin core crashes we don't want it to silently restart, we want to know why it crashed.


# TODO: find a better approach to can mine blocks (this address is just for tests)
config: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f50d525

We have ensure_miner() in the bitcoin test framework. Then in the mining scenario we call that and then getnewaddress

miningaddr=bcrt1qthmht0k2qnh3wy7336z05lu2km7emzfpm3wg46

collectLogs: true
metricsExport: false

resources: {}

image:
repository: lucasdbr05/btcd
pullPolicy: IfNotPresent
tag: "latest"
1 change: 1 addition & 0 deletions resources/charts/bitcoincore/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data:
{{ template "bitcoincore.check_semver" . }}
{{- .Values.baseConfig | nindent 4 }}
rpcport={{ index .Values.global .Values.global.chain "RPCPort" }}
rpcuser={{ .Values.global.rpcuser }}
rpcpassword={{ .Values.global.rpcpassword }}
zmqpubrawblock=tcp://0.0.0.0:{{ .Values.global.ZMQBlockPort }}
zmqpubrawtx=tcp://0.0.0.0:{{ .Values.global.ZMQTxPort }}
Expand Down
2 changes: 2 additions & 0 deletions resources/charts/bitcoincore/templates/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ metadata:
RPCPort: "{{ index .Values.global .Values.global.chain "RPCPort" }}"
ZMQTxPort: "{{ .Values.global.ZMQTxPort }}"
ZMQBlockPort: "{{ .Values.global.ZMQBlockPort }}"
rpcuser: {{ .Values.global.rpcuser }}
rpcpassword: {{ .Values.global.rpcpassword }}
app: {{ include "bitcoincore.fullname" . }}
implementation: bitcoincore
{{- if .Values.collectLogs }}
collect_logs: "true"
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions resources/charts/bitcoincore/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ global:
P2PPort: 38333
ZMQTxPort: 28333
ZMQBlockPort: 28332
rpcuser: user
rpcpassword: gn0cchi

baseConfig: |
Expand Down
23 changes: 23 additions & 0 deletions resources/charts/btcd/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions resources/charts/btcd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: btcd
description: A Helm chart for btcd (alternative Bitcoin full node in Go)

# Application chart
type: application

version: 0.1.0
appVersion: 0.1.0
1 change: 1 addition & 0 deletions resources/charts/btcd/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Thank you for installing {{ include "btcd.fullname" . }}.
59 changes: 59 additions & 0 deletions resources/charts/btcd/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "btcd.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
*/}}
{{- define "btcd.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "btcd.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "btcd.labels" -}}
helm.sh/chart: {{ include "btcd.chart" . }}
{{ include "btcd.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "btcd.selectorLabels" -}}
app.kubernetes.io/name: {{ include "btcd.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Map chain name to btcd config file flag
*/}}
{{- define "btcd.chainFlag" -}}
{{- if eq .Values.global.chain "regtest" -}}
regtest=1
{{- else if eq .Values.global.chain "signet" -}}
signet=1
{{- else if eq .Values.global.chain "testnet" -}}
testnet=1
{{- else -}}
{{/* mainnet: no flag needed */}}
{{- end -}}
{{- end -}}
20 changes: 20 additions & 0 deletions resources/charts/btcd/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "btcd.fullname" . }}
labels:
{{- include "btcd.labels" . | nindent 4 }}
data:
btcd.conf: |
{{ include "btcd.chainFlag" . }}
rpclisten=0.0.0.0:{{ index .Values.global .Values.global.chain "RPCListenPort" }}
rpcuser={{ .Values.global.rpcuser }}
rpcpass={{ .Values.global.rpcpassword }}
listen=0.0.0.0:{{ index .Values.global .Values.global.chain "P2PPort" }}
debuglevel=info
txindex=1
{{- $p2pPort := index .Values.global .Values.global.chain "P2PPort" }}
{{- range .Values.addnode }}
{{- printf "addpeer=%s:%v" . $p2pPort | nindent 4 }}
{{- end }}
{{- .Values.config | nindent 4 }}
135 changes: 135 additions & 0 deletions resources/charts/btcd/templates/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
apiVersion: v1
kind: Pod
metadata:
name: {{ include "btcd.fullname" . }}
labels:
{{- include "btcd.labels" . | nindent 4 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
chain: {{ .Values.global.chain }}
P2PPort: "{{ index .Values.global .Values.global.chain "P2PPort" }}"
RPCPort: "{{ index .Values.global .Values.global.chain "RPCListenPort" }}"
rpcuser: {{ .Values.global.rpcuser }}
rpcpassword: {{ .Values.global.rpcpassword }}
app: {{ include "btcd.fullname" . }}
implementation: btcd
{{- if .Values.collectLogs }}
collect_logs: "true"
{{- end }}
annotations:
init_peers: "{{ .Values.addnode | len }}"
addconnection_peers: {{ default (list) .Values.addconnection | toJson | quote }}
spec:
restartPolicy: "{{ .Values.restartPolicy }}"
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 4 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 4 }}
{{- if .Values.loadSnapshot.enabled }}
initContainers:
- name: download-blocks
image: alpine:latest
command: ["/bin/sh", "-c"]
args:
- |
apk add --no-cache curl
mkdir -p /root/.btcd/data
curl -L {{ .Values.loadSnapshot.url }} | tar -xz -C /root/.btcd/data
volumeMounts:
- name: data
mountPath: /root/.btcd
{{- end }}
containers:
- name: btcd
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- "/bin/linux_amd64/btcd"
args:
- "--configfile=/root/.btcd/btcd.conf"
{{- if .Values.extraArgs }}
{{- range (split " " .Values.extraArgs) }}
- {{ . | quote }}
{{- end }}
{{- end }}
ports:
- name: rpc
containerPort: {{ index .Values.global .Values.global.chain "RPCListenPort" }}
protocol: TCP
- name: p2p
containerPort: {{ index .Values.global .Values.global.chain "P2PPort" }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 8 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 8 }}
tcpSocket:
port: {{ index .Values.global .Values.global.chain "RPCListenPort" }}
resources:
{{- toYaml .Values.resources | nindent 8 }}
volumeMounts:
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 8 }}
{{- end }}
- mountPath: /root/.btcd
name: data
- mountPath: /root/.btcd/btcd.conf
name: config
subPath: btcd.conf
{{- if .Values.metricsExport }}
- name: prometheus
image: bitcoindevproject/bitcoin-exporter:latest
imagePullPolicy: IfNotPresent
ports:
- name: prom-metrics
containerPort: {{ .Values.prometheusMetricsPort }}
protocol: TCP
env:
- name: BITCOIN_RPC_HOST
value: "127.0.0.1"
- name: BITCOIN_RPC_PORT
value: "{{ index .Values.global .Values.global.chain "RPCListenPort" }}"
- name: BITCOIN_RPC_USER
value: {{ .Values.global.rpcuser }}
- name: BITCOIN_RPC_PASSWORD
value: {{ .Values.global.rpcpassword }}
{{- end }}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 4 }}
{{- end }}
volumes:
{{- with .Values.volumes }}
{{- toYaml . | nindent 4 }}
{{- end }}
- name: data
{{- if .Values.persistence.enabled }}
{{- if .Values.persistence.existingClaim }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim }}
{{- else }}
persistentVolumeClaim:
claimName: {{ include "btcd.fullname" . }}.{{ .Release.Namespace }}-btcd-data
{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
- name: config
configMap:
name: {{ include "btcd.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 4 }}
{{- end }}
19 changes: 19 additions & 0 deletions resources/charts/btcd/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "btcd.fullname" . }}.{{ .Release.Namespace }}-btcd-data
labels:
{{- include "btcd.labels" . | nindent 4 }}
annotations:
"helm.sh/resource-policy": keep
spec:
accessModes:
- {{ .Values.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- if .Values.persistence.storageClass }}
storageClassName: {{ .Values.persistence.storageClass }}
{{- end }}
{{- end }}
24 changes: 24 additions & 0 deletions resources/charts/btcd/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "btcd.fullname" . }}
labels:
{{- include "btcd.labels" . | nindent 4 }}
app: {{ include "btcd.fullname" . }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ index .Values.global .Values.global.chain "RPCListenPort" }}
targetPort: rpc
protocol: TCP
name: rpc
- port: {{ index .Values.global .Values.global.chain "P2PPort" }}
targetPort: p2p
protocol: TCP
name: p2p
- port: {{ .Values.prometheusMetricsPort }}
targetPort: prom-metrics
protocol: TCP
name: prometheus-metrics
selector:
{{- include "btcd.selectorLabels" . | nindent 4 }}
Loading
Loading