Giter Club home page Giter Club logo

quberneeds's Introduction

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:

{
  "repositories": {
    "myrepo": "https://repo.example.com/"
  },
  "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, 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.