Skip to main content

Kustomize for Kubernetes, but in Python

Project description

Build your Kubernetes manifests for Kustomize in Python!

https://img.shields.io/pypi/v/kustomize.svg https://img.shields.io/pypi/pyversions/kustomize.svg https://img.shields.io/travis/yougov/python-kustomize/master.svg

Overview

The reason for this project to exist is to make it easier to create dynamic manifests to be exported for usage in Kubernetes’ “Kustomize” tool. And, by using Python and supporting the “dataclasses” language feature, it also helps reducing boilerplate by encouraging code reuse.

Kustomize, by itself, is already a very powerful tool, and it’s possible to deal with different apps and environments by using the “overlays” approach; but it’s not dynamic enough if you need to define manifests parameters through environment variables, for example. So this project aims to cover that gap.

A complement for Kustomize

This project is by no means a replacement for Kustomize, but rather a complement. The idea is to generate kustomization files from Python files, and then use kubectl apply -k or kustomize build to transform them into final manifests for Kubernetes (even applying them to the cluster).

In other words, the idea is to “compile” Python files into Kustomize files, then just use Kustomize for the rest of the deployment.

Installing

The only mandatory dependency to this project is PyYAML. Besides this, you can have attr installed if you want to use their classes, and, if you’re running on Python 3.6, you can install dataclasses to use them - although this project is tested on Python 3.7 and 3.8 only, it probably runs fine on 3.6.

This package will be available as kustomize; you may install it with pip, for example:

$ pip install kustomize

This will also install PyYAML if it’s not already installed.

Alternatively, you can use any other package manager capable of installing packages from PyPI.

Usage

The summary is:

  1. You write a source directory with Python files representing the Kustomize files (see directories at python-kustomize/tests/fixtures/);

  2. You run:

    $ pykustomize <source-dir> <dest-dir>

    where <dest-dir> will be the directory where Kustomize YAML files will be put at;

  3. Then you can apply the generated Kustomize files into your cluster:

    $ kubectl apply -f <dest-dir>

    and done!

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

kustomize-0.3.0.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

kustomize-0.3.0-py2.py3-none-any.whl (43.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file kustomize-0.3.0.tar.gz.

File metadata

  • Download URL: kustomize-0.3.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.8.0

File hashes

Hashes for kustomize-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2fd3437d223ecc2b4d9daa7be5be4461ceddc85fe1873803164bef168ae584a9
MD5 2ecd363920e54fcd2347ec965a801361
BLAKE2b-256 5797338519b4440d32ee675aa43e123a7f4d93e0aa8d17448e54664f6b5b9e58

See more details on using hashes here.

File details

Details for the file kustomize-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: kustomize-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 43.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.8.0

File hashes

Hashes for kustomize-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 443c0813482b7e50ef983678cd674b17b81089ad30a022a96d96ed8973c8705c
MD5 f59a2ccfe49ada8e2fce8f30aa5f7601
BLAKE2b-256 7e3b13a1e607170a6f7ea72fdc48b8ccef0864a6194c86156530386096a4ead7

See more details on using hashes here.

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