Skip to content

Commit e9dfabe

Browse files
committed
BREAKING REFACTOR: move some values to global, add lnd as subchart
1 parent b637bd3 commit e9dfabe

File tree

17 files changed

+117
-116
lines changed

17 files changed

+117
-116
lines changed

resources/charts/bitcoincore/Chart.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ apiVersion: v2
22
name: bitcoincore
33
description: A Helm chart for Bitcoin Core
44

5+
dependencies:
6+
- name: lnd
7+
version: 0.1.0
8+
condition: ln.lnd
9+
510
# A chart can be either an 'application' or a 'library' chart.
611
#
712
# Application charts are a collection of templates that can be packaged into versioned archives

resources/charts/lnd/Chart.yaml renamed to resources/charts/bitcoincore/charts/lnd/Chart.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apiVersion: v2
22
name: lnd
3+
34
description: A Helm chart for LND
45

56
# A chart can be either an 'application' or a 'library' chart.

resources/charts/lnd/templates/_helpers.tpl renamed to resources/charts/bitcoincore/charts/lnd/templates/_helpers.tpl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1+
{{/*
2+
Expand the name of the PARENT chart.
3+
*/}}
4+
{{- define "bitcoincore.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified PARENT app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "bitcoincore.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- end }}
19+
{{- end }}
20+
21+
122
{{/*
223
Expand the name of the chart.
324
*/}}
425
{{- define "lnd.name" -}}
5-
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
26+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}-ln
627
{{- end }}
728

829
{{/*
@@ -14,7 +35,7 @@ If release name contains chart name it will be used as a full name.
1435
{{- if .Values.fullnameOverride }}
1536
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
1637
{{- else }}
17-
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}
38+
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}-ln
1839
{{- end }}
1940
{{- end }}
2041

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "lnd.fullname" . }}
5+
labels:
6+
{{- include "lnd.labels" . | nindent 4 }}
7+
data:
8+
lnd.conf: |
9+
{{- .Values.baseConfig | nindent 4 }}
10+
{{- .Values.defaultConfig | nindent 4 }}
11+
{{- .Values.config | nindent 4 }}
12+
bitcoin.{{ .Values.global.chain }}=1
13+
bitcoind.rpcpass={{ .Values.global.rpcpassword }}
14+
bitcoind.rpchost={{ include "bitcoincore.fullname" . }}:{{ index .Values.global .Values.global.chain "RPCPort" }}
15+
bitcoind.zmqpubrawblock=tcp://{{ include "bitcoincore.fullname" . }}:{{ .Values.global.ZMQBlockPort }}
16+
bitcoind.zmqpubrawtx=tcp://{{ include "bitcoincore.fullname" . }}:{{ .Values.global.ZMQTxPort }}
17+
alias={{ include "lnd.fullname" . }}
18+
externalhosts={{ include "lnd.fullname" . }}
19+
tlsextradomain={{ include "lnd.fullname" . }}

resources/charts/lnd/templates/pod.yaml renamed to resources/charts/bitcoincore/charts/lnd/templates/pod.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ metadata:
1414
{{- if .Values.collectLogs }}
1515
collect_logs: "true"
1616
{{- end }}
17+
chain: {{ .Values.global.chain }}
1718
spec:
1819
{{- with .Values.imagePullSecrets }}
1920
imagePullSecrets:

resources/charts/lnd/values.yaml renamed to resources/charts/bitcoincore/charts/lnd/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ baseConfig: |
111111
maxpendingchannels=64
112112
trickledelay=1
113113
rpclisten=0.0.0.0:10009
114-
# zmq* and bitcoind.{rpcuser, rpcpass} are set in warnet code
114+
bitcoind.rpcuser=user
115+
# zmq* and bitcoind.rpcpass are set in configmap.yaml
115116
116117
config: ""
117118

resources/charts/bitcoincore/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ Always add for custom semver, check version for valid semver
6565
{{- $custom := contains "-" .Values.image.tag -}}
6666
{{- $newer := semverCompare ">=0.17.0" .Values.image.tag -}}
6767
{{- if or $newer $custom -}}
68-
[{{ .Values.chain }}]
68+
[{{ .Values.global.chain }}]
6969
{{- end -}}
7070
{{- end -}}

resources/charts/bitcoincore/templates/configmap.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ metadata:
66
{{- include "bitcoincore.labels" . | nindent 4 }}
77
data:
88
bitcoin.conf: |
9-
{{ .Values.chain }}=1
9+
{{ .Values.global.chain }}=1
1010
1111
{{ template "bitcoincore.check_semver" . }}
1212
{{- .Values.baseConfig | nindent 4 }}
13-
rpcport={{ index .Values .Values.chain "RPCPort" }}
14-
rpcpassword={{ .Values.rpcpassword }}
15-
zmqpubrawblock=tcp://0.0.0.0:{{ .Values.ZMQBlockPort }}
16-
zmqpubrawtx=tcp://0.0.0.0:{{ .Values.ZMQTxPort }}
13+
rpcport={{ index .Values.global .Values.global.chain "RPCPort" }}
14+
rpcpassword={{ .Values.global.rpcpassword }}
15+
zmqpubrawblock=tcp://0.0.0.0:{{ .Values.global.ZMQBlockPort }}
16+
zmqpubrawtx=tcp://0.0.0.0:{{ .Values.global.ZMQTxPort }}
1717
{{- .Values.defaultConfig | nindent 4 }}
1818
{{- .Values.config | nindent 4 }}
1919
{{- range .Values.addnode }}

resources/charts/bitcoincore/templates/pod.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ metadata:
77
{{- with .Values.podLabels }}
88
{{- toYaml . | nindent 4 }}
99
{{- end }}
10-
chain: {{ .Values.chain }}
11-
RPCPort: "{{ index .Values .Values.chain "RPCPort" }}"
12-
ZMQTxPort: "{{ .Values.ZMQTxPort }}"
13-
ZMQBlockPort: "{{ .Values.ZMQBlockPort }}"
14-
rpcpassword: {{ .Values.rpcpassword }}
10+
chain: {{ .Values.global.chain }}
11+
RPCPort: "{{ index .Values.global .Values.global.chain "RPCPort" }}"
12+
ZMQTxPort: "{{ .Values.global.ZMQTxPort }}"
13+
ZMQBlockPort: "{{ .Values.global.ZMQBlockPort }}"
14+
rpcpassword: {{ .Values.global.rpcpassword }}
1515
app: {{ include "bitcoincore.fullname" . }}
1616
{{- if .Values.collectLogs }}
1717
collect_logs: "true"
@@ -34,8 +34,8 @@ spec:
3434
args:
3535
- |
3636
apk add --no-cache curl
37-
mkdir -p /root/.bitcoin/{{ .Values.chain }}
38-
curl -L {{ .Values.loadSnapshot.url }} | tar -xz -C /root/.bitcoin/{{ .Values.chain }}
37+
mkdir -p /root/.bitcoin/{{ .Values.global.chain }}
38+
curl -L {{ .Values.loadSnapshot.url }} | tar -xz -C /root/.bitcoin/{{ .Values.global.chain }}
3939
volumeMounts:
4040
- name: data
4141
mountPath: /root/.bitcoin
@@ -48,23 +48,23 @@ spec:
4848
imagePullPolicy: {{ .Values.image.pullPolicy }}
4949
ports:
5050
- name: rpc
51-
containerPort: {{ index .Values .Values.chain "RPCPort" }}
51+
containerPort: {{ index .Values.global .Values.global.chain "RPCPort" }}
5252
protocol: TCP
5353
- name: p2p
54-
containerPort: {{ index .Values .Values.chain "P2PPort" }}
54+
containerPort: {{ index .Values.global .Values.global.chain "P2PPort" }}
5555
protocol: TCP
5656
- name: zmq-tx
57-
containerPort: {{ .Values.ZMQTxPort }}
57+
containerPort: {{ .Values.global.ZMQTxPort }}
5858
protocol: TCP
5959
- name: zmq-block
60-
containerPort: {{ .Values.ZMQBlockPort }}
60+
containerPort: {{ .Values.global.ZMQBlockPort }}
6161
protocol: TCP
6262
livenessProbe:
6363
{{- toYaml .Values.livenessProbe | nindent 8 }}
6464
readinessProbe:
6565
{{- toYaml .Values.readinessProbe | nindent 8 }}
6666
tcpSocket:
67-
port: {{ index .Values .Values.chain "RPCPort" }}
67+
port: {{ index .Values.global .Values.global.chain "RPCPort" }}
6868
resources:
6969
{{- toYaml .Values.resources | nindent 8 }}
7070
volumeMounts:
@@ -88,11 +88,11 @@ spec:
8888
- name: BITCOIN_RPC_HOST
8989
value: "127.0.0.1"
9090
- name: BITCOIN_RPC_PORT
91-
value: "{{ index .Values .Values.chain "RPCPort" }}"
91+
value: "{{ index .Values.global .Values.global.chain "RPCPort" }}"
9292
- name: BITCOIN_RPC_USER
9393
value: user
9494
- name: BITCOIN_RPC_PASSWORD
95-
value: {{ .Values.rpcpassword }}
95+
value: {{ .Values.global.rpcpassword }}
9696
{{- if .Values.metrics }}
9797
- name: METRICS
9898
value: {{ .Values.metrics }}

0 commit comments

Comments
 (0)