Kubernetes management with Nix https://kubenix.org/
Find a file
Bryton Hall 098edd1266 docs: reformat hugo toml config to yaml
This is the only toml file in the repo now so lets just stick with yaml
which is a far more common format given the context of this project.
2023-07-06 22:37:21 -04:00
.github/workflows add release process and cut version 0.1.0 (#29) 2023-07-06 22:24:02 -04:00
.vscode vscode: don't show submodule in sidebar 2023-07-06 22:27:53 -04:00
docs docs: reformat hugo toml config to yaml 2023-07-06 22:37:21 -04:00
jobs flake: format 2023-06-03 03:11:07 -04:00
lib Replace remarshal with yq (#26) 2023-06-19 12:14:20 -04:00
modules add support for kubernetes 1.27 2023-06-13 16:38:33 -04:00
pkgs pkgs(vals): remove in favor of nixpkgs derivation 2023-06-11 23:53:22 -04:00
tests tests: temp disable import test 2023-01-28 11:47:19 -05:00
.envrc remove flake-compat and devshell inputs 2022-08-13 00:09:36 -04:00
.gitignore cleanup some misc files 2022-08-12 09:44:26 -04:00
.gitmodules create static docs site with module options 2022-08-28 15:22:43 -04:00
CHANGELOG.md add release process and cut version 0.1.0 (#29) 2023-07-06 22:24:02 -04:00
CONTRIBUTING.md add release process and cut version 0.1.0 (#29) 2023-07-06 22:24:02 -04:00
default.nix add missing kube version, move jobs to packages 2022-08-15 00:29:27 -04:00
flake.lock switch to treefmt module 2023-07-06 22:36:37 -04:00
flake.nix switch to treefmt module 2023-07-06 22:36:37 -04:00
LICENSE feat: add license 2019-03-07 23:30:20 +01:00
README.md docs: fix CLI flake package name 2023-06-12 00:01:53 -04:00
versions.nix add support for kubernetes 1.27 2023-06-13 16:38:33 -04:00

kubenix

Kubernetes management with Nix

nixos logo in kubernetes blue

WARN: this is a work in progress, expect breaking changes

Usage

A minimal example flake.nix (build with nix build):

{
  inputs.kubenix.url = "github:hall/kubenix";
  outputs = {self, kubenix, ... }@inputs: let
    system = "x86_64-linux";
  in {
    packages.${system}.default = (kubenix.evalModules.${system} {
      module = { kubenix, ... }: {
        imports = with kubenix.modules; [k8s];
        kubernetes.resources.pods.example.spec.containers.nginx.image = "nginx";
      };
    }).config.kubernetes.result;
  };
}

Or, if you're not using flakes, a default.nix file (build with nix-build):

{ kubenix ? import (builtins.fetchGit {
  url = "https://github.com/hall/kubenix.git";
  rev = "aa734afc9cf7a5146a7a9d93fd534e81572c8122";
}) }:
(kubenix.evalModules.x86_64-linux {
  module = {kubenix, ... }: {
    imports = with kubenix.modules; [k8s];
    kubernetes.resources.pods.example.spec.containers.nginx.image = "nginx";
  };
}).config.kubernetes.result

Either way the JSON manifests will be written to ./result.

See the examples for more.

CLI

NOTE: this is a WIP CLI which currently reads the kubenix package on a local flake

Render all resources with

nix run github:hall/kubenix -- render

HINT: use --help for more commands

Support

The following table gives a general overview of currently supported/planned functionality.

kubectl helm
render x x1
diff x x
apply2 x x

Attribution

This project was forked from GTrunSec, which was forked from xtruder, with commits incorporated from blaggacao.

Logo is a mishmash of the Kubernetes wheel and the NixOs snowflake.


  1. piping rendered helm charts to kubectl is a lossy process (e.g., hooks will not work) ↩︎

  2. currently create-only ↩︎