ALL THINGS KUBERNETES

Installing and Autoscaling Supergiant on GCE

In this tutorial, we’ll guide you through the process of installing Supergiant and autoscaling your Kubernetes cluster on Google Compute Engine. Your cloud hardware will autoscale according to the parameters you set to keep costs as low as possible. When you launch a Kube with Supergiant, the system will immediately use Supergiant’s packing algorithm specifically designed to automatically handle the work of scaling up and scaling down for you. Sounds promising? Yes, it is.

For this tutorial, you will need:

  • A GCE account and a running GCE Virtual Machine (VM) instance. You will need only the instances with 512MB/1CPU size to run Supergiant as a service. When creating a Kubernetes master, Supergiant internally defaults to n1-standard-1. For this tutorial, we’ve selected Ubuntu 16.04 Xenial as the OS to be run on the n1-standard-1 instance.
  • A GCP Service account with full administrator access and a secret key for your instance. Each VM instance is mounted with the default service account. However, you’ll need to create a cloud service secret key manually if it does not yet exist.
  • SSH Public Keys for Supergiant to securely access your GCE instances

Installing Supergiant on your GCE Instance

Step 1. Connect to your Instance

To install Supergiant, you first need to connect to your GCE instance using Google Cloud Platform console or gcloud console tool. Consult a simple guide provided by the Google Cloud for the steps to do this.

Step 2. Get the Latest Supergiant Release

After you have connected to the instance, get the latest stable release of Supergiant:

The command above downloads the latest stable release of Supergiant from GitHub and saves it to /user/bin/supergiant folder of your GCE instance.

Make sure to make the downloaded binary executable.

Step 3. Configure Supergiant

Next, configure your Supergiant service. To do this, grab the example configuration from Supergiant’s GitHub repository. (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 command to download the configuration file:

Then use your favorite text editor to change the log and database file locations in config.json to fit your Ubuntu environment.

You can see that the configuration file also contains other useful features like Supergiant public host, port, and default parameters of GCE instances for your future Kubes.

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

To start Supergiant as a service, you also need to configure Ubuntu systemd. Use your favorite editor to create the following init file in /etc/systemd/system/supergiant.service .

Step 4. Create an Admin User

The first time Supergiant runs, the system will create an admin user and output the username and password to the console. Execute the following command in the terminal to test your configuration and create your admin user:

Then save the randomly generated password to access the Supergiant dashboard later. Type Control + C to stop the server after the user is created.

Step 5. Start your Supergiant Server

Now you are ready to start your new Supergiant system service like this:

If everything is fine, the system shouldn’t produce any output. To check the status of the service, you may also execute the following:

It’s a good idea to enable the service to start on boot-up:

Step 6. Access your Supergiant Dashboard on GCE

Supergiant serves HTTP over port 8080 by default. You need to verify that your GCE instance has http traffic enabled and 8080 port opened. If not, add new Firewall rules for port:8080 under “VPC network/Firewall rules” in your GCP console. After you verify that all needed ports are opened, simply get the public IP of your instance from GCE instances list, and put the IP followed by the port number: 8080 to access your Supergiant dashboard on its default port (or whatever port you have specified in your config.json file). After the dashboard has downloaded, put in “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 development purposes! Check out the view of your Supergiant dashboard below.

Supergiant Dashboard

Step 7. Link a GCE Cloud Account

You next need to create a new GCE cloud account by adding GCE cloud credentials, so click ”Cloud Accounts”, then “New”, and select GCE from the dropdown list. You’ll see the following JSON template with placeholders for cloud credentials.

To get these credentials, you should have a GCE service account and a service account key generated to establish its identity. In general, a service account is an identity with which an instance or an application is running, and you need it to identify your instances and applications to other GCP services (e.g., block storage). You can find your default service account under IAM & Admin/Service accounts section of the Google Cloud Console. If there is no service account key for your account, you should generate it. The GCP will create a simple JSON file with all credentials you need to set up GCE account in Supergiant.

The file should look like this:

After downloading, save the file in a safe place because it cannot be restored. Just paste necessary information from this file and copy it into your Supergiant template. If everything is fine, you’ll get something like this in your Supergiant “Cloud Accounts” window:

Step 8. Create Your Kube and Autoscale It

Now that you have created your brand new GCE account, you can add a Kube to your GCE virtual instance. To create one, click Kubes/New and select GCE in the dropdown list. You’ll see some values pre-populated for you.

Supergiant: create GCE cluster

Edit whatever you like, but be sure to edit or review the following entries:

  • “cloud_account_name”: The name of the Cloud Account you created above.
  • “ssh_pub_key”: Your public SSH key that may be found in your GCP console Metadata/SSH keys.
  • “zone”: The region you would like to launch your Kubernetes cluster. All GCE regions support block storage.
  • “master_node_size”: The instance size for your Kubernetes master; the value you enter here will depend on what options are available to your Supergiant configuration JSON file; 512MB of RAM is sufficient.
  • “name”: A name for your Kube that starts with a letter, limited to 12 characters, made of lowercase letters, numbers, and/or dashes (-).
  • “node_sizes”: An array of GCE node sizes chosen from sizes contained in the Supergiant configuration file.

This list will be used to provision hardware for autoscaling Kubernetes.

My configuration looks like this:

When your edits are complete, click Create.

Step 9. Watch Supergiant Go!

After you click the button, you’ll see a green spinner indicating that Supergiant is provisioning your Kube. Supergiant will orchestrate provisioning of GCE services, including block storage, security settings, networking, and more. The longest wait time will be “waiting for Kubernetes” as you wait for the GCE instance to be provisioned. The process may take up to 5-7 minutes, but be patient. When it is finished, you’ll see new Kubernetes master and minion instances in your GCE console.

Step 10. Access Kubernetes

Once the provisioning process is completed, click on the Kube ID to get details. To verify Kubernetes is running, get the username, password, and master_public_ip from the Kube details in the Supergiant dashboard.

You should see a JSON file like this when you click on the newly installed Kube:

From your terminal, run the following command:

You should see a JSON response describing the Kubernetes API.

Congratulations! You have just launched an autoscaling Kubernetes cluster on GCE!

Teardown

If you want to delete your tutorial Kube from the Supergiant dashboard, simply click on Kubes, select the one you’d like to delete, and then choose Delete from the Actions menu. It’s as simple as that. Supergiant will clean up after itself and remove all the associated GCE services linked to the Kube.

Subscribe to our newsletter