2022-08-11 23:07:20 -04:00
# kubenix
2019-03-13 19:45:15 +01:00
2022-08-28 15:27:18 -04:00
Kubernetes management with Nix
2017-11-11 11:52:17 +01:00
2022-08-11 23:47:39 -04:00
< p align = "center" style = "margin: 2em auto;" >
2022-08-28 15:22:43 -04:00
< img src = "./docs/static/logo.svg" alt = "nixos logo in kubernetes blue" width = "350" / >
2022-08-11 23:47:39 -04:00
< / p >
2017-11-11 11:52:17 +01:00
2022-08-11 23:07:20 -04:00
> **WARN**: this is a work in progress, expect breaking changes
2019-03-12 21:03:13 +01:00
2022-08-11 23:07:20 -04:00
## Usage
2017-11-11 11:52:17 +01:00
2022-08-14 22:31:44 -04:00
A minimal example flake (build with `nix build` ):
```nix
{
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` ):
2022-08-14 21:48:45 -04:00
```nix
{ kubenix ? import (builtins.fetchGit {
url = "https://github.com/hall/kubenix.git";
rev = "aa734afc9cf7a5146a7a9d93fd534e81572c8122";
}) }:
(kubenix.evalModules.x86_64-linux {
2022-08-14 22:31:44 -04:00
module = {kubenix, ... }: {
2022-08-14 21:48:45 -04:00
imports = with kubenix.modules; [k8s];
2022-08-14 22:31:44 -04:00
kubernetes.resources.pods.example.spec.containers.nginx.image = "nginx";
2022-08-14 21:48:45 -04:00
};
}).config.kubernetes.result
```
2022-08-14 22:31:44 -04:00
Either way the JSON manifests will be written to `./result` .
2019-02-20 23:16:18 +01:00
2022-08-29 02:04:47 -04:00
See the [examples ](/examples/pod ) for more.
2022-08-11 23:07:20 -04:00
2022-08-15 20:34:03 -04:00
## CLI
2022-08-28 15:22:43 -04:00
> **NOTE**: this is a WIP CLI which currently reads the `k8s` package on a local flake
2022-08-15 20:34:03 -04:00
Render all resources with
nix run github:hall/kubenix -- render
> **HINT**: use ` --help` for more commands
### Support
2022-08-16 00:58:23 -04:00
The following table gives a general overview of currently supported/planned functionality.
| | kubectl | kustomize | helm | helmfile |
| --------- | :-----: | :-------: | :---: | :------: |
| render | x | | x[^2] | |
| diff | x | | x | |
| apply[^1] | x | | x | |
2022-08-15 20:34:03 -04:00
[^1]: currently create-only
[^2]: piping rendered helm charts to kubectl is a lossy process (e.g., [hooks ](https://helm.sh/docs/topics/charts_hooks/ ) will not work)
2022-08-11 23:07:20 -04:00
## Attribution
2017-11-11 11:52:17 +01:00
2022-08-28 15:35:07 -04:00
This project was forked from [GTrunSec ](https://github.com/GTrunSec/kubenix ), which was forked from [xtruder ](https://github.com/xtruder/kubenix ), with commits incorporated from [blaggacao ](https://github.com/blaggacao/kubenix ).
2017-11-11 11:52:17 +01:00
2022-08-11 23:07:20 -04:00
Logo is a mishmash of the [Kubernetes wheel ](https://github.com/kubernetes/kubernetes/blob/master/logo/logo.svg ) and the [NixOs snowflake ](https://github.com/NixOS/nixos-artwork/blob/master/logo/white.svg ).