mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
kubenix.submodule example used to create resources in multiple namespaces (#22)
This commit is contained in:
parent
20907f568e
commit
a90fdc0eae
4 changed files with 148 additions and 0 deletions
64
docs/content/examples/namespaces/module.nix
Normal file
64
docs/content/examples/namespaces/module.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
kubenix,
|
||||
...
|
||||
}: {
|
||||
imports = with kubenix.modules; [submodules k8s];
|
||||
|
||||
# Import submodule.
|
||||
submodules.imports = [
|
||||
./namespaced.nix
|
||||
];
|
||||
|
||||
# We can now create multiple submodule instances.
|
||||
submodules.instances.namespace-http = {
|
||||
# ~~~~~~~~~~~~~~
|
||||
# ^
|
||||
# ╭-----------------------╯
|
||||
# The submodule instance name is injected as the name attribute to
|
||||
# the submodule function. In this example, it is used as the namespace
|
||||
# name.
|
||||
#
|
||||
# This needs to match config.submodule.name of an imported submodule.
|
||||
submodule = "namespaced";
|
||||
# Now we can set the args options defined in the submodule.
|
||||
args.kubernetes.resources = {
|
||||
services.nginx.spec = {
|
||||
ports = [
|
||||
{
|
||||
name = "http";
|
||||
port = 80;
|
||||
}
|
||||
];
|
||||
selector.app = "nginx";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
submodules.instances.namespace-https = {
|
||||
submodule = "namespaced";
|
||||
args.kubernetes.resources = {
|
||||
services.nginx.spec = {
|
||||
ports = [
|
||||
{
|
||||
name = "https";
|
||||
port = 443;
|
||||
}
|
||||
];
|
||||
selector.app = "nginx";
|
||||
};
|
||||
};
|
||||
# Example of how other defaults can be applied to resources
|
||||
# within a submodule.
|
||||
args.kubernetes.version = "1.26";
|
||||
};
|
||||
|
||||
# Resources defined in parent context use namespace set at this
|
||||
# level and are not affected by the above submodules.
|
||||
kubernetes.namespace = "default";
|
||||
kubernetes.resources.services.nginx.spec = {
|
||||
selector.app = "nginx-default";
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue