Skip to main content

Kustomize for Kubernetes, but in Python

Project description

https://img.shields.io/pypi/v/kustomize.svg https://img.shields.io/pypi/pyversions/kustomize.svg tests Ruff https://img.shields.io/badge/skeleton-2024-informational

Build your Kubernetes manifests for Kustomize in Python!

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. This library supports a number of object definition types:

  • dict

  • dataclasses

  • attr (needs the library installed)

  • kubernetes (needs the library installed)

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.5.1.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

kustomize-0.5.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kustomize-0.5.1.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for kustomize-0.5.1.tar.gz
Algorithm Hash digest
SHA256 515925d19142e1c0f11183c92396282ae02e52ff9df546ab8a5dd9f20d47e4de
MD5 2df3d0819c11c5c1593443d07dbeb4b5
BLAKE2b-256 538581cde87a5502c4f9eedfc17ce9838c71ef98dae074fa12161dfb015144aa

See more details on using hashes here.

File details

Details for the file kustomize-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: kustomize-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for kustomize-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 de4155b3eb13687820bd1bbbf7f69a4a6b6717f9b7d7a9e122a115997764008a
MD5 45a921f647f61a6526542e9a73ad1a40
BLAKE2b-256 cbe0b1b4d9c26179ff079e279b410c726cbcaed3e766d25091e4b2e1aa638c5c

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