Skip to content

Commit 5fcbbcb

Browse files
committed
Wrap all Kubernetes resources with mkNCSI and add component labels
- Wrap Job.init in secret.nix and ConfigMap.push in config.nix with mkNCSI - Rename metadata/0.4.3.nix to metadata/0.4.3.md for proper file typing - Add standard component labels to daemonset (node), statefulset (cache), deployments (builder/proxy), and init job - Move common labels (name, part-of, managed-by, version) to options.nix config - Each resource now identifies its component role for better querying and organization This enables: - All resources get consistent labels via mkNCSI - Component-based queries: kubectl get pods -l app.kubernetes.io/component=cache - Standard Kubernetes label compliance
1 parent c765b49 commit 5fcbbcb

7 files changed

Lines changed: 17 additions & 17 deletions

File tree

kubenix/builder.nix

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ in
8686
config =
8787
let
8888
baseLabels = {
89-
"app.kubernetes.io/name" = "builder";
90-
"app.kubernetes.io/part-of" = "nix-csi";
89+
"app.kubernetes.io/component" = "builder";
9190
};
9291
in
9392
lib.mkIf (cfg.enable && cfg.builders.enable) {
@@ -215,8 +214,7 @@ in
215214
spec =
216215
let
217216
labels = {
218-
"app.kubernetes.io/name" = "proxy";
219-
"app.kubernetes.io/part-of" = "nix-csi";
217+
"app.kubernetes.io/component" = "proxy";
220218
};
221219
in
222220
{

kubenix/cache.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ in
3737
config =
3838
let
3939
labels = {
40-
"app.kubernetes.io/name" = "cache";
41-
"app.kubernetes.io/part-of" = "nix-csi";
40+
"app.kubernetes.io/component" = "cache";
4241
};
4342
in
4443
lib.mkIf (cfg.enable && cfg.cache.enable) {

kubenix/config.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ in
4646
};
4747
};
4848
kubernetes.resources.${cfg.namespace} = {
49-
ConfigMap.push = lib.mkIf cfg.push {
49+
ConfigMap.push = lib.mkIf cfg.push (mkNCSI {
5050
data = {
5151
builder-aarch64-linux = armPkgs.nix-csi-builder-env;
5252
builder-x86_64-linux = x86Pkgs.nix-csi-builder-env;
@@ -57,7 +57,7 @@ in
5757
proxy-aarch64-linux = armPkgs.nix-csi-proxy-env;
5858
proxy-x86_64-linux = x86Pkgs.nix-csi-proxy-env;
5959
};
60-
};
60+
});
6161
ConfigMap.nix-node = mkNCSI {
6262
data = {
6363
"nix.conf" = builtins.readFile (cfg.node.nixConfig.nixConf);

kubenix/daemonset.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ in
2626
config =
2727
let
2828
labels = {
29-
"app.kubernetes.io/name" = "csi";
30-
"app.kubernetes.io/part-of" = "nix-csi";
29+
"app.kubernetes.io/component" = "node";
3130
};
3231
in
3332
lib.mkIf cfg.enable {

kubenix/options.nix

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ in
5353
apply = lib.mapAttrs (n: v: lib.trim (if lib.typeOf v == "path" then builtins.readFile v else v));
5454
default = { };
5555
};
56-
metadata = lib.mkOption {
56+
labels = lib.mkOption {
5757
description = "Labels added to nix-csi resources";
58-
type = (curPkgs.formats.json { }).type;
58+
type = lib.types.attrsOf lib.types.str;
5959
default = { };
6060
};
6161
version = lib.mkOption {
@@ -185,7 +185,7 @@ in
185185
mkNCSI =
186186
attrs:
187187
lib.recursiveUpdate {
188-
inherit (cfg) metadata;
188+
metadata.labels = cfg.labels;
189189
} attrs;
190190
subPath = spath: lib.removePrefix "/" (toString spath);
191191
};
@@ -208,6 +208,11 @@ in
208208
resource
209209
);
210210

211-
nix-csi = { };
211+
nix-csi.labels = {
212+
"app.kubernetes.io/name" = "nix-csi";
213+
"app.kubernetes.io/part-of" = "nix-csi";
214+
"app.kubernetes.io/managed-by" = "nix";
215+
"app.kubernetes.io/version" = cfg.version;
216+
};
212217
};
213218
}

kubenix/secret.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ in
9191
fi
9292
'';
9393
};
94-
Job.init = {
94+
Job.init = mkNCSI {
9595
metadata.annotations = {
9696
"kluctl.io/hook" = "pre-deploy";
9797
"kluctl.io/hook-delete-policy" = "hook-succeeded"; # seems flaky
@@ -101,8 +101,7 @@ in
101101
# ttlSecondsAfterFinished = 0; # remove job when it's done
102102
template = {
103103
metadata.labels = {
104-
"app.kubernetes.io/name" = "init";
105-
"app.kubernetes.io/part-of" = "nix-csi";
104+
"app.kubernetes.io/component" = "init";
106105
};
107106
spec = {
108107
restartPolicy = "OnFailure";
File renamed without changes.

0 commit comments

Comments
 (0)