Skip to main content

Use Skaffold with Emrichen templates

Project description

Emskaffolden = Emrichen + Skaffold

Emrichen is a template engine that takes in templates written in YAML or JSON, processes tags that do things like variable substitution, and outputs YAML or JSON. Emrichen is especially powerful for templating Kubernetes manifests.

Skaffold is a developer tool that handles the workflow for building, pushing and deploying your application, allowing you to focus on what matters most: writing code. Skaffold is especially good at three things: doing everyday development with Kubernetes, providing a coherent way to do image tagging in CI and watching for Kubernetes deployments to complete in CD.

Emskaffolden combines Emrichen and Skaffold by compiling the Skaffold config file and Kubernetes templates with Emrichen and then invoking Skaffold.

Emskaffolden is opinionated: it may not suit everyone's workflow. If you find Emskaffolden's way of working unsuitable for your needs, you can try to make your case in the issues, but we try to keep the core very small.

Why wrap Skaffold instead of implementing Emrichen support for Skaffold?

  1. Emrichen is a relatively unknown templating tool, so they'd probably never accept a PR integrating Emrichen into Skaffold.
  2. This way we can support any of the Skaffold deploy methods using Emrichen, not just kubectl. You can even go wild and generate Kustomize or even Helm YAML using Emrichen! Err, not sure why you'd want to. But you can.

Installation

Install Skaffold and Python 3.6+. Then install emskaffolden using Pip:

python3 -m pip install emskaffolden

Usage

When you invoke emskaffolden (or the shorthand emsk), it does the following steps:

  1. Compiles skaffold.in.yaml to skaffold.compiled.yaml (change with -F)
  2. Reads skaffold.compiled.yaml, discovers all *.compiled.yaml files referenced there, locates a corresponding *.in.yaml template and compiles it to *.compiled.yaml
  3. Invokes Skaffold with -f skaffold.compiled.yaml and any other parameters you passed to the Emskaffolden command line after --.

Use -- to separate Emrichen and Skaffold options

As a general rule, options before -- go to Emrichen and options after -- go to skaffold. The Skaffold subcommand (or basically any positional arguments) can go on either side of --.

So eg. these two are interchangeable:

emskaffolden run -f kubernetes/staging.vars.yaml -- --default-repo=harbor.con2.fi/con2
emskaffolden -f kubernetes/staging.vars.yaml -- run --default-repo=harbor.con2.fi/con2

are interchangeable and both tell Emrichen to use the kubernetes/staging.vars.yaml var file, and invokes Skaffold with run -f skaffold.compiled.yaml --default-repo=harbor.con2.fi/con2.

On the other hand, if you were to leave out the --, Emskaffolden would complain about --default-repo, which is understood by Skaffold but not Emrichen/Emskaffolden.

Tip: You can use the short form emsk for all commands instead of emskaffolden.

Default and environment-specific var files

A kubernetes/default.vars.yaml var file is loaded from if present.

Environment-specific files are loaded from kubernetes/ if present. The default environment is called development, corresponding to kubernetes/development.vars.yaml, and the environment can be switched with -E <env name>.

If your environment specific var files are elsewhere, use -f path/to/foo.vars.yaml instead.

Workflow

There is no emskaffolden init. Just copy over files from example/ and edit them to your liking. For a real-world example, see Kompassi or Edegal.

Use emskaffolden dev as your everyday development environment – either locally using Docker Desktop, or in the Kubernetes environment of your choice.

Use emskaffolden run in your CI/CD pipeline, or split it into emskaffolden build -- --output-file=build.json and emskaffolden deploy -- -a build.json.

*.compiled.yaml files should not be committed into Git. The .gitignore in example/ excludes them.

License

The MIT License (MIT)

Copyright © 2020 Santtu Pajukanta

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emskaffolden-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

emskaffolden-0.1.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file emskaffolden-0.1.1.tar.gz.

File metadata

  • Download URL: emskaffolden-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.9

File hashes

Hashes for emskaffolden-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0da4b261e6a74b166b4f2732c611e4edce8c1878561726799c3592c7e0efd0ca
MD5 334d79f3cc08d9efd5e334d3fbc7d55c
BLAKE2b-256 2137102d6d8331c2230b976eb9f0b8ba5aca7cff6cf7ca05b8bf94b70e87973f

See more details on using hashes here.

Provenance

File details

Details for the file emskaffolden-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: emskaffolden-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.9

File hashes

Hashes for emskaffolden-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 59c351fdcf25146f41d94a505a0f8cd78115761ead4c0099272f4d7caee6ffbe
MD5 043eba95765b98e7369fb1ff664ddb90
BLAKE2b-256 df1caff1a5272bbb3ff41aacc620cd00e32562c6781859eadd28e21d27f8743b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page