mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2026-02-02 17:35:10 +01:00
docs: cleanup, fix links, add comments
This commit is contained in:
parent
8d10d79cfe
commit
95504f4c3b
12 changed files with 65 additions and 82 deletions
|
|
@ -1,9 +1,12 @@
|
|||
{ kubenix ? import ../../../.. }:
|
||||
kubenix.evalModules.x86_64-linux {
|
||||
kubenix.evalModules.${builtins.currentSystem} {
|
||||
module = { kubenix, ... }: {
|
||||
# instead of defining everything inline, let's import it
|
||||
imports = [ ./module.nix ];
|
||||
|
||||
# annotate the generated resources with a project name
|
||||
kubenix.project = "example";
|
||||
# define a target api version to validate output
|
||||
kubernetes.version = "1.24";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
kubenix,
|
||||
...
|
||||
}: {
|
||||
imports = with kubenix.modules; [k8s];
|
||||
{ kubenix, ... }: {
|
||||
imports = [ kubenix.modules.k8s ];
|
||||
|
||||
kubernetes.resources = {
|
||||
deployments.nginx.spec = {
|
||||
|
|
@ -56,13 +50,11 @@
|
|||
};
|
||||
|
||||
services.nginx.spec = {
|
||||
ports = [
|
||||
{
|
||||
selector.app = "nginx";
|
||||
ports = [{
|
||||
name = "http";
|
||||
port = 80;
|
||||
}
|
||||
];
|
||||
selector.app = "nginx";
|
||||
}];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
{ kubenix ? import ../../../.. }:
|
||||
kubenix.evalModules.${builtins.currentSystem} {
|
||||
module = { kubenix, ... }: {
|
||||
imports = with kubenix.modules; [helm];
|
||||
imports = [ kubenix.modules.helm ];
|
||||
kubernetes.helm.releases.example = {
|
||||
chart = kubenix.lib.helm.fetch {
|
||||
chart = "nginx";
|
||||
repo = "https://charts.bitnami.com/bitnami";
|
||||
sha256 = "sha256-wP3tcBnySx+kvZqfW2W9k665oi8KOI50tCcAl0g9cuw=";
|
||||
};
|
||||
values = {
|
||||
replicaCount = 2;
|
||||
chart = "nginx";
|
||||
version = "15.0.1";
|
||||
sha256 = "sKVqx99O4SNIq5y8Qo/b/2xIqXqSsZJzrgnYYz/0TKg=";
|
||||
};
|
||||
# arbitrary attrset passed as values to the helm release
|
||||
values.replicaCount = 2;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ weight: 30
|
|||
|
||||
Instead of deploying a 3rd party image, we can build our own.
|
||||
|
||||
We rely on the upstream [`dockerTools`](https://github.com/NixOs/nixpkgs/tree/master/pkgs/built-support/docker) package here.
|
||||
Specifically, we can use the `buildImage` function to define our image:
|
||||
We rely on the upstream [`dockerTools`](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-dockerTools) package here.
|
||||
Specifically, we can use the `buildLayeredImage` function to define our image:
|
||||
|
||||
{{< source "image.nix" >}}
|
||||
|
||||
|
|
@ -60,7 +60,5 @@ Render the generated manifests again and see that it now refers to the newly bui
|
|||
Of course, to actually deploy, we need to push the image to our registry. The script defined at {{< option "docker.copyScript" >}} does just that.
|
||||
|
||||
```sh
|
||||
$(nix build -f . --json config.docker.copyScript | jq -r '.[].outputs.out')
|
||||
$(nix build -f . --print-out-paths config.docker.copyScript)
|
||||
```
|
||||
|
||||
<!-- TODO: can we make that `nix run -f . config.docker.copyScript` ? -->
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
{ kubenix ? import ../../../.. }:
|
||||
kubenix.evalModules.${builtins.currentSystem} {
|
||||
module = {
|
||||
kubenix,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
module = { kubenix, config, pkgs, ... }: {
|
||||
imports = with kubenix.modules; [ k8s docker ];
|
||||
docker = {
|
||||
registry.url = "docker.somewhere.io";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
{
|
||||
dockerTools,
|
||||
nginx,
|
||||
}:
|
||||
{ dockerTools, nginx }:
|
||||
dockerTools.buildLayeredImage {
|
||||
name = "nginx";
|
||||
contents = [ nginx ];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{ kubenix ? import ../../../.. }:
|
||||
kubenix.evalModules.x86_64-linux {
|
||||
kubenix.evalModules.${builtins.currentSystem} {
|
||||
module = { kubenix, ... }: {
|
||||
imports = [ ./module.nix ];
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,14 @@ kubenix.evalModules.${builtins.currentSystem} {
|
|||
# to it, we pass a module that accepts a (different) kubenix object
|
||||
module = { kubenix, ... }: {
|
||||
# in order to define options, we need to import their definitions
|
||||
imports = with kubenix.modules; [k8s];
|
||||
imports = [ kubenix.modules.k8s ];
|
||||
# now we have full access to define Kubernetes resources
|
||||
kubernetes.resources.pods.example.spec.containers.ex.image = "nginx";
|
||||
kubernetes.resources.pods = {
|
||||
# "example" is the name of our pod
|
||||
example.spec.containers = {
|
||||
# "ex" is the name of the container in our pod
|
||||
ex.image = "nginx";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{ kubenix ? import ../../../.. }:
|
||||
kubenix.evalModules.x86_64-linux {
|
||||
kubenix.evalModules.${builtins.currentSystem} {
|
||||
module = { kubenix, ... }: {
|
||||
imports = with kubenix; [k8s];
|
||||
imports = [ kubenix.modules.k8s ];
|
||||
kubernetes.resources.secrets.example.stringData = {
|
||||
password = "ref+file:///path/to/secret";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
Testing is still very much in flux but here's a rough example.
|
||||
Testing is still very much in flux (contributions welcome!) but here's a rough example.
|
||||
|
||||
{{< source "default.nix" >}}
|
||||
|
||||
Where we've defined a might look like:
|
||||
Where we've defined a test that might look like:
|
||||
|
||||
{{< source "test.nix" >}}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
{ kubenix ? import ../../../.. }:
|
||||
kubenix.evalModules.x86_64-linux {
|
||||
kubenix.evalModules.${builtins.currentSystem} {
|
||||
module = { kubenix, ... }: {
|
||||
imports = with kubenix.modules; [testing];
|
||||
imports = [ kubenix.modules.testing ];
|
||||
testing = {
|
||||
tests = [ ./test.nix ];
|
||||
common = [
|
||||
{
|
||||
common = [{
|
||||
features = [ "k8s" ];
|
||||
options = {
|
||||
kubernetes.version = "1.24";
|
||||
};
|
||||
}
|
||||
];
|
||||
}];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,4 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
kubenix,
|
||||
test,
|
||||
...
|
||||
}: {
|
||||
{ kubenix, test, ... }: {
|
||||
imports = [ kubenix.modules.test ];
|
||||
|
||||
test = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue