Skip to content
Install the CLI

Tutorial 12

Scorecards and compile-time policy

These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.

In tutorial 09, you used lib.mkOption and lib.types to validate each option on a single package instance. Some policies, however, belong to the platform team rather than to an individual package author:

  • “Every reverse-proxy gateway in our production cluster must set maxBodySize explicitly rather than relying on the 1m default.”
  • “No two reverse-proxy gateways across the entire cluster may claim the same proxyPath.”

In Kix, you enforce these rules at build time using scorecards. Because scorecards evaluate inside Nix against the typed package options, metadata, and full cluster graph, they can check cross-instance invariants that single-manifest YAML linters cannot see.

Open:

tutorials/19-scorecards/cluster.nix
tutorials/19-scorecards/scorecard.nix

In tutorials/19-scorecards/cluster.nix, the cluster defines two application namespaces (app-v1 and app-v2), each with a backend and a gateway instance:

  • app-v1.gateway sets proxyPath = "/v1/" and maxBodySize = "10m".
  • app-v2.gateway sets proxyPath = "/v2/" and maxBodySize = "10m".

At the top of cluster.nix, the cluster module inside modules sets scorecard by importing ./scorecard.nix:

tutorials/19-scorecards/cluster.nix
kix.buildCluster {
name = "19-scorecards";
modules = [
kix.flavors.kind
# `lib` is injected by the NixOS module system — we pull it in
# here so we can hand it to ./scorecard.nix on import.
(
{ ref, lib, ... }:
{
# ── Scorecard ────────────────────────────────────────────────
# The whole rules block lives in ./scorecard.nix. cluster.nix
# stays focused on what the cluster *contains*; the rules file
# owns the checks we want to run against it.
scorecard = import ./scorecard.nix { inherit lib kix; };
# ...
}
)
];
}

View source on GitHub ↗

Keeping scorecard policy in a separate file (./scorecard.nix) lets platform teams share a single policy definition across multiple clusters while keeping cluster.nix focused on topology and instances.

Enable Built-In Rules And Severity Controls

Section titled “Enable Built-In Rules And Severity Controls”

Open tutorials/19-scorecards/scorecard.nix. At the top of the file, enable, ruleOverrides, and rules configure what the scorecard checks:

tutorials/19-scorecards/scorecard.nix
{
enable = true;
# Per-rule severity override. Key is `<category>.<rule>`.
# Raises a built-in from "warning" to "error" so the build fails
# if a probe is missing.
ruleOverrides.byRule."reliability.hasProbes".severity = "error";
rules = {
# 1. Whole built-in category. Bundles hasProbes,
# boundedResources, hasResourceLimits, hasResourceRequests,
# gracefulShutdown, hasPDB.
reliability = kix.rules.reliability;
# custom rules ...
};
}

View source on GitHub ↗

Here is what each field controls:

  • enable = true: Turns on scorecard evaluation during kix check and kix build.
  • ruleOverrides.byRule."reliability.hasProbes".severity = "error": Overrides the severity of a single rule (<category>.<rule>) from "warning" to "error".
  • rules = { reliability = kix.rules.reliability; ... }: Selects Kix’s built-in reliability rule category (kix.rules.reliability, alongside kix.rules.security, kix.rules.governance, and kix.rules.architecture) and adds custom rules for this cluster.
  • maxSeverity (optional, defaults to "warning"): Caps the effective severity of every finding in the cluster to "info", "warning", or "error". Because the default is "warning", findings from error-severity rules are capped to warnings unless the cluster also sets maxSeverity = "error".

Next, look at the first custom rule in tutorials/19-scorecards/scorecard.nix:

tutorials/19-scorecards/scorecard.nix
custom.proxyMaxBodySizeMustBeExplicit = {
description = "Reverse-proxy gateways must set maxBodySize explicitly (not the 1m default).";
level = "package";
severity = "error";
tags = [ "reliability" "kix-examples" ];
# Only run on reverse-proxy packages. `appliesTo` receives the
# package metadata directly, so this checks `meta.provides`.
appliesTo =
{ meta, ... }:
builtins.elem "reverse-proxy" (meta.provides or [ ]);
check =
{ config, instanceName, ... }:
if (config.maxBodySize or "") == "1m" then
[
{
message =
"instance '${instanceName}' uses the default maxBodySize '1m'. "
+ "nginx rejects larger request bodies — set this explicitly.";
}
]
else
[ ];
};

View source on GitHub ↗

A level = "package" rule runs once per package instance and inspects the package’s meta, config, and built resources:

  1. appliesTo = { meta, ... }: ...: Filters which instances this rule checks. Because reverse-proxy-package.nix declares meta.provides = [ "reverse-proxy" ], builtins.elem "reverse-proxy" (meta.provides or [ ]) runs this rule only on reverse-proxy instances and skips echo-server backends.
  2. check = { config, instanceName, ... }: ...: Inspects the instance’s merged config directly. You do not have to parse nginx’s default.conf text out of a rendered ConfigMap; you read config.maxBodySize as a structured Nix value. If it equals "1m", check returns a finding with a descriptive message.

Some mistakes only appear when you compare multiple instances across the cluster. If app-v1/gateway and app-v2/gateway both configure proxyPath = "/v1/", each instance looks completely valid in isolation, yet their routes collide across the cluster.

To catch that, tutorials/19-scorecards/scorecard.nix defines a helper predicate isProxy and a level = "cluster" rule named custom.noProxyPathCollision:

tutorials/19-scorecards/scorecard.nix
isProxy =
inst:
# Cluster-level rules inspect built instances, so the package
# metadata is under `inst._meta.packageMeta`.
builtins.elem "reverse-proxy" (inst._meta.packageMeta.provides or [ ]);

View source on GitHub ↗

tutorials/19-scorecards/scorecard.nix
custom.noProxyPathCollision = {
description = "No two reverse-proxy gateways may share the same proxyPath.";
level = "cluster";
severity = "error";
tags = [
"routing"
"kix-examples"
];
check =
{ allInstances, ... }:
let
# `allInstances` is `{ <ns> = { <name> = instance; }; }`.
# Flatten into a list of { ns, name, inst } records.
#
# `lib.concatLists` is the nixpkgs equivalent of JS's
# `arr.flat()` — flatten a list of lists into one list.
# `builtins.attrNames` returns the keys of an attrset.
flat = lib.concatLists (
map (
ns:
map (name: {
inherit ns name;
inst = allInstances.${ns}.${name};
}) (builtins.attrNames allInstances.${ns})
) (builtins.attrNames allInstances)
);
# Keep only reverse-proxy instances.
proxies = builtins.filter (e: isProxy e.inst) flat;
# Group by proxyPath → { "/v1/" = [...]; "/v2/" = [...]; }.
byPath = builtins.foldl' (
acc: e:
let
p = e.inst._meta.config.proxyPath or "?";
in
acc // { ${p} = (acc.${p} or [ ]) ++ [ e ]; }
) { } proxies;
# Any path with more than one owner is a collision.
collisions = lib.filterAttrs (_: members: builtins.length members > 1) byPath;
in
map (path: {
message =
"${toString (builtins.length collisions.${path})} reverse-proxy gateways share proxyPath '${path}': "
+ builtins.concatStringsSep ", " (
map (e: "${e.ns}/${e.name}") collisions.${path}
);
}) (builtins.attrNames collisions);
};

View source on GitHub ↗

Look at how custom.noProxyPathCollision works:

  1. level = "cluster": Runs once for the entire cluster and receives allInstances ({ <namespace> = { <instance> = inst; }; }).
  2. Filter to reverse proxies: Flattens allInstances and uses isProxy to keep only instances whose meta.provides includes "reverse-proxy".
  3. Group by config.proxyPath: Reads e.inst._meta.config.proxyPath on every reverse-proxy instance and groups instances by path.
  4. Report collisions: Any proxyPath claimed by more than one gateway produces an error finding that lists every colliding <namespace>/<instance> pair.

Run kix check 19-scorecards:

kix-examples/
❱ kix check 19-scorecards
 TOOL       RESULT  DETAILS                      
 eval       pass    22 manifests evaluated       
 scorecard  pass    0 errors, 2 warnings, 2 info 

reliability.boundedResources (warning), 2:
  app-v1/gateway/gateway: container 'nginx' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.
  app-v2/gateway/gateway: container 'nginx' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.

2 info finding(s) not listed; run with -v to list them.

Both custom rules pass (0 errors), while the built-in kix.rules.reliability rules report 6 warnings and 2 informational findings across the 24 evaluated manifests. kix build 19-scorecards succeeds and renders all 24 resources:

kix-examples/ offline capture
❱ kix build 19-scorecards
Show outputHide output · 667 lines
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kix.run/depends-on: 95gmkzkbdf1k30pp3k54hp8vc8qd54p8,q85cvsj44a56pxm9cx3naj0ywb4bnmcv
    kix.run/identity-hash: 011nbqjvmaz0d3nrnq6w3dnv66pfwv1y
    kix.run/package: backend
    kix.run/package-namespace: app-v1
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
    app.kubernetes.io/name: backend
  name: backend
  namespace: app-v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: backend
      app.kubernetes.io/name: backend
  template:
    metadata:
      annotations:
        checksum/config: 59e6c3c05a9d5f93aae11fd69e5b28940015b69402671f5859b225af8e0b89a2
      labels:
        app.kubernetes.io/instance: backend
        app.kubernetes.io/name: backend
    spec:
      containers:
      - image: docker.io/nginxinc/nginx-unprivileged:1.30.6-alpine@sha256:f5116ed4606f3eb015dd4a8e28cb9b351476dc0ad4bc6e9f93b19cec130cdf03
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 8080
          periodSeconds: 10
        name: nginx
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 1
          httpGet:
            path: /healthz
            port: 8080
          periodSeconds: 5
        resources:
          limits:
            cpu: 100m
            memory: 64Mi
          requests:
            cpu: 50m
            memory: 32Mi
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          seccompProfile:
            type: RuntimeDefault
        volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: config
          readOnly: true
        - mountPath: /tmp
          name: tmp
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          name: backend
        name: config
      - emptyDir: {}
        name: tmp
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kix.run/depends-on: 95gmkzkbdf1k30pp3k54hp8vc8qd54p8,vz8jvwngqp8ac8synjqn2zcwpmc4ar9k,requires:mkgdf3yajj0a92l7fspcy7ciykw4dsl1
    kix.run/identity-hash: fbrxkfz5xqd1ghkqw363hpvlba42v51s
    kix.run/package: gateway
    kix.run/package-namespace: app-v1
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
    app.kubernetes.io/name: gateway
  name: gateway
  namespace: app-v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: gateway
      app.kubernetes.io/name: gateway
  template:
    metadata:
      labels:
        app.kubernetes.io/instance: gateway
        app.kubernetes.io/name: gateway
    spec:
      containers:
      - image: nginx:1.27-alpine
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 80
          periodSeconds: 10
        name: nginx
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        readinessProbe:
          httpGet:
            path: /healthz
            port: 80
          periodSeconds: 5
        volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: config
          readOnly: true
      volumes:
      - configMap:
          name: gateway
        name: config
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kix.run/depends-on: 883jpjfxsaiclk52hbfgjnakw4im51hm,lxi0gciwfx6mgp92319mjxhjwvgkdqhs
    kix.run/identity-hash: aj39j3ywdkqjcv333nygsj9ijcif6r29
    kix.run/package: backend
    kix.run/package-namespace: app-v2
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
    app.kubernetes.io/name: backend
  name: backend
  namespace: app-v2
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: backend
      app.kubernetes.io/name: backend
  template:
    metadata:
      annotations:
        checksum/config: 4c5192f6b90f0c6e3f49ed9c1a26351e8c39fd59716fd6cc07587071ddaae713
      labels:
        app.kubernetes.io/instance: backend
        app.kubernetes.io/name: backend
    spec:
      containers:
      - image: docker.io/nginxinc/nginx-unprivileged:1.30.6-alpine@sha256:f5116ed4606f3eb015dd4a8e28cb9b351476dc0ad4bc6e9f93b19cec130cdf03
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 8080
          periodSeconds: 10
        name: nginx
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 1
          httpGet:
            path: /healthz
            port: 8080
          periodSeconds: 5
        resources:
          limits:
            cpu: 100m
            memory: 64Mi
          requests:
            cpu: 50m
            memory: 32Mi
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          seccompProfile:
            type: RuntimeDefault
        volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: config
          readOnly: true
        - mountPath: /tmp
          name: tmp
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          name: backend
        name: config
      - emptyDir: {}
        name: tmp
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kix.run/depends-on: lxi0gciwfx6mgp92319mjxhjwvgkdqhs,yypaq64gbsgsgvsqn44b31y2r4lcwrdv,requires:mkgdf3yajj0a92l7fspcy7ciykw4dsl1
    kix.run/identity-hash: 2myic78xhppfhqhkv9xrrpcnrmsh89s2
    kix.run/package: gateway
    kix.run/package-namespace: app-v2
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
    app.kubernetes.io/name: gateway
  name: gateway
  namespace: app-v2
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: gateway
      app.kubernetes.io/name: gateway
  template:
    metadata:
      labels:
        app.kubernetes.io/instance: gateway
        app.kubernetes.io/name: gateway
    spec:
      containers:
      - image: nginx:1.27-alpine
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 80
          periodSeconds: 10
        name: nginx
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        readinessProbe:
          httpGet:
            path: /healthz
            port: 80
          periodSeconds: 5
        volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: config
          readOnly: true
      volumes:
      - configMap:
          name: gateway
        name: config
---
apiVersion: kix.run/v1alpha1
kind: Activation
metadata:
  annotations:
    kix.run/built-via: /nix/store/jr65m3rbsmljs8r0klsq63n1f5czwllq-kix-activation-19-scorecards.json
    kix.run/depends-on: 354i13x5hiwcmf6fkf8wdvyj4v3q78dc,4sq8laq4iq1acp2kfbc1jidw8h96hb2a,6f3b1011md1xifkrcmrrcby0wbpd6ryl,ivxy7wm88944y8sfgyhj4zniyhf2x9iz,mkgdf3yajj0a92l7fspcy7ciykw4dsl1,zmrfvwmay3n1g1awsp87krkmxwy9hlan
    kix.run/identity-hash: q5h4i1ahy6885v4l1rq4bggvnii52ql4
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/managed-by: kix
    kix.run/cluster: 19-scorecards
  name: 19-scorecards-q5h4i1ahy688
spec:
  instances:
    app-v1:
      backend: backend
      gateway: gateway
    app-v2:
      backend: backend
      gateway: gateway
    kube-system:
      platform-dns: platform-dns
      platform-storage: platform-storage
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: 95gmkzkbdf1k30pp3k54hp8vc8qd54p8,l0yvq498zywhzsr2mdcr0bkc5qq5hyai
    kix.run/identity-hash: 354i13x5hiwcmf6fkf8wdvyj4v3q78dc
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
    kix.run/root: backend
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: app-v1
spec:
  instanceName: backend
  namespaceName: app-v1
  package: echo-server
  version: "1.30.6"
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: 95gmkzkbdf1k30pp3k54hp8vc8qd54p8,m6k6gpzaqamfwzvbrxlyzy4k0d2r8l32
    kix.run/identity-hash: 6f3b1011md1xifkrcmrrcby0wbpd6ryl
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
    kix.run/root: gateway
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: app-v1
spec:
  instanceName: gateway
  namespaceName: app-v1
  version: "0.0.2"
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: cahr6h996w8b0wnzwhvjlgws2w2s1k4l,lxi0gciwfx6mgp92319mjxhjwvgkdqhs
    kix.run/identity-hash: ivxy7wm88944y8sfgyhj4zniyhf2x9iz
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
    kix.run/root: backend
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: app-v2
spec:
  instanceName: backend
  namespaceName: app-v2
  package: echo-server
  version: "1.30.6"
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: arf77cch4ssn5l6b27j3dj9w5g58fbar,lxi0gciwfx6mgp92319mjxhjwvgkdqhs
    kix.run/identity-hash: zmrfvwmay3n1g1awsp87krkmxwy9hlan
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
    kix.run/root: gateway
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: app-v2
spec:
  instanceName: gateway
  namespaceName: app-v2
  version: "0.0.2"
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: sj0fv5bs2hnh9zcqdh62ph34l2wm0b1m
    kix.run/identity-hash: mkgdf3yajj0a92l7fspcy7ciykw4dsl1
    kix.run/import-apiversion: v1
    kix.run/import-fqdn: kube-dns.kube-system.svc.cluster.local
    kix.run/import-kind: Service
    kix.run/import-name: kube-dns
    kix.run/mode: import
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/instance: platform-dns
    app.kubernetes.io/managed-by: kix
  name: platform-dns
  namespace: kube-system
spec:
  instanceName: platform-dns
  mode: import
  namespaceName: kube-system
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: sj0fv5bs2hnh9zcqdh62ph34l2wm0b1m
    kix.run/identity-hash: 4sq8laq4iq1acp2kfbc1jidw8h96hb2a
    kix.run/import-apiversion: storage.k8s.io/v1
    kix.run/import-kind: StorageClass
    kix.run/import-name: standard
    kix.run/mode: import
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/instance: platform-storage
    app.kubernetes.io/managed-by: kix
  name: platform-storage
  namespace: kube-system
spec:
  instanceName: platform-storage
  mode: import
  namespaceName: kube-system
---
apiVersion: v1
data:
  default.conf: |
    server {
        listen 8080;
        location / {
            root /etc/nginx/conf.d;
            default_type text/plain;
            try_files /message.txt =404;
            # nginx refuses a POST for a static file with 405. The
            # redirect turns the request into a GET, so every
            # method gets the message.
            error_page 405 =200 /message.txt;
        }
        location /healthz {
            default_type text/plain;
            return 200 'ok\n';
        }
    }
  message.txt: |
    Response from app-v1
kind: ConfigMap
metadata:
  annotations:
    kix.run/depends-on: 95gmkzkbdf1k30pp3k54hp8vc8qd54p8
    kix.run/identity-hash: q85cvsj44a56pxm9cx3naj0ywb4bnmcv
    kix.run/package: backend
    kix.run/package-namespace: app-v1
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: app-v1
---
apiVersion: v1
data:
  default.conf: |
    server {
        listen 80;
        client_max_body_size 10m;

        location /healthz {
            default_type text/plain;
            return 200 'ok\n';
        }
        location /v1/ {
            proxy_pass http://backend.app-v1.svc.cluster.local:80/;
        }
    }
kind: ConfigMap
metadata:
  annotations:
    kix.run/depends-on: 95gmkzkbdf1k30pp3k54hp8vc8qd54p8,l0yvq498zywhzsr2mdcr0bkc5qq5hyai
    kix.run/identity-hash: vz8jvwngqp8ac8synjqn2zcwpmc4ar9k
    kix.run/package: gateway
    kix.run/package-namespace: app-v1
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: app-v1
---
apiVersion: v1
data:
  default.conf: |
    server {
        listen 8080;
        location / {
            root /etc/nginx/conf.d;
            default_type text/plain;
            try_files /message.txt =404;
            # nginx refuses a POST for a static file with 405. The
            # redirect turns the request into a GET, so every
            # method gets the message.
            error_page 405 =200 /message.txt;
        }
        location /healthz {
            default_type text/plain;
            return 200 'ok\n';
        }
    }
  message.txt: |
    Response from app-v2
kind: ConfigMap
metadata:
  annotations:
    kix.run/depends-on: lxi0gciwfx6mgp92319mjxhjwvgkdqhs
    kix.run/identity-hash: 883jpjfxsaiclk52hbfgjnakw4im51hm
    kix.run/package: backend
    kix.run/package-namespace: app-v2
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: app-v2
---
apiVersion: v1
data:
  default.conf: |
    server {
        listen 80;
        client_max_body_size 10m;

        location /healthz {
            default_type text/plain;
            return 200 'ok\n';
        }
        location /v2/ {
            proxy_pass http://backend.app-v2.svc.cluster.local:80/;
        }
    }
kind: ConfigMap
metadata:
  annotations:
    kix.run/depends-on: cahr6h996w8b0wnzwhvjlgws2w2s1k4l,lxi0gciwfx6mgp92319mjxhjwvgkdqhs
    kix.run/identity-hash: yypaq64gbsgsgvsqn44b31y2r4lcwrdv
    kix.run/package: gateway
    kix.run/package-namespace: app-v2
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: app-v2
---
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    kix.run/identity-hash: 95gmkzkbdf1k30pp3k54hp8vc8qd54p8
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/managed-by: kix
    kubernetes.io/metadata.name: app-v1
  name: app-v1
---
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    kix.run/identity-hash: lxi0gciwfx6mgp92319mjxhjwvgkdqhs
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/managed-by: kix
    kubernetes.io/metadata.name: app-v2
  name: app-v2
---
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    kix.run/identity-hash: sj0fv5bs2hnh9zcqdh62ph34l2wm0b1m
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/managed-by: kix
    kubernetes.io/metadata.name: kube-system
  name: kube-system
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    kix.run/depends-on: 011nbqjvmaz0d3nrnq6w3dnv66pfwv1y,95gmkzkbdf1k30pp3k54hp8vc8qd54p8
    kix.run/identity-hash: l0yvq498zywhzsr2mdcr0bkc5qq5hyai
    kix.run/package: backend
    kix.run/package-namespace: app-v1
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: app-v1
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/name: backend
  type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    kix.run/depends-on: 95gmkzkbdf1k30pp3k54hp8vc8qd54p8,fbrxkfz5xqd1ghkqw363hpvlba42v51s
    kix.run/identity-hash: m6k6gpzaqamfwzvbrxlyzy4k0d2r8l32
    kix.run/package: gateway
    kix.run/package-namespace: app-v1
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: app-v1
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/name: gateway
  type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    kix.run/depends-on: aj39j3ywdkqjcv333nygsj9ijcif6r29,lxi0gciwfx6mgp92319mjxhjwvgkdqhs
    kix.run/identity-hash: cahr6h996w8b0wnzwhvjlgws2w2s1k4l
    kix.run/package: backend
    kix.run/package-namespace: app-v2
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: app-v2
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/name: backend
  type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    kix.run/depends-on: 2myic78xhppfhqhkv9xrrpcnrmsh89s2,lxi0gciwfx6mgp92319mjxhjwvgkdqhs
    kix.run/identity-hash: arf77cch4ssn5l6b27j3dj9w5g58fbar
    kix.run/package: gateway
    kix.run/package-namespace: app-v2
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: app-v2
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/name: gateway
  type: ClusterIP

To make error-severity scorecard findings fail the build instead of being capped at "warning", first add maxSeverity = "error"; to tutorials/19-scorecards/scorecard.nix:

tutorials/19-scorecards/scorecard.nix
{
enable = true;
maxSeverity = "error";
# ...
}

Next, open tutorials/19-scorecards/cluster.nix and comment out maxBodySize = "10m"; on the gateway in instances.app-v1 so it falls back to the "1m" default:

tutorials/19-scorecards/cluster.nix
gateway = {
package = reverseProxyPackage;
config = {
proxyPath = "/v1/";
# maxBodySize = "10m";
};
deps.backend = ref.app-v1.backend;
};

Now run kix check 19-scorecards:

kix-examples/
❱ kix check 19-scorecards

Because custom.proxyMaxBodySizeMustBeExplicit has severity = "error" and scorecard.maxSeverity = "error" is set, evaluation fails and prints:

[scorecard:custom.proxyMaxBodySizeMustBeExplicit] app-v1/gateway: instance 'gateway' uses the default maxBodySize '1m'. nginx rejects larger request bodies - set this explicitly.

Uncomment maxBodySize = "10m"; in instances.app-v1.gateway.

Next, in tutorials/19-scorecards/cluster.nix, change proxyPath in instances.app-v2.gateway from "/v2/" to "/v1/" so both namespaces claim "/v1/":

tutorials/19-scorecards/cluster.nix
instances.app-v2.gateway = {
package = reverseProxyPackage;
config = {
proxyPath = "/v1/";
maxBodySize = "10m";
};
deps.backend = ref.app-v2.backend;
};

Run kix check 19-scorecards again:

kix-examples/
❱ kix check 19-scorecards

This time, custom.noProxyPathCollision catches the cross-namespace conflict at build time:

[scorecard:custom.noProxyPathCollision] : 2 reverse-proxy gateways share proxyPath '/v1/': app-v1/gateway, app-v2/gateway

Change app-v2’s proxyPath back to "/v2/" and remove maxSeverity = "error"; from tutorials/19-scorecards/scorecard.nix so the example returns to its checked-in state, then run kix check 19-scorecards to verify the cluster passes again.

You completed the 12-part Kix tutorial path:

  • scorecard.enable = true runs compile-time policy checks across your cluster
  • scorecard.maxSeverity ("info", "warning", or "error", defaulting to "warning") caps finding severity across the cluster, and setting maxSeverity = "error" makes error-severity rules fail evaluation
  • level = "package" rules inspect an individual instance’s meta, config, and resources without parsing rendered YAML strings
  • level = "cluster" rules inspect allInstances across all namespaces to catch cross-instance collisions before deployment
  • Browse the How-to guides for step-by-step recipes on secrets, CRDs, Helm chart adoption, NetworkPolicies, and scorecard customization.
  • Read the Explanation pages for deeper dives into the dependency graph, availability synthesis, NetworkPolicy derivation, and Server-Side Apply field ownership.
  • Keep the Reference handy while authoring your own clusters and packages.