Skip to content

eicnix/Quberneeds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quberneeds

Quberneeds is a small Python script that downloads Helm charts and runs helmfiles embedded inside them.

Typically, a helmfile.yaml is not placed inside a Helm chart. Instead it is used to declaratively deploy one or more charts.
However, for use with Quberneeds helmfile.yamls are instead placed inside the chart they deploy (referencing the chart with ./). Rather than using helmfile to group multiple charts together, here its primary purpose is to map environment variables to Helm values. This is required because Helm itself does not allow templating inside Values Files.

Quberneeds input

Quberneeds takes a JSON file as input. This file lists a set of charts to download and install and a set of environment variables to set. It looks like this:

{
  "charts": {
    "myrepo/mychart": "1.0.0",
    "myrepo/otherchart": "1.0.0"
  },
  "env": {
    "SOME_VAR": "some-value",
    "OTHER_VAR": "other-value"
  }
}

Chart structure

A Helm chart contains a Chart.yaml for metadata and a values.yaml for configuration in its root directory.
For use with Quberneeds you also need to place a helmfile.yaml here. It could look something like this:

releases:
  - name: '{{ requiredEnv "TENANT_ID" }}-myasset'
    namespace: '{{ requiredEnv "TENANT_ID" }}'
    chart: ./

    values:
      - someConfig:
          config1: '{{ requiredEnv "MYASSET_CONFIG1" }}'
          config2: '{{ env "MYASSET_CONFIG2" | default "default-val" }}'

As you can see, the helmfile.yaml allows you to extend or override the static configuration from values.yaml with templated values using environment variables.

Exported environment variables

If you create a subdirectory inside a Helm chart named exports the contents of all files inside that directory will be picked up by Quberneeds and used as additional environment variables. The variable names are generated by stripping the file endings and converting the remaining name to upper-case characters. If multiple charts export the same environment variable the values are concatenated and comma-separated. All exported environment variables are set for all charts.

This mechanism can be used as a form of static service discovery or dependency injection. For example, a set of "application" charts can each have a exports/apps.json file with metadata in their charts and a central "portal" application can consume them all via the environment variable APPS, as long as they are all deployed together in one Quberneeds run.

Usage

Quberneeds takes a command (install or delete) and the path to a JSON file as command-line arguments. It can either be run from Git or using Zero Install to handle dependencies.

Run from Git

Clone this Git repository, ensure that python, kubectl, helm and helmfile are in your PATH and then run:

cd src
python quberneeds.py (install|delete) file.json

Run using Zero Install

Ensure 0install is in your PATH and then run:

0alias quberneeds http://assets.axoom.cloud/tools/quberneeds.xml
quberneeds (install|delete) file.json

Releasing

To package a new release of Quberneeds as a Zero Install feed run:

0install run http://0install.net/tools/0template.xml quberneeds.xml.template version=0.1

About

runs helmfiles embedded in Helm charts

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages