Create a standard bundle keeping model-specific configuration in a separate file

If you want to create a bundle without hardcoding inside it specific configuration you can do following instructions below.

Create two file, namely, a bundle.yaml and a bundle-config.yaml (you can name these two file as you prefer). In the first one you can write your bundle as you always did, but without specific configurations which can be put in the latter file, i.e., the configuratin file, following the specific instructions.

Configuration file structure

In this file you have two sections:

  • 1 parameters to declare a parameter and
  • 2 applications where you use the previously declared parameter in a specific application.

Let’s see the details:

Parameter section

In this section you declare all the parameters you will use in the application sections following the syntax below:

parameters:

    <key>: &<parameter-name>                           <value>

Application section

In this section you will use all the parameters you defined in the previous section following the syntax below:

applications:

    <application-name>:
        <the name of the configuration you want to set>: *<parameter-name>

Example

In the bundle.yaml:

applications:

    kubernetes-master:
        charm: cs:~containers/kubernetes-master
        num_units: 1
        options:
            authorization-mode: Node,RBAC
        to:
            - "0"

In the bundle-config.yaml:

parameters:
    #Services Settings
    default-net: &default_net                   space_default
    channel: &channel                           1.8/stable

applications:

    kubernetes-master:
        bindings:
            "": *default_net
        options:
            channel: *channel

Pay attention that parameters declared in the bundle-config.yaml does not appear in the bundle. To have a complete view you need both the files.

Deploy

The instruction for deployng the bundle with the configuration file is:

juju deploy ./<bundle.yaml> --overlay <bundle-config.yaml>

Limitations

Remember that the configuration file must be self-contained: in the bundle file you can never explicitely use a parameter defined in the configuration file otherwise the deploy will fail.