Closed corpix closed 1 year ago
Can you give me concrete example please, I haven't used it for some time, so I don't know from top of my head. I think you could use mkMerge
.
Sure. Thank you for a fast reply.
But instead of limits & requests
let's try adding a kubernetes.api.resources.apps.v1.Deployment.system-kubernetes-dashboard.spec.template.spec.securityContext.seccompProfile
(because this is what could be easily reproduced on master
branch of kubenix).
Will try to use kubernetes dashboard from helm.
Code:
cat kube/dashboard.nix
{ pkgs ? import <nixpkgs> {}
, kubenix ? import (builtins.fetchTarball
{
url = "https://github.com/xtruder/kubenix/archive/473a18371d2c0bb22bf060f750589695fb7d3100.tar.gz";
sha256 = "0j3mzg81s8pd8gsa3lx7bmhawjpb3f5li2irh55kr7b9kyxr2nsy";
}) {}
, evalModules ? kubenix.evalModules
, ... }:
let
modules = evalModules {
modules = [
({ config, kubenix, ... }: {
imports = with kubenix.modules; [helm];
kubernetes.helm.instances.system = {
namespace = "kube-dashboard";
chart = kubenix.lib.helm.fetch {
repo = "https://kubernetes.github.io/dashboard";
chart = "kubernetes-dashboard";
sha256 = "1nlafbjvagcakb5iylsypbcx728ykkxbfn0ln99z35klxzpgc96h";
};
};
})
];
};
in (rec {
inherit (modules) config;
# kubernetes manifest
result = config.kubernetes.result;
})
Then build it:
nix-build --verbose --show-trace kube/dashboard.nix
...
error: while evaluating the attribute 'text' of the derivation 'kubenix-generated.json' at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/pkgs/stdenv/generic/make-derivation.nix:203:11:
while evaluating anonymous function at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/attrsets.nix:417:24, called from /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/attrsets.nix:366:15:
while evaluating anonymous function at /nix/store/yazix5khh53y6yc2c7rq4pkfg5n562mn-source/modules/k8s.nix:22:23, called from undefined position:
while evaluating 'moduleToAttrs' at /nix/store/yazix5khh53y6yc2c7rq4pkfg5n562mn-source/modules/k8s.nix:20:19, called from /nix/store/yazix5khh53y6yc2c7rq4pkfg5n562mn-source/modules/k8s.nix:22:26:
while evaluating 'filterAttrs' at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/attrsets.nix:124:23, called from /nix/store/yazix5khh53y6yc2c7rq4pkfg5n562mn-source/modules/k8s.nix:22:44:
while evaluating anonymous function at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/attrsets.nix:125:29, called from /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/attrsets.nix:125:18:
while evaluating anonymous function at /nix/store/yazix5khh53y6yc2c7rq4pkfg5n562mn-source/modules/k8s.nix:22:60, called from /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/attrsets.nix:125:62:
while evaluating the attribute 'securityContext' at undefined position:
while evaluating 'g' at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/attrsets.nix:298:19, called from undefined position:
while evaluating anonymous function at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/modules.nix:140:72, called from /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/attrsets.nix:301:20:
while evaluating the attribute 'value' at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/modules.nix:525:9:
while evaluating the option `kubernetes.api.resources.apps.v1.Deployment.system-kubernetes-dashboard.spec.template.spec.securityContext':
while evaluating the attribute 'mergedValue' at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/modules.nix:557:5:
while evaluating 'merge' at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/types.nix:459:20, called from /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/modules.nix:559:59:
while evaluating 'merge' at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/types.nix:519:22, called from /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/types.nix:464:14:
while evaluating 'evalModules' at /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/modules.nix:63:17, called from /nix/store/k7rx58a2dm4jzi3kmblnlxj6sznw85sl-source/lib/types.nix:520:12:
The option `kubernetes.api.resources.apps.v1.Deployment.system-kubernetes-dashboard.spec.template.spec.securityContext.seccompProfile' does not exist. Definition values:
- In `/nix/store/yazix5khh53y6yc2c7rq4pkfg5n562mn-source/modules/helm.nix':
{
type = "RuntimeDefault";
}
We have got The option
kubernetes.api.resources.apps.v1.Deployment.system-kubernetes-dashboard.spec.template.spec.securityContext.seccompProfile' does not exist`.
The definition of this option is short:
{
# ...
"io.k8s.api.core.v1.SeccompProfile" = {
options = {
"localhostProfile" = mkOption { type = types.nullOr types.str; };
"type" = mkOption { type = types.str; };
};
config = { "localhostProfile" = mkOverride 1002 null; };
};
# ...
}
Could I add the definition of this option without modifying kubenix?
This repo has been deprecated, since I stopped maintaining it some time ago. There is a fork maintained by @hall available at https://github.com/hall/kubenix, that has better documentation and looks like a way further.
Let's say we have
"io.k8s.api.core.v1.ResourceRequirements"
submodule from https://github.com/xtruder/kubenix/blob/master/modules/generated/v1.18.nix And we want to override a type forlimits & requests
from(types.nullOr (types.attrsOf types.str))
to(types.nullOr (types.attrsOf types.oneOf [types.int types.str]));
How could we write this override?