GithubHelp home page GithubHelp logo

shammishailaj / compass Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rimusz-lab/compass

0.0 2.0 0.0 20.04 MB

Repeatable, cross-environment Helm deployments.

License: GNU General Public License v3.0

Go 100.00%

compass's Introduction

Compass

Go Report Card

Inspired by bashful, compass is a declarative pipelining and templating tool for Helm. Simply describe how the environment should be setup, and it will chart out a direction for your stack(s). As it is still in early development, please use with caution.

Features

  • Stack Creation / Destruction
  • Chart Dependencies & Variable Requirements
  • Install & Forget Chart
  • Fetch Docker Digest By Tag
  • Pre/Post-Deployment Bash Jobs
  • Explicit or Global Values (Namespace, Release, Version)
  • Derive Values From Extra Init Template
  • Output JSON Values

Installation

go get github.com/gregdhill/compass

Getting Started

We'll need a YAML configuration file I like to call a scroll...

# scroll.yaml
values:
  imageRepo: "docker/image"
  imageTag: "latest"

charts:
  test:
  - release: my-release
    namespace: default
    repo: stable
    name: chart
    template: values.yaml

If you save that as scroll.yaml you'll see that another file named values.yaml is required, so let's go ahead and create that:

# values.yaml
image:
  repository: {{ .imageRepo }}
  tag: {{ .imageTag }}
  pullPolicy: Always

This is designed to mimic the values.yaml required by most Helm charts, but it also allows us to add an extra layer of templating on top. Additional arguments can also be added from a file specified by the -env flag. Let's build what we have so far:

compass scroll.yaml

This will setup stable/chart in namespace default with the name my-release, analogous to:

helm upgrade --install my-release stable/chart --namespace=default --set 'repository="docker/image",tag="latest",pullPolicy=Always'

However the aim here is to simplify multi-chart, multi-environment workflows (i.e. production vs staging).

Advanced

Let's dive into a deeper example:

# scroll.yaml
values:
  imageRepo: "docker/image"
  imageTag: "latest"
  environment: "production"

charts:
  test1:
  - release: my-release-1
    namespace: default
    repo: stable
    name: chart_one
    template: values1.yaml
  test2:
  - release: my-release-2
    namespace: default
    repo: stable
    name: chart_two
    template: values2.yaml
    depends:
    - test1
    jobs:
      after:
      - ./script/publish.sh
# values1.yaml
image:
  repository: {{ .imageRepo }}@sha256
{{ if eq .environment "production" }}
  tag: {{ digest .docker_url .imageRepo "master" "DOCKER_TOKEN" }}
{{ else }}
  tag: {{ digest .docker_url .imageRepo "develop" "DOCKER_TOKEN" }}
{{ end }}

Executing compass scroll.yaml will first prepare two releases with one dependency (test1 -> test2). When rendering the first values template it will traverse the production logic which calls a function named digest on the master tag. This fetches the latest digest for that release tag from the targeted docker API to ensure that Kubernetes collects our most up-to-date image. Once that has finished installing it will trigger the test2 deployment. This has a post deployment job which calls a simple bash script called publish.sh. This will also have access to all values used in the pipeline such as .imageRepo.

To get a quick glimpse of what values are generated from your pipeline, use the following command:

compass scroll.yaml -out

compass's People

Contributors

gregdhill avatar

Watchers

James Cloos avatar Shammi Shailaj avatar

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.