Skip to content

Conversation

@syedazeez337
Copy link

Summary
Convert legacy aws/require-aws-node-irsa to a CEL ValidatingPolicy under aws-cel/require-aws-node-irsa, with kyverno test fixtures.

What changed

  • Added: aws-cel/require-aws-node-irsa/policy.yaml (CEL ValidatingPolicy)

  • Added tests:

    • aws-cel/require-aws-node-irsa/tests/pass (uses non-aws-node SA → pass)
    • aws-cel/require-aws-node-irsa/tests/fail (uses aws-node SA → fail)
  • No changes to the legacy sample.

Why
Part of the ongoing migration of sample policies to CEL-based types for better performance, native K8s alignment, and clearer testability.

Behavior (parity with legacy)

  • Target: DaemonSet kube-system/aws-node only.
  • Fails when spec.template.spec.serviceAccountName == "aws-node".
  • Mirrors legacy action: validationActions: Audit (equivalent to validationFailureAction: Audit).

Spec details

  • matchConstraints.resourceRules: apps/v1, daemonsets, CREATE|UPDATE
  • matchConditions: name/namespace pinning (kube-system + aws-node)
  • validations[0].expression: object.spec.template.spec.serviceAccountName != "aws-node"

How I tested

# from repo root: sources/policies
kyverno test aws-cel/require-aws-node-irsa/tests/pass
kyverno test aws-cel/require-aws-node-irsa/tests/fail
# both suites: "1 tests passed and 0 tests failed"

Notes

  • This keeps the same user-facing intent as the legacy policy (stop using the shared aws-node SA; use IRSA-specific SA).
  • Happy to adjust if maintainers prefer to require an explicit non-aws-node SA (vs. simply “not equal to aws-node”).

@syedazeez337
Copy link
Author

kyverno_cel

JimBugwadia
JimBugwadia previously approved these changes Oct 22, 2025
@JimBugwadia JimBugwadia enabled auto-merge (squash) October 22, 2025 17:42
@fjogeleit
Copy link
Member

The current test structure is failing our expected structure. @syedazeez337 can you please take a look?

auto-merge was automatically disabled December 30, 2025 18:57

Head branch was pushed to by a user without write access

@syedazeez337 syedazeez337 force-pushed the feat/cel-require-aws-node-irsa branch 2 times, most recently from 8598362 to 002f47d Compare December 30, 2025 19:01
@syedazeez337
Copy link
Author

Hi @fjogeleit
Apologies for this long delay. I have updated with this new change. Let me know.

@syedazeez337 syedazeez337 force-pushed the feat/cel-require-aws-node-irsa branch from 952ed97 to 09f087a Compare December 31, 2025 18:26
Convert legacy aws/require-aws-node-irsa to a CEL ValidatingPolicy under
aws-cel/require-aws-node-irsa, with kyverno test fixtures.

Changes:
- Add ValidatingPolicy at aws-cel/require-aws-node-irsa/require-aws-node-irsa.yaml
- Add chainsaw test with pass/fail/skip scenarios
- Add kyverno-test with pass/fail/skip test results
- Add artifacthub-pkg.yml metadata

Behavior (parity with legacy):
- Target: DaemonSet kube-system/aws-node only
- Fails when spec.template.spec.serviceAccountName == aws-node
- Uses validationActions: Audit

Signed-off-by: Azeez Syed <syedazeez337@gmail.com>
@syedazeez337 syedazeez337 force-pushed the feat/cel-require-aws-node-irsa branch from 09f087a to 7eee43c Compare December 31, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants