Skip to content

Commit c1c7009

Browse files
committed
create initContainer for loading snapshots
if key is set, download and untar a blocks directory into the bitcoin datadir. its up to the user to make sure they are choosing an appropriate snapshot, e.g., if the snapshot was created from a signet chain then it can only be loaded into a signet node with the correct signet challenge. we can expand on this in the future to better export all of the relevant config details in the snapshot, but for now this just adds the ability to load files into pods before the pod starts.
1 parent 1da2547 commit c1c7009

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

resources/charts/bitcoincore/templates/pod.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ spec:
2323
{{- end }}
2424
securityContext:
2525
{{- toYaml .Values.podSecurityContext | nindent 4 }}
26+
{{- if .Values.loadSnapshot.enabled }}
27+
initContainers:
28+
- name: download-blocks
29+
image: alpine:latest
30+
command: ["/bin/sh", "-c"]
31+
args:
32+
- |
33+
apk add --no-cache curl
34+
mkdir -p /root/.bitcoin/{{ .Values.chain }}
35+
curl -L {{ .Values.loadSnapshot.url }} | tar -xz -C /root/.bitcoin/{{ .Values.chain }}
36+
volumeMounts:
37+
- name: data
38+
mountPath: /root/.bitcoin
39+
{{- end }}
2640
containers:
2741
- name: {{ .Chart.Name }}
2842
securityContext:
@@ -54,6 +68,8 @@ spec:
5468
{{- with .Values.volumeMounts }}
5569
{{- toYaml . | nindent 8 }}
5670
{{- end }}
71+
- mountPath: /root/.bitcoin
72+
name: data
5773
- mountPath: /root/.bitcoin/bitcoin.conf
5874
name: config
5975
subPath: bitcoin.conf
@@ -83,9 +99,11 @@ spec:
8399
{{- with .Values.volumes }}
84100
{{- toYaml . | nindent 4 }}
85101
{{- end }}
86-
- configMap:
102+
- name: data
103+
emptyDir: {}
104+
- name: config
105+
configMap:
87106
name: {{ include "bitcoincore.fullname" . }}
88-
name: config
89107
{{- with .Values.nodeSelector }}
90108
nodeSelector:
91109
{{- toYaml . | nindent 4 }}

resources/charts/bitcoincore/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,6 @@ baseConfig: |
134134
config: ""
135135

136136
connect: []
137+
loadSnapshot:
138+
enabled: false
139+
url: ""

0 commit comments

Comments
 (0)