Skip to content

feat(pruner): add NetworkPolicy for controller and webhook - #3795

Open
infernus01 wants to merge 1 commit into
tektoncd:mainfrom
infernus01:pruner-network-policy
Open

feat(pruner): add NetworkPolicy for controller and webhook#3795
infernus01 wants to merge 1 commit into
tektoncd:mainfrom
infernus01:pruner-network-policy

Conversation

@infernus01

Copy link
Copy Markdown
Member

Changes

  • Adds spec.networkPolicy to TektonPruner
  • Reconciles three default NetworkPolicies: a scoped default-deny for all pruner (app.kubernetes.io/part-of: tekton-pruner), a controller allow policy (Prometheus metrics ingress on TCP/9090, unrestricted egress), and a webhook allow policy (admission callbacks on TCP/8443, Prometheus metrics on TCP/9090, unrestricted egress)
  • Propagates spec.networkPolicy from TektonConfigTektonPruner, so disabled: true on TektonConfig removes polcies
  • Cleans up the pruner-network-policies CustomSet on TektonPruner CR deletion

Egress is unrestricted because the pruner controller needs API server access to list, watch, and delete PipelineRun/TaskRun resources across namespaces, and NetworkPolicy cannot select endpoints on the host network.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

NONE

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 22, 2026
@tekton-robot
tekton-robot requested a review from divyansh42 July 22, 2026 11:00
@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Jul 22, 2026
@tekton-robot
tekton-robot requested a review from pratap0007 July 22, 2026 11:00
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign jkhelil after the PR has been reviewed.
You can assign the PR to them by writing /assign @jkhelil in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 22, 2026
@infernus01
infernus01 force-pushed the pruner-network-policy branch from 9e5eed7 to d09b01e Compare July 22, 2026 11:03
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2026
Comment thread pkg/reconciler/kubernetes/tektonpruner/networkpolicies.go
@infernus01
infernus01 force-pushed the pruner-network-policy branch from d09b01e to 26953d8 Compare July 23, 2026 16:03
@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 25.32%. Comparing base (3d8e72a) to head (834246f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3795      +/-   ##
==========================================
- Coverage   25.40%   25.32%   -0.08%     
==========================================
  Files         449      450       +1     
  Lines       23477    23555      +78     
==========================================
+ Hits         5964     5966       +2     
- Misses      16822    16897      +75     
- Partials      691      692       +1     
Flag Coverage Δ
unit-tests 25.32% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jkhelil

jkhelil commented Jul 24, 2026

Copy link
Copy Markdown
Member

@infernus01
Add validation to pkg/apis/operator/v1alpha1/tektonpruner_validation.go
Fix: add errs = errs.Also(tp.Spec.NetworkPolicy.validate("spec.networkPolicy")) to TektonPruner.Validate().

type: string
type: object
type: array
required:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change ? can you rerun ./hack/update-codegen.sh/

@jkhelil

jkhelil commented Jul 24, 2026

Copy link
Copy Markdown
Member

@infernus01 Add Release note

@jkhelil

jkhelil commented Jul 24, 2026

Copy link
Copy Markdown
Member

/kind misc

@tekton-robot tekton-robot added the kind/misc Categorizes issue or PR as a miscellaneuous one. label Jul 24, 2026
Signed-off-by: Shubham Bhardwaj <shubbhar@redhat.com>
@infernus01
infernus01 force-pushed the pruner-network-policy branch from 26953d8 to 834246f Compare July 24, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. kind/misc Categorizes issue or PR as a miscellaneuous one. release-note-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants