dpc on Nostr: Investigating how to make k8s do stuff without touching any smelly Yaml file, or even ...
Investigating how to make k8s do stuff without touching any smelly Yaml file, or even worse so - stinky helm templates or other terrible mechanisms like it.
```
writeYaml = name: content: pkgs.writeText name (builtins.toJSON content);
in
{
packages = {
pod = writeYaml "pod.yaml" {
apiVersion = "v1";
kind = "Pod";
metadata = {
name = "nginx";
};
spec = {
containers = [
{
name = "nginx";
image = "nginx:latest";
ports = [
{
containerPort = 80;
}
];
}
];
};
};
};
```
And then:
```
> nix build -L .#pod && cat result | kc apply -f -
pod/nginx created
```
```
writeYaml = name: content: pkgs.writeText name (builtins.toJSON content);
in
{
packages = {
pod = writeYaml "pod.yaml" {
apiVersion = "v1";
kind = "Pod";
metadata = {
name = "nginx";
};
spec = {
containers = [
{
name = "nginx";
image = "nginx:latest";
ports = [
{
containerPort = 80;
}
];
}
];
};
};
};
```
And then:
```
> nix build -L .#pod && cat result | kc apply -f -
pod/nginx created
```