Deploy Flynn on Packet

In this guide we'll walk you through the basics of why you'd want a platform, how to install Flynn on Packet, and the basics of deploying your apps and managing databases.

Why Use a Platform?

Platforms do most of the work of operating your software for you so you can focus on building and improving your applications. A good platform will help you move faster, do more with a smaller team, and better utilize your servers.

There are lots of tools that help with deploying apps, creating and managing containers, virtual machines, networking, database configurations, and scheduling jobs. What sets platforms apart is they offer a complete stack out of the box, so you don't need to learn or configure dozens of tools. You get everything you need for modern devops practices so you can spend time building your own apps rather than building or maintaining infrastructure.

While there are a zillion options, one of our favorites is Flynn—it's modern, opinionated, and super scalable. Want to watch a video version of this guide? Click here.

Key Benefit: High Availability

When you run a cluster of three or more servers, Flynn automatically sets everything up to be highly available. This means that if a server goes down, your apps and all of Flynn's components will recover immediately and keep on working on the remaining servers.

Getting Started

Start installing Flynn by provisioning one or 3+ new servers on Packet to be the servers in your Flynn cluster. They should all be the same type, running Ubuntu 16.04 LTS, and in the same datacenter.

You will also need a Internet-accessible domain name for the cluster (it can be a subdomain) and DNS hosting provider for the domain. For this text we will use an example domain: demo.packetflynn.com.

The Technical Tidbits

Once the servers are up and running, SSH in and set up a firewall to block all external access to the servers with the exception of ports 80, 443, and 22.

Note: if you made some mistake with your installation you can always execute:

$ bash /tmp/install-flynn --clean

this command will clean all your installation and deploy fresh.

After Flynn is installed you need to generate a discovery token on your primary node as identifier for the other nodes in your cluster. In our example, we have the minimum cluster size which is 3 nodes.

Note: The above example is not applicable if you are running a single node Flynn instance.

Then you may start the Flynn daemon on all servers and ensure that all nodes are free from errors.

$ sudo systemctl start flynn-host
$ sudo systemctl status flynn-host

Now that we have a Flynn host running on all these 3 servers. We need to boostrap the cluster with flynn-host bootsrap command. But first, we need to make sure that we have a resolvable domain (or subdomain) with DNS A records pointing to all 3 nodes IP address, and a wildcard domain that is CNAME to the cluster domain.

CLUSTER_DOMAIN is your domain (or subdomain) assigned to your Flynn cluster, you can also specify the number of nodes that you have in the cluster (--min-hosts) which we have 3 and lastly, the discovery token that you have generated earlier.

Note: You only need to run this on your primary node in the cluster. It will schedule jobs on nodes across the cluster as required.

After Bootstrap you should see this message:

Flynn bootstrapping complete. Install the Flynn CLI (see https://flynn.io/docs/cli for instructions) and paste the line below into a terminal window:

The built-in dashboard can be accessed at http://dashboard.demo.packetflynn.com

When you access the dashboard, you will need to install the certificate in your browser before you can proceed and navigate through the other functions. You can refer to the screenshots below on how to install the SSL certificate in your browser, or just simply follow the guide shown in the Flynn dashboard.

The flynn dashboard will now prompt for your login token, which you can find with the following command:

flynn -a dashboard env get LOGIN_TOKEN

Note: You should safe keep the login token generated in the message given above as it will serve as your access to the Dashboard.

Deploying Your First App

Once you have everything setup, you should be ready to deploy your first test app! There are a lot of samples from the repo, but for this particular guide, we will use Go.