Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ Monitor and analyze the emergent behaviors of Bitcoin networks.
- [Data Collection](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/data.md)
- [Monitoring](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/monitoring.md)
- [Lightning Network](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/lightning.md)
- [Connecting to local nodes](https://github.com/bitcoin-dev-project/warnet/blob/main/docs/connecting-local-nodes.md)

![warnet-art](https://raw.githubusercontent.com/bitcoin-dev-project/warnet/main/docs/machines.webp)
88 changes: 88 additions & 0 deletions docs/connecting-local-nodes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Connecting Local Nodes

## Connections from cluster into local machine

[Telepresence](https://github.com/telepresenceio/telepresence) can be used to make a connection from the cluster to your local machine. Telepresence is designed to intercept cluster commmunication and forward it to your local machine so we will have to install a dummy pod and service to receive the traffic that will get forwarded.

### Run Warnet network

```shell
warcli cluster deploy
warcli network start
```

### Install Telepresence

Install the open source version of Telepresence.

```shell
# find path to most recent release for your architecture and OS
# https://github.com/telepresenceio/telepresence/releases
wget [URL of release]
# assuming AMD64 linux binary (replace as needed)
sudo mv telepresence-linux-amd64 /usr/local/bin/telepresence
sudo chmod +x /usr/local/bin/telepresence
telepresence version
```

If on Mac OS you may need to remove telepresence from quarantine

```shell
sudo xattr -d com.apple.quarantine /usr/local/bin/telepresence
```

### Connect Telepresence to your cluster

```shell
telepresence helm install
telepresence connect
```

`telepresence version` should now show something like this:

```shell
OSS Client : v2.19.1
OSS Root Daemon : v2.19.1
OSS User Daemon : v2.19.1
OSS Traffic Manager: v2.19.1
Traffic Agent : docker.io/datawire/tel2:2.19.1
```

### Run a dummy pod and service to intercept

In this example we are installing a nginx pod but any image should work as the network traffic will not actually arrive at this pod and will instead be redirected to your local machine.

```shell
# Image here can be anything. Just picking a popular image.
kubectl create deploy local-bitcoind --image=registry.k8s.io/nginx
kubectl expose deploy local-bitcoind --port 18444 --target-port 18444
```

### Instruct Telepresence to intercept traffic to the dummy pod

The intercept command starts the process that will recieve the traffic. In this case, bitcoind process.

```shell
mkdir /tmp/connect
# Assumes you have bitcoind installed and available on the PATH
telepresence intercept local-bitcoind --port 18444 -- bitcoind --regtest --datadir=/tmp/connect
```

### Connect to local bitcoind from cluster

```shell
warcli bitcoin rpc 0 addnode "local-bitcoind:18444" "onetry"
# Check that the local node was added
warcli bitcoin rpc 0 getpeerinfo
```

### Disconnect and remove Telepresence

```shell
# Disconnect from the cluster
telepresence quit -s
# Remove Telepresence from the cluster
telepresent helm uninstall
# Remove Telepresence from your computer
sudo rm /usr/local/bin/telepresence
```