Giter VIP home page Giter VIP logo

kastemais's Introduction

kastemais

Templating similar to kustomize but with multiple overlays

Install prerequisites

This requires yq and yaml-patch

docker build --tag kastemais .

Design

XXX

An application describes the minimum to deploy a service

An overlay contains YAML patches that modify an application with a specific purpose, e.g.

  • Adding namespace
  • Adding labels and annotations
  • Adding resources
  • Adding sidecars

Applications

Stored in a subdirectory of /app, e.g. /app/nginx

Contains one or more YAML documents in one or more files - multiple documents per file a allowed

All files must have a leading document separator ---

Overlays

Stored in a subdirectory if /overlay, e.g. /overlay/sidecar-monitoring

Overlays can be applied to all documents

Overlays can be applied to specific documents using filters

Building blocks

Reading a value from YAML

cat app/nginx/deployment.yaml | docker run -i kastemais yq r - metadata.name

Apply YAML patch

cat app/nginx/deployment.yaml | docker run -i kastemais yaml-patch -o overlay/ci-annotations/patch-all.yaml

This also works for multiple documents:

cat app/nginx/*.yaml | docker run -i kastemais yaml-patch -o overlay/ci-annotations/patch-all.yaml

Add prefix/suffix

NAME=$(./yq r app/nginx/deployment.yaml metadata.name)
cat app/nginx/deployment.yaml | docker run -i kastemais yq w - metadata.name ${NAME}-qa

Filter documents

TODO: How to filter?

Merge into one YAML document in the form (see merge_documents() in functions.sh):

apiVersion: v1
kind: List
items:
- ...
- ...

This is also valid:

apiVersion: v1
kind: List
items:
-
  ...
-
  ...

Handling multiple documents

yq can only operate on numerically indexed documents in a file:

$ cat app/nginx/*.yaml | yq3 -d'*' r - kind
ConfigMap
Deployment
Service

yq can also merge multiple documents within a file when in the correct order (see merge_documents() in functions.sh)

Workaround: Split documents into separate files

$ cat app/nginx/*.yaml | csplit --prefix=document- --suffix-format=%02d.yaml --elide-empty-files --quiet - /---/ '{*}'
$ ls -l document-*.yaml
document-00.yaml  document-01.yaml  document-02.yaml

Package definition

TODO: Description which application from /app and which overlays from /overlay to apply.

Variable substitution

TODO: Is this in scope? If so...

  • Support substitution from environment variables
  • Explicit list of variables to substitute
  • Support .env file?

Workaround: envsubst

kastemais's People

Contributors

nicholasdille avatar

Watchers

James Cloos avatar  avatar  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.