Skip to content

Commit

Permalink
Merge pull request #664 from pinheadmz/ln-helm
Browse files Browse the repository at this point in the history
Restore LN functionality with helm
  • Loading branch information
pinheadmz authored Dec 23, 2024
2 parents 82306a8 + c18298d commit 85ed1d6
Show file tree
Hide file tree
Showing 39 changed files with 1,575 additions and 414 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
- dag_connection_test.py
- graph_test.py
- logging_test.py
- ln_basic_test.py
- ln_test.py
- rpc_test.py
- services_test.py
- signet_test.py
Expand Down
5 changes: 5 additions & 0 deletions resources/charts/bitcoincore/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ apiVersion: v2
name: bitcoincore
description: A Helm chart for Bitcoin Core

dependencies:
- name: lnd
version: 0.1.0
condition: ln.lnd

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
Expand Down
25 changes: 25 additions & 0 deletions resources/charts/bitcoincore/charts/lnd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v2
name: lnd

description: A Helm chart for LND

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 0.1.0
78 changes: 78 additions & 0 deletions resources/charts/bitcoincore/charts/lnd/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{{/*
Expand the name of the PARENT chart.
*/}}
{{- define "bitcoincore.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified PARENT app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "bitcoincore.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}


{{/*
Expand the name of the chart.
*/}}
{{- define "lnd.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}-ln
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "lnd.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}-ln
{{- end }}
{{- end }}

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

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "lnd.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "lnd.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
52 changes: 52 additions & 0 deletions resources/charts/bitcoincore/charts/lnd/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "lnd.fullname" . }}
labels:
{{- include "lnd.labels" . | nindent 4 }}
data:
lnd.conf: |
{{- .Values.baseConfig | nindent 4 }}
{{- .Values.defaultConfig | nindent 4 }}
{{- .Values.config | nindent 4 }}
bitcoin.{{ .Values.global.chain }}=1
bitcoind.rpcpass={{ .Values.global.rpcpassword }}
bitcoind.rpchost={{ include "bitcoincore.fullname" . }}:{{ index .Values.global .Values.global.chain "RPCPort" }}
bitcoind.zmqpubrawblock=tcp://{{ include "bitcoincore.fullname" . }}:{{ .Values.global.ZMQBlockPort }}
bitcoind.zmqpubrawtx=tcp://{{ include "bitcoincore.fullname" . }}:{{ .Values.global.ZMQTxPort }}
alias={{ include "lnd.fullname" . }}
externalhosts={{ include "lnd.fullname" . }}
tlsextradomain={{ include "lnd.fullname" . }}
tls.cert: |
-----BEGIN CERTIFICATE-----
MIIB8TCCAZagAwIBAgIUJDsR6mmY+TaO9pCfjtotlbOkzJMwCgYIKoZIzj0EAwIw
MjEfMB0GA1UECgwWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEPMA0GA1UEAwwGd2Fy
bmV0MB4XDTI0MTExMTE2NTM1MFoXDTM0MTEwOTE2NTM1MFowMjEfMB0GA1UECgwW
bG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEPMA0GA1UEAwwGd2FybmV0MFkwEwYHKoZI
zj0CAQYIKoZIzj0DAQcDQgAEBVltIvaTlAQI/3FFatTqVflZuZdRJ0SmRMSJrFLP
tp0fxE7hmteSt6gjQriy90fP8j9OJXBNAjt915kLY4zVvqOBiTCBhjAOBgNVHQ8B
Af8EBAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB/zAd
BgNVHQ4EFgQU5d8QMrwhLgTkDjWA+eXZGz+dybUwLwYDVR0RBCgwJoIJbG9jYWxo
b3N0ggEqhwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMAoGCCqGSM49BAMCA0kAMEYC
IQDPofN0fEl5gTwCYhk3nZbjMqJhZ8BsSJ6K8XRhxr7zbwIhAPsgQCFOqUWg632O
NEO53OQ6CIqnpxSskjsFNH4ZBQOE
-----END CERTIFICATE-----
tls.key: |
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIIcFtWTLQv5JaRRxdkPKkO98OrvgeztbZ7h8Ev/4UbE4oAoGCCqGSM49
AwEHoUQDQgAEBVltIvaTlAQI/3FFatTqVflZuZdRJ0SmRMSJrFLPtp0fxE7hmteS
t6gjQriy90fP8j9OJXBNAjt915kLY4zVvg==
-----END EC PRIVATE KEY-----
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "lnd.fullname" . }}-channels
labels:
channels: "true"
{{- include "lnd.labels" . | nindent 4 }}
data:
source: {{ include "lnd.fullname" . }}
channels: |
{{ .Values.channels | toJson }}
82 changes: 82 additions & 0 deletions resources/charts/bitcoincore/charts/lnd/templates/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: v1
kind: Pod
metadata:
name: {{ include "lnd.fullname" . }}
labels:
{{- include "lnd.labels" . | nindent 4 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
app: {{ include "lnd.fullname" . }}
{{- if .Values.collectLogs }}
collect_logs: "true"
{{- end }}
chain: {{ .Values.global.chain }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 4 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 4 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: rpc
containerPort: {{ .Values.RPCPort }}
protocol: TCP
- name: p2p
containerPort: {{ .Values.P2PPort }}
protocol: TCP
- name: rest
containerPort: {{ .Values.RestPort }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 8 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 8 }}
startupProbe:
{{- toYaml .Values.startupProbe | nindent 8 }}
resources:
{{- toYaml .Values.resources | nindent 8 }}
volumeMounts:
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 8 }}
{{- end }}
- mountPath: /root/.lnd/lnd.conf
name: config
subPath: lnd.conf
- mountPath: /root/.lnd/tls.key
name: config
subPath: tls.key
- mountPath: /root/.lnd/tls.cert
name: config
subPath: tls.cert
{{- if .Values.circuitBreaker }}
- name: circuitbreaker
image: pinheadmz/circuitbreaker:278737d
imagePullPolicy: IfNotPresent
{{- end}}
volumes:
{{- with .Values.volumes }}
{{- toYaml . | nindent 4 }}
{{- end }}
- configMap:
name: {{ include "lnd.fullname" . }}
name: config
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 4 }}
{{- end }}
24 changes: 24 additions & 0 deletions resources/charts/bitcoincore/charts/lnd/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "lnd.fullname" . }}
labels:
{{- include "lnd.labels" . | nindent 4 }}
app: {{ include "lnd.fullname" . }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.RPCPort }}
targetPort: rpc
protocol: TCP
name: rpc
- port: {{ .Values.P2PPort }}
targetPort: p2p
protocol: TCP
name: p2p
- port: {{ .Values.RestPort }}
targetPort: rest
protocol: TCP
name: rest
selector:
{{- include "lnd.selectorLabels" . | nindent 4 }}
Loading

0 comments on commit 85ed1d6

Please sign in to comment.