mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
docs: add k3s tip on auto-deploying manifests
This commit is contained in:
parent
c577e3e887
commit
9fe3b49493
1 changed files with 29 additions and 0 deletions
29
docs/content/tips-n-tricks/k3s/_index.md
Normal file
29
docs/content/tips-n-tricks/k3s/_index.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
The k3s project supports [automatic resource deployment](https://docs.k3s.io/installation/packaged-components#auto-deploying-manifests-addons) of files in the `/var/lib/rancher/k3s/server/manifests` directory.
|
||||
|
||||
As such, on a server node, we can write kubenix's output there.
|
||||
|
||||
```nix
|
||||
{
|
||||
# let's write `resultYAML` to an arbitrary file under `/etc`
|
||||
environment.etc."kubenix.yaml".source =
|
||||
(kubenix.evalModules.x86_64-linux {
|
||||
module = { kubenix, ... }: {
|
||||
imports = [ kubenix.modules.k8s ];
|
||||
kubernetes.resources.pods.example.spec.containers.example.image = "nginx";
|
||||
};
|
||||
}).config.kubernetes.resultYAML;
|
||||
|
||||
# now we can link our file into the appropriate directory
|
||||
# and k3s will handle the rest
|
||||
system.activationScripts.kubenix.text = ''
|
||||
ln -sf /etc/kubenix.yaml /var/lib/rancher/k3s/server/manifests/kubenix.yaml
|
||||
'';
|
||||
}
|
||||
```
|
||||
{{< hint danger >}}
|
||||
**WARN**: this will write all manifests to the nix store and is therefore not suitable for inline sensitive data.
|
||||
{{< /hint >}}
|
||||
|
||||
{{< hint info >}}
|
||||
**NOTE**: k3s will not delete resources if files are removed.
|
||||
{{< /hint >}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue