Skip to content

Commit 62bcdcc

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 - Update CI/CD workflow to use new component labels (cache, node, init) 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 - CI/CD pipelines correctly select resources by component
1 parent c765b49 commit 62bcdcc

8 files changed

Lines changed: 27 additions & 27 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
8888
- name: Wait for nix-csi cache pod
8989
run: |
90-
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=cache -n nix-csi --timeout=60s
90+
kubectl wait --for=condition=ready pod -l app.kubernetes.io/component=cache -n nix-csi --timeout=60s
9191
9292
- name: Wait for test workload
9393
run: |
@@ -138,7 +138,7 @@ jobs:
138138
- name: Print node logs
139139
run: |
140140
echo "=== Node pod logs ==="
141-
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1
141+
kubectl logs -l app.kubernetes.io/component=node -n nix-csi --tail -1
142142
143143
- name: Cluster state all
144144
if: failure()
@@ -160,19 +160,19 @@ jobs:
160160
- name: Cache
161161
if: failure()
162162
run: |
163-
kubectl logs -l app.kubernetes.io/name=cache -n nix-csi --tail -1 || true
164-
kubectl describe pod -l app.kubernetes.io/name=cache-n nix-csi || true
163+
kubectl logs -l app.kubernetes.io/component=cache -n nix-csi --tail -1 || true
164+
kubectl describe pod -l app.kubernetes.io/component=cache -n nix-csi || true
165165
166166
- name: Node
167167
if: failure()
168168
run: |
169-
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1 || true
170-
kubectl describe pod -l app.kubernetes.io/name=csi -n nix-csi || true
169+
kubectl logs -l app.kubernetes.io/component=node -n nix-csi --tail -1 || true
170+
kubectl describe pod -l app.kubernetes.io/component=node -n nix-csi || true
171171
172172
- name: Init
173173
if: failure()
174174
run: |
175-
kubectl logs -l app.kubernetes.io/name=init -n nix-csi --tail -1 || true
175+
kubectl logs -l app.kubernetes.io/component=init -n nix-csi --tail -1 || true
176176
177177
- name: Events
178178
if: failure()
@@ -228,7 +228,7 @@ jobs:
228228
- name: Print node logs
229229
run: |
230230
echo "=== Node pod logs ==="
231-
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1
231+
kubectl logs -l app.kubernetes.io/component=node -n nix-csi --tail -1
232232
233233
- name: Debug on failure
234234
if: failure()
@@ -240,10 +240,10 @@ jobs:
240240
kubectl logs -l app.kubernetes.io/name=cache -n nix-csi --tail -1 || true
241241
242242
echo "=== Node pod logs ==="
243-
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1 || true
243+
kubectl logs -l app.kubernetes.io/component=node -n nix-csi --tail -1 || true
244244
245245
echo "=== Init pod logs ==="
246-
kubectl logs -l app.kubernetes.io/name=init -n nix-csi --tail -1 || true
246+
kubectl logs -l app.kubernetes.io/component=init -n nix-csi --tail -1 || true
247247
248248
echo "=== Events ==="
249249
kubectl get events -n nix-csi --sort-by='.lastTimestamp'

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)