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 }}

resources/charts/bitcoincore/templates/service.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ metadata:
88
spec:
99
type: {{ .Values.service.type }}
1010
ports:
11-
- port: {{ index .Values .Values.chain "RPCPort" }}
11+
- port: {{ index .Values.global .Values.global.chain "RPCPort" }}
1212
targetPort: rpc
1313
protocol: TCP
1414
name: rpc
15-
- port: {{ index .Values .Values.chain "P2PPort" }}
15+
- port: {{ index .Values.global .Values.global.chain "P2PPort" }}
1616
targetPort: p2p
1717
protocol: TCP
1818
name: p2p
19-
- port: {{ .Values.ZMQTxPort }}
19+
- port: {{ .Values.global.ZMQTxPort }}
2020
targetPort: zmq-tx
2121
protocol: TCP
2222
name: zmq-tx
23-
- port: {{ .Values.ZMQBlockPort }}
23+
- port: {{ .Values.global.ZMQBlockPort }}
2424
targetPort: zmq-block
2525
protocol: TCP
2626
name: zmq-block

resources/charts/bitcoincore/values.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@ securityContext: {}
3333
service:
3434
type: ClusterIP
3535

36-
regtest:
37-
RPCPort: 18443
38-
P2PPort: 18444
39-
40-
signet:
41-
RPCPort: 38332
42-
P2PPort: 38333
43-
44-
ZMQTxPort: 28333
45-
ZMQBlockPort: 28332
46-
4736
ingress:
4837
enabled: false
4938
className: ""
@@ -109,12 +98,23 @@ tolerations: []
10998

11099
affinity: {}
111100

112-
chain: regtest
113-
114101
collectLogs: false
115102
metricsExport: false
116103
prometheusMetricsPort: 9332
117104

105+
# These are values that are propogated to the sub-charts (i.e. lightning nodes)
106+
global:
107+
chain: regtest
108+
regtest:
109+
RPCPort: 18443
110+
P2PPort: 18444
111+
signet:
112+
RPCPort: 38332
113+
P2PPort: 38333
114+
ZMQTxPort: 28333
115+
ZMQBlockPort: 28332
116+
rpcpassword: gn0cchi
117+
118118
baseConfig: |
119119
checkmempool=0
120120
debuglogfile=debug.log
@@ -130,8 +130,6 @@ baseConfig: |
130130
rest=1
131131
# rpcport and zmq endpoints are configured by chain in configmap.yaml
132132
133-
rpcpassword: gn0cchi
134-
135133
config: ""
136134

137135
defaultConfig: ""
@@ -141,3 +139,6 @@ addnode: []
141139
loadSnapshot:
142140
enabled: false
143141
url: ""
142+
143+
ln:
144+
lnd: false

resources/charts/lnd/templates/configmap.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/warnet/deploy.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
FORK_OBSERVER_CHART,
1616
HELM_COMMAND,
1717
INGRESS_HELM_COMMANDS,
18-
LND_CHART_LOCATION,
1918
LOGGING_HELM_COMMANDS,
2019
LOGGING_NAMESPACE,
2120
NAMESPACES_CHART_LOCATION,
@@ -28,7 +27,6 @@
2827
get_default_namespace_or,
2928
get_mission,
3029
get_namespaces_by_type,
31-
get_pod,
3230
wait_for_ingress_controller,
3331
wait_for_pod_ready,
3432
)
@@ -263,10 +261,6 @@ def deploy_network(directory: Path, debug: bool = False, namespace: Optional[str
263261
click.echo(f"Failed to run Helm command: {cmd}")
264262
return
265263

266-
lnd = node.get("lnd")
267-
if lnd:
268-
deploy_lnd(node, namespace)
269-
270264
except Exception as e:
271265
click.echo(f"Error: {e}")
272266
return
@@ -275,43 +269,6 @@ def deploy_network(directory: Path, debug: bool = False, namespace: Optional[str
275269
Path(temp_override_file_path).unlink()
276270

277271

278-
def deploy_lnd(node: object, namespace: str):
279-
node_name = node.get("name")
280-
lnd_name = f"{node_name}-lnd"
281-
282-
tank = get_pod(node_name, namespace)
283-
284-
# A little harsh but for now let's make sure this always works
285-
assert tank
286-
287-
extra_conf = {
288-
"extraLabels": {"chain": tank.metadata.labels["chain"]},
289-
"config": ("\n").join(
290-
[
291-
f"bitcoin.{tank.metadata.labels['chain']}=1",
292-
"bitcoind.rpcuser=user",
293-
f"bitcoind.rpcpass={tank.metadata.labels['rpcpassword']}",
294-
f"bitcoind.rpchost={node_name}:{int(tank.metadata.labels['RPCPort'])}",
295-
f"bitcoind.zmqpubrawblock=tcp://{node_name}:{int(tank.metadata.labels['ZMQBlockPort'])}",
296-
f"bitcoind.zmqpubrawtx=tcp://{node_name}:{int(tank.metadata.labels['ZMQTxPort'])}",
297-
f"alias={lnd_name}",
298-
f"externalhosts={lnd_name}",
299-
f"tlsextradomain={lnd_name}",
300-
]
301-
),
302-
}
303-
304-
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as temp_file:
305-
yaml.dump(extra_conf, temp_file)
306-
extra_conf_file_path = Path(temp_file.name)
307-
308-
cmd = f"{HELM_COMMAND} {lnd_name} {LND_CHART_LOCATION} --namespace {namespace} -f {extra_conf_file_path}"
309-
if not stream_command(cmd):
310-
print(f"Failed to run Helm command: {cmd}")
311-
return
312-
Path(extra_conf_file_path).unlink()
313-
314-
315272
def deploy_namespaces(directory: Path):
316273
namespaces_file_path = directory / NAMESPACES_FILE
317274
defaults_file_path = directory / DEFAULTS_NAMESPACE_FILE

test/data/ln/network.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ nodes:
22
- name: tank-0000
33
addnode:
44
- tank-0001
5-
lnd: true
5+
ln:
6+
lnd: true
7+
68
- name: tank-0001
79
addnode:
810
- tank-0002
9-
lnd: true
11+
ln:
12+
lnd: true
13+
1014
- name: tank-0002
1115
addnode:
1216
- tank-0000
13-
lnd: true
17+
ln:
18+
lnd: true

test/data/signet/node-defaults.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ image:
33
pullPolicy: Always
44
tag: "27.0"
55

6-
chain: signet
6+
global:
7+
chain: signet
78

89
spec:
910
restartPolicy: Never

0 commit comments

Comments
 (0)