2022-08-11 23:07:20 -04:00
# kubenix
2019-03-13 19:45:15 +01:00
2022-08-11 23:07:20 -04:00
Kubernetes resource 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;" >
< img src = "./docs/logo.svg" alt = "nixos logo in kubernetes blue" width = "350" / >
< / 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 21:48:45 -04:00
<!-- Apply all resources with
2017-11-11 11:52:17 +01:00
2022-08-12 09:44:00 -04:00
nix run github:hall/kubenix . -- apply
2017-11-11 11:52:17 +01:00
2022-08-14 21:48:45 -04:00
> **HINT**: use ` --help` for more commands -->
2019-02-20 23:16:18 +01:00
2022-08-14 21:48:45 -04:00
Create a `default.nix` file:
```nix
{ 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.test.spec.containers.nginx.image = "nginx";
};
}).config.kubernetes.result
```
Then execute `nix-build` to write JSON manifests to `./result` .
<!-- A minimal example flake:
2019-02-20 23:16:18 +01:00
2022-08-11 23:07:20 -04:00
```nix
{
2022-08-14 21:48:45 -04:00
inputs.kubenix.url = "github:hall/kubenix";
2022-08-11 23:07:20 -04:00
outputs = {self, ...}@inputs: {
2022-08-14 21:48:45 -04:00
kubenix = {
module = { inputs.kubenix, ...}: {
kubernetes.resources.pods."app" = {
spec.containers."app" = {
name = "app";
image = "nginx";
};
};
}
}
2022-08-11 23:07:20 -04:00
}
}
2022-08-14 21:48:45 -04:00
``` -->
2019-02-20 23:16:18 +01:00
2022-08-12 09:44:00 -04:00
<!-- A more complete example config:
2017-11-11 11:52:17 +01:00
2022-08-11 23:07:20 -04:00
```nix
{
kubernetes = {
context = "default";
resources = {};
helm = {
releases = {};
};
}
}
``` -->
## Attribution
2017-11-11 11:52:17 +01:00
2022-08-11 23:07:20 -04:00
This project was forked from https://github.com/GTrunSec/kubenix which was forked from https://github.com/xtruder/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 ).