Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/connection-from-host.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Connection from host

### Using NodePort

To connect to a node from your host machine, you can use the NodePort service type. This exposes the node's desired ports on the host machine, allowing you to connect to them directly.

For example to connect to a Bitcoin Core node using the RPC port, add this to the node's configuration in the network graph definition:

```yaml
nodes:
- name: tank-0001
service:
type: NodePort
rpcNodePort: 30443
```

Then you can connect to the node with `localhost:30443`. Or in non-local cluster `<kubernetes-cluster-ip>:30443`.

All the different port options can be seen in values.yaml files. The exposed port values must be in the range 30000-32767. If left empty, a random port in that range will be assigned by Kubernetes.

To check which ports are open on the host machine, use `kubectl get svc -n <namespace>` and look for the `PORT(S)` column.

### Using port-forward

Alternatively, you can use `kubectl port-forward` command. For example to expose the regtest RPC port of a Bitcoin Core node, run the below. The first port is the local port on your machine, and the second port is the port inside the cluster. You can choose any available local port.

```shell
kubectl port-forward pod/tank-0001 18443:18443
```
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ spec:
targetPort: p2p
protocol: TCP
name: p2p
{{- if and (eq .Values.service.type "NodePort") (.Values.service.p2pNodePort) }}
nodePort: {{ .Values.service.p2pNodePort }}
{{- end }}
- port: {{ .Values.RPCPort }}
targetPort: rpc
protocol: TCP
name: rpc
{{- if and (eq .Values.service.type "NodePort") (.Values.service.rpcNodePort) }}
nodePort: {{ .Values.service.rpcNodePort }}
{{- end }}
- port: {{ .Values.RestPort }}
targetPort: rest
protocol: TCP
name: rest
{{- if and (eq .Values.service.type "NodePort") (.Values.service.restNodePort) }}
nodePort: {{ .Values.service.restNodePort }}
{{- end }}
selector:
{{- include "cln.selectorLabels" . | nindent 4 }}
4 changes: 4 additions & 0 deletions resources/charts/bitcoincore/charts/cln/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ securityContext: {}

service:
type: ClusterIP
# NodePorts are only used if service.type is NodePort, values must be in the range 30000-32767
p2pNodePort:
rpcNodePort:
restNodePort:

P2PPort: 9735
RPCPort: 9736
Expand Down
12 changes: 12 additions & 0 deletions resources/charts/bitcoincore/charts/lnd/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,31 @@ spec:
targetPort: rpc
protocol: TCP
name: rpc
{{- if and (eq .Values.service.type "NodePort") (.Values.service.rpcNodePort) }}
nodePort: {{ .Values.service.rpcNodePort }}
{{- end }}
- port: {{ .Values.P2PPort }}
targetPort: p2p
protocol: TCP
name: p2p
{{- if and (eq .Values.service.type "NodePort") (.Values.service.p2pNodePort) }}
nodePort: {{ .Values.service.p2pNodePort }}
{{- end }}
- port: {{ .Values.RestPort }}
targetPort: rest
protocol: TCP
name: rest
{{- if and (eq .Values.service.type "NodePort") (.Values.service.restNodePort) }}
nodePort: {{ .Values.service.restNodePort }}
{{- end }}
{{- if .Values.metricsExport }}
- port: {{ .Values.prometheusMetricsPort }}
targetPort: prom-metrics
protocol: TCP
name: prometheus-metrics
{{- if and (eq .Values.service.type "NodePort") (.Values.service.prometheusNodePort) }}
nodePort: {{ .Values.service.prometheusNodePort }}
{{- end }}
{{- end }}
selector:
{{- include "lnd.selectorLabels" . | nindent 4 }}
5 changes: 5 additions & 0 deletions resources/charts/bitcoincore/charts/lnd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ securityContext: {}

service:
type: ClusterIP
# NodePorts are only used if service.type is NodePort, values must be in the range 30000-32767
p2pNodePort:
rpcNodePort:
restNodePort:
prometheusNodePort:

RPCPort: 10009
P2PPort: 9735
Expand Down
15 changes: 15 additions & 0 deletions resources/charts/bitcoincore/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,36 @@ spec:
targetPort: rpc
protocol: TCP
name: rpc
{{- if and (eq .Values.service.type "NodePort") (.Values.service.rpcNodePort) }}
nodePort: {{ .Values.service.rpcNodePort }}
{{- end }}
- port: {{ index .Values.global .Values.global.chain "P2PPort" }}
targetPort: p2p
protocol: TCP
name: p2p
{{- if and (eq .Values.service.type "NodePort") (.Values.service.p2pNodePort) }}
nodePort: {{ .Values.service.p2pNodePort }}
{{- end }}
- port: {{ .Values.global.ZMQTxPort }}
targetPort: zmq-tx
protocol: TCP
name: zmq-tx
{{- if and (eq .Values.service.type "NodePort") (.Values.service.zmqTxNodePort) }}
nodePort: {{ .Values.service.zmqTxNodePort }}
{{- end }}
- port: {{ .Values.global.ZMQBlockPort }}
targetPort: zmq-block
protocol: TCP
name: zmq-block
{{- if and (eq .Values.service.type "NodePort") (.Values.service.zmqBlockNodePort) }}
nodePort: {{ .Values.service.zmqBlockNodePort }}
{{- end }}
- port: {{ .Values.prometheusMetricsPort }}
targetPort: prom-metrics
protocol: TCP
name: prometheus-metrics
{{- if and (eq .Values.service.type "NodePort") (.Values.service.prometheusNodePort) }}
nodePort: {{ .Values.service.prometheusNodePort }}
{{- end }}
selector:
{{- include "bitcoincore.selectorLabels" . | nindent 4 }}
6 changes: 6 additions & 0 deletions resources/charts/bitcoincore/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ securityContext: {}

service:
type: ClusterIP
# NodePorts are only used if service.type is NodePort, values must be in the range 30000-32767
p2pNodePort:
rpcNodePort:
zmqTxNodePort:
zmqBlockNodePort:
prometheusNodePort:

ingress:
enabled: false
Expand Down
Loading