How to Install Kontena to DigitalOcean

Important! This tutorial is made for early versions of Kontena. If you are running the latest release, please see more easy way to install Kontena to Digital Ocean

This tutorial goes through step-by-step what are needed to install complete Kontena cluster setup to DigitalOcean. We will install one Kontena server and three host nodes with Kontena agent.

Install Kontena server

Before we can setup Docker host nodes, we need to setup Kontena Server. It's is very straightforward process.

1. Create DigitalOcean Droplet

First we have to login to DigitalOcean. After that we are ready to create our first droplet.

Click Create Droplet button and give some host name to your droplet:

For testing purposes the smallest Droplet size is enough but in real production setup it is recommended to take a larger one.

For the Region selection and Available settings you can select what is best for your needs.
DigitalOcean has a pre-configured application image where Docker is built-in so we want to use it.

By adding SSH keys it is possible to login to server via SSH without password.

Now we are ready to create our first Droplet by clicking Create Droplet button.

Creating droplet takes approx. 1 minute.

2. Install Kontena Server Ubuntu Packages

After the droplet is created we can login to our server with SSH keys or root user password. First we will install Kontena Server packages:

$ echo "deb http://dl.bintray.com/kontena/kontena /" | sudo tee -a /etc/apt/sources.list 
$ sudo apt-get update 
$ sudo apt-get install kontena-server

3. Setup SSL Certificate (Optional)

If you are setting up a production environment you might want to add SSL certificate to Kontena Server. You can do this by editing kontena-server-haproxy config:

$ sudo vim /etc/default/kontena-server-haproxy  
HAProxy SSL certificate SSL_CERT=/path/to/certificate.pem  

3. Start Kontena Server

Now we have installed Kontena Server and we can start it:

$ sudo start kontena-server-api

Server will now start to listen port 8080 or 8443 if you configured SSL certificate

Create Grid for Node Cluster

After we have installed Kontena Server we will create our first Grid where our Kontena Agents can establish connection and build up a cluster of host nodes

1. Install Kontena CLI

In order to create the first grid we have to install Kontena CLI first. If you have not Ruby environment installed, please install it first.

To install Kontena CLI we just install kontena-cli gem:

$ gem install kontena-cli

2. Connect and Configure Grid

Now after we have installed Kontena Server and Kontena Cli, we can create our first grid. First we will connect to Kontena Server that we have just created:

$ kontena connect http://<your_server_address>:8080 # use https and 8443 port if you configured ssl certificate

If you don’t have Kontena Account already, create it first:

$ kontena register

Then we will login to Kontena Server

$ kontena login

Now we are ready to create our first grid:

$ kontena grid create first-grid 
$ kontena grid use first-grid 
$ kontena grid current 
first-grid:  
   token: <grid_token>
   users: 1
   nodes: 0
   containers: 0 

Install Kontena Agents

We have now Kontena Server up and running and it's waiting connections from host nodes. So we can add Docker host nodes with Kontena Agents to our cluster.

1. Create DigitalOcean Droplet

First we need to create a DigitalOcean droplet for each node.

Repeat the same steps which we did while creating Kontena Server droplet. Because we are running our Docker containers in these nodes consider picking up larger size for these droplets. For testing purpose 1Gb droplet size is sufficient.

2. Install Kontena Agent Ubuntu package

After droplet creation is finished, we will login to server via SSH and install Kontena Agent package:

$ wget -qO - https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add - 
$ echo "deb http://dl.bintray.com/kontena/kontena /" | sudo tee -a /etc/apt/sources.list 
$ sudo apt-get update 
$ sudo apt-get install kontena-agent

3. Configure Agent

During installation process we can configure Kontena Agent:

First we need to define Address of Kontena Server. Type the address of just created Kontena Server. Use ws protocol and port 8080( or wss and 8443 if you configured SSL certificate).

Then you need to provide Grid token. Use the token you got when created the first grid.

Then give the number of node you are creating, 1 for the first agent droplet, 2 for the second etc.

4. Restart Docker

After installation process we will just restart Docker:

$ sudo restart docker

5. Verify That Agents Are Connected to Server

Now we have created Kontena Server and one Kontena Agent. We can verify that connection between server and agent is established by running the following command with Kontena CLI:

$ kontena node list

It should show a list of connected nodes:

Name         OS                   Driver     Labels      Status  
agent-1      Ubuntu 14.04.1 LTS   aufs       -           online  

Now we have to create second and third nodes as well by repeating Kontena Agent Installation steps (1-5).

Start using Kontena Server

Now everything is ready and we can start deploying your applications to your grid. To deploy an example application, please see this tutorial:
http://blog.kontena.io/automate-deployments-with-kontena-deploy/

Cover image: NOAA's National Ocean Service