Skip to content

Commit 4df0c33

Browse files
committed
move certs from cln nodes to simln
1 parent 814793c commit 4df0c33

File tree

10 files changed

+256
-145
lines changed

10 files changed

+256
-145
lines changed

resources/charts/bitcoincore/charts/cln/templates/configmap.yaml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,13 @@ data:
1111
{{- .Values.config | nindent 4 }}
1212
network={{ .Values.global.chain }}
1313
bind-addr=0.0.0.0:{{ .Values.P2PPort }}
14-
clnrest-port={{ .Values.RestPort }}
1514
bitcoin-rpcconnect={{ include "bitcoincore.fullname" . }}
1615
bitcoin-rpcport={{ index .Values.global .Values.global.chain "RPCPort" }}
1716
bitcoin-rpcpassword={{ .Values.global.rpcpassword }}
1817
alias={{ include "cln.fullname" . }}
19-
announce-addr=dns:{{ include "cln.fullname" . }}:9735
18+
announce-addr=dns:{{ include "cln.fullname" . }}:{{ .Values.P2PPort }}
2019
database-upgrade=true
2120
bitcoin-retry-timeout=600
22-
clnrest-certs=/root/.lightning
23-
tls.cert: |
24-
-----BEGIN CERTIFICATE-----
25-
MIIB8TCCAZagAwIBAgIUJDsR6mmY+TaO9pCfjtotlbOkzJMwCgYIKoZIzj0EAwIw
26-
MjEfMB0GA1UECgwWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEPMA0GA1UEAwwGd2Fy
27-
bmV0MB4XDTI0MTExMTE2NTM1MFoXDTM0MTEwOTE2NTM1MFowMjEfMB0GA1UECgwW
28-
bG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEPMA0GA1UEAwwGd2FybmV0MFkwEwYHKoZI
29-
zj0CAQYIKoZIzj0DAQcDQgAEBVltIvaTlAQI/3FFatTqVflZuZdRJ0SmRMSJrFLP
30-
tp0fxE7hmteSt6gjQriy90fP8j9OJXBNAjt915kLY4zVvqOBiTCBhjAOBgNVHQ8B
31-
Af8EBAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB/zAd
32-
BgNVHQ4EFgQU5d8QMrwhLgTkDjWA+eXZGz+dybUwLwYDVR0RBCgwJoIJbG9jYWxo
33-
b3N0ggEqhwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMAoGCCqGSM49BAMCA0kAMEYC
34-
IQDPofN0fEl5gTwCYhk3nZbjMqJhZ8BsSJ6K8XRhxr7zbwIhAPsgQCFOqUWg632O
35-
NEO53OQ6CIqnpxSskjsFNH4ZBQOE
36-
-----END CERTIFICATE-----
37-
tls.key: |
38-
-----BEGIN EC PRIVATE KEY-----
39-
MHcCAQEEIIcFtWTLQv5JaRRxdkPKkO98OrvgeztbZ7h8Ev/4UbE4oAoGCCqGSM49
40-
AwEHoUQDQgAEBVltIvaTlAQI/3FFatTqVflZuZdRJ0SmRMSJrFLPtp0fxE7hmteS
41-
t6gjQriy90fP8j9OJXBNAjt915kLY4zVvg==
42-
-----END EC PRIVATE KEY-----
4321
---
4422
apiVersion: v1
4523
kind: ConfigMap

resources/charts/bitcoincore/charts/cln/templates/pod.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,10 @@ spec:
3131
- name: p2p
3232
containerPort: {{ .Values.P2PPort }}
3333
protocol: TCP
34-
- name: rest
35-
containerPort: {{ .Values.RestPort }}
36-
protocol: TCP
3734
command:
3835
- /bin/sh
3936
- -c
40-
- |
41-
lightningd --conf=/root/.lightning/config --recover=35b8182d6db5cec40d9bead20607b7c9b91ed89997a290bc0e0f07e5922e4714 &
42-
pid=$!;
43-
sleep 10;
44-
kill $pid;
45-
sleep 1;
37+
- |
4638
lightningd --conf=/root/.lightning/config
4739
livenessProbe:
4840
{{- toYaml .Values.livenessProbe | nindent 8 }}
@@ -59,12 +51,6 @@ spec:
5951
- mountPath: /root/.lightning/config
6052
name: config
6153
subPath: config
62-
- mountPath: /root/.lightning/cert
63-
name: config
64-
subPath: tls.cert
65-
- mountPath: /root/.lightning/key
66-
name: config
67-
subPath: tls.key
6854
{{- with .Values.extraContainers }}
6955
{{- toYaml . | nindent 4 }}
7056
{{- end }}

resources/charts/bitcoincore/charts/cln/templates/service.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,5 @@ spec:
1212
targetPort: p2p
1313
protocol: TCP
1414
name: p2p
15-
- port: {{ .Values.RestPort }}
16-
targetPort: rest
17-
protocol: TCP
18-
name: rest
1915
selector:
2016
{{- include "cln.selectorLabels" . | nindent 4 }}

resources/charts/bitcoincore/charts/cln/values.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,9 @@ affinity: {}
102102

103103
baseConfig: |
104104
log-level=debug
105-
developer
106-
dev-fast-gossip
105+
# developer
106+
# dev-fast-gossip
107107
bitcoin-rpcuser=user
108-
clnrest-host=0.0.0.0
109108
# bitcoind.rpcpass are set in configmap.yaml
110109
111110
config: ""

resources/charts/commander/templates/rbac.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ metadata:
1515
app.kubernetes.io/name: {{ .Chart.Name }}
1616
rules:
1717
- apiGroups: [""]
18-
resources: ["pods", "configmaps"]
19-
verbs: ["get", "list", "watch"]
18+
resources: ["pods", "configmaps", "pods/exec"]
19+
verbs: ["get", "list", "watch", "exec"]
2020
---
2121
apiVersion: rbac.authorization.k8s.io/v1
2222
kind: RoleBinding

resources/plugins/simln/plugin.py

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
get_static_client,
1818
wait_for_init,
1919
write_file_to_container,
20+
read_file_from_container,
2021
)
2122
from warnet.process import run_command
2223

@@ -145,6 +146,8 @@ def _launch_activity(activity: Optional[list[dict]], plugin_dir: str) -> str:
145146
activity_json = _generate_activity_json(activity)
146147
wait_for_init(name, namespace=get_default_namespace(), quiet=True)
147148

149+
#write cert files to container
150+
transfer_cln_certs(name)
148151
if write_file_to_container(
149152
name,
150153
"init",
@@ -162,13 +165,18 @@ def _generate_activity_json(activity: Optional[list[dict]]) -> str:
162165
nodes = []
163166

164167
for i in get_mission(LIGHTNING_MISSION):
165-
name = i.metadata.name
166-
node = {
167-
"id": name,
168-
"address": f"https://{name}:10009",
169-
"macaroon": "/working/admin.macaroon",
170-
"cert": "/working/tls.cert",
171-
}
168+
ln_name = i.metadata.name
169+
port = 10009
170+
node = {"id": ln_name}
171+
if "cln" in ln_name:
172+
port = 9735
173+
node["ca_cert"] = f"/working/{ln_name}-ca.pem"
174+
node["client_cert"] = f"/working/{ln_name}-client.pem"
175+
node["client_key"] = f"/working/{ln_name}-client-key.pem"
176+
else:
177+
node["macaroon"] = "/working/admin.macaroon"
178+
node["cert"] = "/working/tls.cert"
179+
node["address"] = f"{ln_name}:{port}"
172180
nodes.append(node)
173181

174182
if activity:
@@ -178,6 +186,30 @@ def _generate_activity_json(activity: Optional[list[dict]]) -> str:
178186

179187
return json.dumps(data, indent=2)
180188

189+
def transfer_cln_certs(name):
190+
dst_container = "init"
191+
cln_root = "/root/.lightning/regtest"
192+
for i in get_mission(LIGHTNING_MISSION):
193+
ln_name = i.metadata.name
194+
if "cln" in ln_name:
195+
copyfile(ln_name, "cln", f"{cln_root}/ca.pem", name, dst_container, f"/working/{ln_name}-ca.pem")
196+
copyfile(ln_name, "cln", f"{cln_root}/client.pem", name, dst_container, f"/working/{ln_name}-client.pem")
197+
copyfile(ln_name, "cln", f"{cln_root}/client-key.pem", name, dst_container, f"/working/{ln_name}-client-key.pem")
198+
199+
200+
def copyfile(pod_name, src_container, source_path, dst_name, dst_container, dst_path):
201+
namespace=get_default_namespace()
202+
file_data = read_file_from_container(pod_name, source_path, src_container, namespace)
203+
if not write_file_to_container(
204+
dst_name,
205+
dst_container,
206+
dst_path,
207+
file_data,
208+
namespace=namespace,
209+
quiet=True,
210+
):
211+
print(f"Failed to copy {source_path} from {pod_name} to {dst_name}:{dst_path}")
212+
181213

182214
def _sh(pod, method: str, params: tuple[str, ...]) -> str:
183215
namespace = get_default_namespace()

0 commit comments

Comments
 (0)