At Revelry, we believe in sharing and learning from one another (beliefs that are rooted in our Core Values). Among the many things we do to encourage internal knowledge exchange is to have a different team member present at each week’s Engineering Meeting. These presentations don’t have to be lengthy, formal, or complicated; in fact, many are brief, but also powerful in that they teach our Revelers something new, inspire conversation, and encourage collaboration.
In the spirit of sharing, we share our This Week I Learned presentations (aka RevTWILs”) here. We hope you find them helpful.
THIS WEEK: Director of Engineering Jason Pollentier digs into connecting to a Live Fly.io app with LiveBook and Wireguard.
The App Needs to be Configured for Clustering and Deployed to Fly
- The app needs to be running a recent version of Elixir.
- It needs to have an Erlang node name set (and you need to know what it is).
- It needs IPv6 networking.
- It needs a “cookie” set (and you need to know what it is). This is basically a password for Erlang networking.
I used the silly app that I’d built previously to measure latency between Fly.io regions: https://pingme.fly.dev/ https://github.com/grossvogel/pingme
Configure LiveBook
If you’re running LiveBook Desktop, there are some environment variables you can set in ~/.livebookdesktop.sh
. they correspond to the same IPv6 and node name settings we configured for the app. If you’re launching LiveBook from terminal instead, you can set these same env variables the usual way.
# BEGIN fly.io remote connection settings
export LIVEBOOK_DISTRIBUTION=name
export ERL_AFLAGS="-proto_dist inet6_tcp"
# END fly.io remote connection settings
Create a Wireguard Configuration
- This registers a new client with Fly’s Wireguard network and gives you the credentials to identify yourself as that client and connect.
- Note that there is one network per Fly.io Organization, so this will give you access to all of the apps in that organization.
fly wireguard create personal atl fly-personal-jason
Import the Config and Connect Using the Wireguard Client
There is a simple, easy to use GUI client for MacOS (and other systems). https://www.wireguard.com/install/
Get the Node Name to Connect to
With the pingme app, we can just visit the web UI to find out the node names, e.g. pingme@fdaa:0:6214:a7b:a062:4e32:7f29:2. Your app probably doesn’t expose node names in a GUI, so one quick way to find a node name is to use fly ssh console -a YOUR_APP
and then either shell into your release or grab the ipv6 address using grep fly-local-6pn /etc/hosts
Connect!
- LiveBook will automatically connect to a standalone local node when you launch a notebook. If you disconnect, you can configure how to connect.
- Enter the node name and cookie to connect. We’re inside the existing node here – not in a new node in the same cluster (just like when we use the remote release command on a node to connect to a running app).
Bonus
- We can use the Fly.io Wireguard config as an entry point to understand Wireguard’s cryptokey routing system in general: https://www.wireguard.com/#cryptokey-routing
- We can also use the Wireguard config to connect fly.io apps to an RDS database. It sounds like performance can be pretty good depending on your region. Fly claims iad is only 1ms from us-east-1.
- Much of this information came from Fly.io. Learn more in there Advanced Guides.
We're building an AI-powered Product Operations Cloud, leveraging AI in almost every aspect of the software delivery lifecycle. Want to test drive it with us? Join the ProdOps party at ProdOps.ai.