ITADN

How to define custom resources

#94Closedsheepforce 创建于 2025-12-03
S
sheepforcecommented
I'm somewhat puzzled how custom resources work in Kubenix. From the documentation [here](https://kubenix.org/modules/kubernetes/#kubernetes.customResources) and the code [here](https://github.com/hall/kubenix/blob/e8577e661f3286624f79ce5ca3240a0ffcea9a7d/modules/k8s.nix#L319) they somehow seem to be supported, but I can not figure out how to use them. For instance, I would like to define a Traefik middleware for basic-auth, see here (kubernetes) https://doc.traefik.io/traefik/reference/routing-configuration/http/middlewares/basicauth/ My current attempt looks like this: ```nix { config , lib , pkgs , kubenix , ... }: { imports = with kubenix.modules; [ k8s submodules ]; submodules.imports = [ ../lib/namespaced.nix ]; submodules.instances.longhorn-system = { submodule = "namespaced"; args.kubernetes = { customResources = [{ apiVersion = "traefik.containo.us/v1alpha1"; kind = "Middleware"; metadata = { name = "basic-auth"; namespace = "longhorn-system"; }; spec = { basicAuth = { secret = "basic-auth"; }; }; }]; }; }; } ``` But when I render this, no definition of a middleware appears anywhere in the JSON/YAML. But there is also no error.
关闭于 2026-01-04 9 条评论