Repository navigation
Description
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-alonenamesNetworkPolicyonly. - 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.shruns kube-linter with.kube-linter.yamlon the fixture policy that has egress rules and the type Ingress - THEN The script exits 0, the case
both-types-with-egresspasses with thenetwork-policy-egress-alonefinding, and the last line reads10 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.Zwith the scoped check, and a person pins that tag in dan-petty/homelab, anduv run devops k8s lintruns there - THEN The live check shows the same 153 findings as the run at
40ef403and 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 checkpvc-prune-protectionusesobjectKinds: [PersistentVolumeClaim]. The checknetwork-policy-egress-aloneusesobjectKinds: [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.yamlnames this script as the test of the custom check. The header of the script gives the commandmise 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.objectKindstoNetworkPolicy. Do not exclude the check and do not keepAny. (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.excludeturns 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.
- Chosen: Narrow the scope to
- Does the change add a case to
tests/test-kube-linter-config.sh?: No. The script already runspolicy 1 both-types-with-egressandpolicy 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
dan-petty commentedon Dec 1, 2026
CI lint is near its 300 s limit at 283.5 s, which is CI being very slow.Both fix a CI job configuration, but #34 fixes mise config leakage while this scopes a kube-linter check to NetworkPolicy.devops-cli-service commentedon Dec 1, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Dec 1, 2026
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:
Sources:
devops-cli-service commentedon Dec 1, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.