Skip to content

fix(ci): scope the egress policy lint check to NetworkPolicy #69

Backlog

Description

@dan-petty

Problem

The check network-policy-egress-alone in .kube-linter.yaml has the scope objectKinds: [Any]. So kube-linter runs its CEL expression on each object, and a large CustomResourceDefinition makes that slow. The expression reads only a NetworkPolicy.

The lint of all chart sources of devops k8s lint is then near its limit of 300 s (dan-petty/devops-cli#7900).

Evidence

kube-linter 0.8.3 on the environment tree of dan-petty/homelab at 40ef403 (108 CustomResourceDefinitions), one run each, on 2026-12-01:

Run Wall time CPU time Lint errors
All documents 283.5 s 371.8 s 153
No CustomResourceDefinitions 38.5 s 50.3 s 153
All documents, check scoped to NetworkPolicy 56.4 s 63.9 s 153

With the scope NetworkPolicy, the check still reports a bad NetworkPolicy.

Acceptance criteria

  • The scope of network-policy-egress-alone names NetworkPolicy only.
  • The test of the config shows that the check still refuses a NetworkPolicy with egress rules and the type Ingress.
  • A release holds the change, and dan-petty/homelab pins it.

Source

Source: dan-petty/devops-cli#8003

Alternatives check of 2026-12-01: in-use.
The item already names this tool.
Tool: kube-linter (https://github.com/stackrox/kube-linter), Apache-2.0, last activity 2026-11-25, maintained.
Reason: kube-linter 0.8.3 already covers the need. Its scope.objectKinds field narrows the check to NetworkPolicy, keeps the same 153 findings, and cuts the run to 56.4 s. The issue names kube-linter as its tool.

Covers:

  • scope.objectKinds narrows a custom check to one object kind
  • The CEL check still reports a bad NetworkPolicy under the narrow scope
  • The scoped run keeps the same 153 lint findings

Lacks:

  • The config author must set the scope by hand
  • No guard against slow CEL runs on large CustomResourceDefinition trees
  • The 300 s limit of the devops CLI stays

Proposed design

Problem statement

The custom check network-policy-egress-alone in .kube-linter.yaml has the scope objectKinds: [Any]. kube-linter then runs the CEL expression of the check on each object of a rendered tree. A large CustomResourceDefinition makes that run slow. The lint of all chart sources of devops k8s lint is then near its limit of 300 s. The change narrows the scope of the check to NetworkPolicy.

Acceptance criteria

Requirement: Scope of the egress check

The custom check network-policy-egress-alone in .kube-linter.yaml MUST name NetworkPolicy only in scope.objectKinds.

Scenario: The scoped check still refuses a bad NetworkPolicy

  • WHEN mise exec -- tests/test-kube-linter-config.sh runs kube-linter with .kube-linter.yaml on the fixture policy that has egress rules and the type Ingress
  • THEN The script exits 0, the case both-types-with-egress passes with the network-policy-egress-alone finding, and the last line reads 10 of 10 cases passed

Requirement: Pending a person after the merge

A release of this repository SHALL hold the scoped check, and dan-petty/homelab MUST pin that release tag.

Scenario: The homelab lint runs inside its limit

  • WHEN release-please publishes the next tag vX.Y.Z with the scoped check, and a person pins that tag in dan-petty/homelab, and uv run devops k8s lint runs there
  • THEN The live check shows the same 153 findings as the run at 40ef403 and finishes in less than 120 s

Existing Tool Considered

kube-linter (https://github.com/stackrox/kube-linter) covers the need. The alternatives check of 2026-12-01 in the issue body gives the verdict in-use, because the item already names this tool. That block holds what the tool covers and what it lacks. The change builds no code: it edits one line of .kube-linter.yaml and runs the existing test tests/test-kube-linter-config.sh. The change sets scope.objectKinds by hand to [NetworkPolicy]; that is the first item of the block's Lacks: list. The block also records that no guard exists against slow CEL runs on large CustomResourceDefinition trees and that the 300 s limit of the devops CLI stays; this change does not address those two items.

Key questions

  • Which field scopes a kube-linter custom check to one object kind?: scope.objectKinds. The check pvc-prune-protection uses objectKinds: [PersistentVolumeClaim]. The check network-policy-egress-alone uses objectKinds: [Any]. The change sets the second one to [NetworkPolicy]. [sources: .kube-linter.yaml:36, .kube-linter.yaml:51]
  • Where does this repository test the custom checks of the config?: In tests/test-kube-linter-config.sh. The header of .kube-linter.yaml names this script as the test of the custom check. The header of the script gives the command mise exec -- tests/test-kube-linter-config.sh. [sources: .kube-linter.yaml:4, tests/test-kube-linter-config.sh]
  • How does the change cut the lint time?: Narrow scope.objectKinds to NetworkPolicy. Do not exclude the check and do not keep Any. (best practice) [sources: .kube-linter.yaml:12, .kube-linter.yaml:51]
    • Chosen: Narrow the scope to NetworkPolicy. The CEL expression reads only a NetworkPolicy. The evidence of the issue shows 56.4 s in place of 283.5 s, with the same 153 findings.
    • Rejected: Exclude the check with checks.exclude. checks.exclude turns a check off for all objects. The header of the file forbids that use to pass a finding.
    • Rejected: Keep the scope Any. The lint stays at 283.5 s and near the 300 s limit.
  • Does the change add a case to tests/test-kube-linter-config.sh?: No. The script already runs policy 1 both-types-with-egress and policy 0 egress-only. The first case asserts the finding for the type Ingress. The second case asserts no finding for the type Egress only. The narrow scope reports the same findings, so the change runs the script as it is. (best practice) [sources: tests/test-kube-linter-config.sh, .kube-linter.yaml:54]
    • Chosen: Keep the existing cases and add none. The two cases already cover both forms of the policy, and the narrowed scope reports the same findings.
    • Rejected: Add a CustomResourceDefinition fixture case. The CEL expression returns an empty string for an object that is not a NetworkPolicy, so the case asserts no difference.
  • Does the change keep the object.kind == "NetworkPolicy" test in the CEL expression?: Keep it. The scope now selects NetworkPolicy objects only. The test costs nothing and keeps the expression correct when a caller copies it. (best practice) [sources: .kube-linter.yaml:54]
    • Chosen: Keep the kind test in the CEL expression. It is correct under the new scope and protects a caller that copies the expression.
    • Rejected: Remove the kind test. The issue does not ask for it, and it brings no gain.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    status/new
    value/high
    on Dec 1, 2026
  2. dan-petty commented on Dec 1, 2026

    @dan-petty
    OwnerAuthor
    • Priority: CI lint is near its 300 s limit at 283.5 s, which is CI being very slow.
    • Related: fix(ci): keep the caller mise config out of K8s Validate #34, which asks for a different change. Both fix a CI job configuration, but #34 fixes mise config leakage while this scopes a kube-linter check to NetworkPolicy.
  3. added
    effort/low
    source/agent
    scope/ci
    priority/p0-critical
    on Dec 1, 2026
  4. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (8)

    Tools considered:

    Searches run:

    • kube-linter custom check scope objectKinds NetworkPolicy, results: 5
    • kube-linter custom check configuration objectKinds scope documentation, results: 5
    • kube-linter customChecks scope objectKinds example yaml, results: 5
    • kube-linter documentation, results: 5
    • stackrox kube-linter custom check cel, results: 5
    • kube-linter objectKinds Any NetworkPolicy customChecks scope, results: 5
    • kube-linter NetworkPolicy egress lint check, results: 5
    • docs.kubelinter.io custom checks, results: 5

    Sources:

  6. added
    status/ready
    and removed
    status/new
    on Dec 1, 2026
  7. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. added
    owner/service
    and removed
    owner/service
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p0-criticalscope/cisource/agentstatus/readytype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions