mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 08:00:06 +01:00
add minimal working example to readme
This commit is contained in:
parent
7fb2bf9578
commit
aa60eca0fd
4 changed files with 70 additions and 26 deletions
34
README.md
34
README.md
|
|
@ -10,21 +10,37 @@ Kubernetes resource management with Nix
|
|||
|
||||
## Usage
|
||||
|
||||
Apply all resources with
|
||||
<!-- Apply all resources with
|
||||
|
||||
nix run github:hall/kubenix . -- apply
|
||||
|
||||
> **HINT**: use ` --help` for more commands
|
||||
> **HINT**: use ` --help` for more commands -->
|
||||
|
||||
A minimal example flake:
|
||||
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:
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs.kubenix = "github:hall/kubenix";
|
||||
inputs.kubenix.url = "github:hall/kubenix";
|
||||
outputs = {self, ...}@inputs: {
|
||||
nixosConfigurations.hostname = {
|
||||
modules = [ inputs.kubenix.nixosModule ];
|
||||
};
|
||||
kubenix = {
|
||||
module = { inputs.kubenix, ...}: {
|
||||
kubernetes.resources.pods."app" = {
|
||||
spec.containers."app" = {
|
||||
name = "app";
|
||||
|
|
@ -32,8 +48,10 @@ A minimal example flake:
|
|||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
``` -->
|
||||
|
||||
<!-- A more complete example config:
|
||||
|
||||
|
|
|
|||
10
default.nix
Normal file
10
default.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(import
|
||||
(
|
||||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
)
|
||||
{ src = ./.; }
|
||||
).defaultNix
|
||||
31
flake.lock
generated
31
flake.lock
generated
|
|
@ -1,12 +1,28 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1650374568,
|
||||
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1648297722,
|
||||
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -17,22 +33,23 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1648219316,
|
||||
"narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
|
||||
"lastModified": 1660396586,
|
||||
"narHash": "sha256-ePuWn7z/J5p2lO7YokOG1o01M0pDDVL3VrStaPpS5Ig=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634",
|
||||
"rev": "e105167e98817ba9fe079c6c3c544c6ef188e276",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
url = "github:numtide/flake-utils";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
|
|
@ -134,11 +138,6 @@
|
|||
nixosModules.kubenix = import ./modules;
|
||||
overlays.default = _final: prev: {
|
||||
kubenix.evalModules = self.evalModules.${prev.system};
|
||||
# up to date versions of their nixpkgs equivalents
|
||||
# kubernetes =
|
||||
# prev.callPackage ./pkgs/applications/networking/cluster/kubernetes
|
||||
# {};
|
||||
# kubectl = prev.callPackage ./pkgs/applications/networking/cluster/kubectl {};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue