← Back to DAGDA | Support | Source: https://github.com/andsens/nix-kubetree
Skip to content
This repository was archived by the owner on Nov 14, 2026. It is now read-only.
andsensPublic archive

About

Pluggable module for performing tree transformations on Nix kubernetes manifests

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

35 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nix-kubetree

Important

This project is archived and no longer maintained. Use kubenix instead: typed Kubernetes resources for Nix, where a misspelled field fails at evaluation, and submodules in place of the macros a transformer would add. The NixOS module of k3s (services.k3s.manifests) takes plain objects for anything that needs no types.

Pluggable module for performing tree transformations on Nix kubernetes manifests.

Comes with a built-in kubernetes primitives module that provides various properties on normal pod specifications, which eases both the writing and improves the readability of manifests.
See the docs for more.

Configuring resources

Resources are specified on kubetree.resources.<MANIFESTNAME>.<ITEMNAME>:

kubetree.resources.netutils.deployment = {
  apiVersion = "apps/v1";
  kind = "Deployment";
  metadata = {
    namespace = "default";
    name = "netutils";
  };
  spec = {
    selector.matchLabels."app.kubernetes.io/name" = "netutils";
    ...
  };
};

The transformed resources will be available at kubetree.manifests.<MANIFESTNAME>.<ITEMNAME>

services.k3s integration

The manifests can be applied to k3s automatically. Enable with kubetree.k3s.enable = true.

Adding your own transformers

Enhancing kubetree with your own transformers is fairly straightforward. Simply configure the functions on kubetree.transformers.<APIGROUP>.<KIND>.<SPECPATH>._transformers = [<FN>].

An example explains this better:

kubetree.transformers.v1.Pod.spec.containers."[]"._transformers = [ (
  cfg: resource: resource // { imagePullPolicy = "Always" }
) ];

This transformer adds imagePullPolicy: Always to all containers on all Pods.
The "[]" part of the config path instructs kubetree to apply the transformation to all items in a list.
cfg is config.kubetree, meaning you can enhance the configuration tree with your own namespaced settings and have them available when your transformer is evaluated.

Library functions

kubetree includes useful library functions accessible through inputs.kubetree.lib.transform. The documentation for which can be found in the docs.

About

Pluggable module for performing tree transformations on Nix kubernetes manifests

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages