How to Start Supergiant Server as a Service on Ubuntu

Posted by Brian Sage on November 7, 2016

By the end of this tutorial, you will have Supergiant running as a service using systemd on Ubuntu server 16.04 (really 15.04 and later).

To keep things simple, we will use Vagrant to stand up Ubuntu server, but if that doesn’t work for you, feel free to use whatever means you have available. It’s my hope to keep these instructions pretty simple and portable between AWS EC2, DigitalOceanOpenStack, VirtualBox, or anywhere else you can easily stand up an instance of the popular Ubuntu server. 

Running Supergiant as a Service

To reduce our cloud expenses, we created Supergiant to auto-scale hardware for our many Kubernetes clusters to reduce our cloud expenses. When computing needs go up, Supergiant ensures there is enough hardware to get the job done. When computing needs go down, Supergiant de-provisions nodes, greatly trimming costs.

In order to do this, we run Supergiant as a service, and this tutorial is designed to show you the fastest way to get there in as few steps as possible, so you can try it out, too.

Step 1: Ubuntu 16.04

Just in case you don’t have access to an Ubuntu 16.04 server, here is a quick way to use Vagrant and VirtualBox to stand one up locally. If you already have a test box, feel free to skip to the next step.

Install Vagrant and VirtualBox open-source applications, and then execute the following:

vagrant init gbarbieru/xenial

Edit the Vagrantfile to allow the new VM to receive an IP address from your router.

Vagrant.configure("2") do |config|
  ...
  config.vm.network "private_network", type: "dhcp"
  ...
end

Next, execute the following to startup (it might take a while to download Ubuntu your first time) and connect to your new Ubuntu server:

vagrant up && vagrant ssh

NOTE: Windows users may need to install ssh.exe in their system path.

Step 2: Get Supergiant

As of this tutorial, the most recent Supergiant release is 0.12.0, and that’s the version I’ve linked below. Always check the Supergiant latest release page for the current server binary URL.

Execute the following, which will download the Supergiant server binary to your /usr/sbin/ directory:

sudo curl https://github.com/supergiant/supergiant/releases/download/v0.12.0/supergiant-server-linux-amd64 -L -o /usr/bin/supergiant

Be sure to make the binary executable.

sudo chmod +x /usr/bin/supergiant

Step 3: Configure Supergiant

We will grab the example configuration file from github and put it in a responsible place. We don’t recommend using these default settings in production, but the configuration will work as-is for quick-start and testing purposes.

Execute the following to download the example configuration file:

sudo curl https://raw.githubusercontent.com/supergiant/supergiant/master/config/config.json.example --create-dirs -o /etc/supergiant/config.json

Use your favorite text editor to change the following configuration parameters in config.json to fit our Ubuntu environment:

{
  ...
  "sqlite_file": "/var/lib/supergiant/development.db",
  ...
  "log_file": "/var/log/supergiant/development.log",
  ...
}

Next create the directories we just referenced, so Supergiant can write its DB and log files:

sudo mkdir /var/lib/supergiant && sudo mkdir /var/log/supergiant

Next configure systemd to start Supergiant as a service. Use your favorite editor to create the following init file in /etc/systemd/system/supergiant.service:

[Unit]
Description=Supergiant Server
After=syslog.target
After=network.target
[Service]
ExecStart=/usr/bin/supergiant --config-file /etc/supergiant/config.json
Restart=on-abort
[Install]
WantedBy=multi-user.target

Step 4: Create an Admin User

The first time Supergiant runs, an admin user will be created, and the service will output the username and password to the console.

Execute the following in the terminal to test your configuration and create your admin user:

sudo supergiant --config-file /etc/supergiant/config.json

Save the randomly generated password, so you can access the dashboard later. Type Control+C to stop the server after the user is created.

If you have any trouble by this point, please join us on our Slack channel.

Step 5: Start Your Supergiant Server

Start your new Supergiant system service like so:

sudo systemctl start supergiant.service

In this case, no news is good news. The system shouldn't produce any output if this is successful.

To check the status of the service, you may execute the following:

sudo systemctl status supergiant.service

Last, enable the service to start on bootup:

sudo systemctl enable supergiant.service

Access your Supergiant Dashboard

By default, Supergiant serves HTTP over port 8080, and Ubuntu’s simple firewall is off by default. To access the dashboard, simply get the IP of our server and then open it up in a web browser.

From within your Vagrant VM console type ifconfig and hit Enter. In the console output, it’s likely eth1 will be the IP address assigned by your router.

Put the IP, followed by the port number:8080 in a web browser to access your Supergiant dashboard on its default port (or whatever port you may have customized in your config.json file above), then use the username "admin" and the password generated above to log in.

That’s it!

You’ve successfully created a Supergiant server that runs as a service. For greater security, we recommend creating a new admin user, logging in as that user, and then deleting the account named "admin".

Access the Supergiant Community

Remember, if you have trouble, or if you want to talk to other users about how they're making the most of Supergiant, our community hangs out on the Supergiant public Slack channel.

We would love any feedback you want to leave. We're working hard to add features that our community wants most, so all your comments are helpful to us. Visit the Supergiant Slack channel, and post your questions and comments.

Whereto Next?

This tutorial is one in a series to help you get started with Kubernetes using Supergiant. From here we recommend you check out the following:

comments powered by Disqus