Deploying web applications using Juju on Scaleway | Scaleway


#1

Deploying web applications using Juju on Scaleway

Important

This provider is in “beta” and makes use of manual provisioning. Manual provisioning allows Juju users to implement any cloud provider’s API calls and act similar to a provider implemented in the Juju Core code base. You can access the provider source-code on github

This package provides a CLI plugin for Juju that allows automated provisioning of C1 BareMetal SSD servers on Scaleway.

This plugin is highly inspired from kAPIlt Juju plugin.

Requirements

This process requires you to have a Scaleway account.

Installation

The plugin installation is done via pypi, the Python package manager, available by default on Ubuntu. A virtualenv is also recommended to sandbox this install from your system packages:

pip install -U juju-scaleway

Configuration

Scaleway API keys

Before you can start using Juju with Scaleway, you need to get an API token. API tokens are unique identifiers associated with your Scaleway account.

To get one, open the pull-down menu on your account name and click on “My Credentials” link.

Then, to generate a new token, click the “Create New Token” button on the right corner.

In a terminal, export your credentials required by the plugin using environment variables:

export SCALEWAY_ACCESS_KEY=your_organization_key
export SCALEWAY_SECRET_KEY=your_secret_token

Note

As environment variables are not shared between shells, you will need to repeat this operation for every shell. You can avoid this repetition by adding this environment variables in your shell’s rc files, for instance append them to your ~/.bashrc or ~/.zshrc

Juju configuration

The next step is to add an environment for Scaleway in your '~/.juju/environments.yaml'. This environment looks like the following:

# https://jujucharms.com/docs/config-scaleway.html
    scaleway:
        type: manual
        bootstrap-host: null
        bootstrap-user: root

Then, you have to tell Juju which environment to use. To do this, in a terminal use the following command:

export JUJU_ENV=scaleway

To set Scaleway as your default provider, run the following command in your terminal:

juju switch scaleway

Bootstrapping

Now you can bootstrap your Scaleway environment. You need to route the command through the scaleway plugin that we installed via pip.

juju scaleway bootstrap

All machines created by this plugin will have the Juju environment name as a prefix for their servers name, for instance scaleway-XXXYYYZZZ

After your environment is bootstrapped you can add additional machines to it via the add-machine command, for instance the following will add 2 additional machines:

juju scaleway add-machine -n 2
juju status

You can now use standard Juju commands to deploy service workloads (also known as charms):

juju deploy wordpress

If you don’t specify a machine to place the workload on, the machine will automatically go to an unused machine within the environment.

You can use manual placement to deploy target particular machines:

juju deploy mysql --to=2

This command deploys a MySQL unit to the server number #2.

Assemble these workloads together via relations like lego blocks:

juju add-relation wordpress mysql

You can list all machines in Scaleway that are part of the Juju environment with the list-machines command. This directly queries the Scaleway API and does not interact with the Juju API.

juju scaleway list-machines
Id       Name               Status   Created      Address
6222349  scaleway-0            active   2014-11-25   212.47.239.232
6342360  scaleway-ef19ad5cc... active   2014-11-25   212.47.228.28
2224321  scaleway-145bf7a80... active   2014-11-25   212.47.228.79

You can terminate allocated machines via their machine id. By default, the Scaleway plugin forces the terminatiom of machines, which also terminates any service unit running on on those machines:

juju scaleway terminate-machine 1 2

And you can destroy the entire environment via:

juju scaleway destroy-environment

destroy-environment also takes a –force option which only uses the Scaleway API. It’s helpful if the state server or other machines are killed independently of Juju.

Try this tutorial on your own C1 server TRY IT


This is a companion discussion topic for the original entry at https://www.scaleway.com/docs/deploying-web-applications-using-juju-on-scaleway/

#2

Just a heads up, the Juju configuration is somewhat under documented
(Lacking a section for fixes to common problems and some information
about how to get all the python requirements) and I am having trouble
getting it working.


#3

@madmooshroomgaming

Is completely right. 2 facts:

  1. This should be a shell script
  2. I can’t get it running.

#4

I too had a few problems setting this up, the missing bit is you need to install

libffi-dev and libssl-dev

Juju’s own guide for setting up Scaleway as a provider


#5

does anyone have any idea how to teach Juju to launch VC1 instances instead of C1?


#6

Juju integration with Scaleway lacks a lot.