Skip to content

feat(manualapprovalgate): add NetworkPolicy support - #3801

Merged
tekton-robot merged 1 commit into
tektoncd:mainfrom
divyansh42:network-policy-mag
Aug 5, 2026
Merged

feat(manualapprovalgate): add NetworkPolicy support#3801
tekton-robot merged 1 commit into
tektoncd:mainfrom
divyansh42:network-policy-mag

Conversation

@divyansh42

@divyansh42 divyansh42 commented Jul 23, 2026

Copy link
Copy Markdown
Member

Changes

Add default-deny, controller, and webhook NetworkPolicies for the ManualApprovalGate component, following the same pattern used by TektonTrigger and TektonPipeline. Policies are reconciled via a CustomSet and respect the spec.networkPolicy toggle for disabling and custom overrides. Includes validation, cleanup on CR deletion, e2e test, CRD schema updates, and documentation.

Assisted-by: Claude Opus 4.6 (via Cursor)

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

ManualApprovalGate now creates default NetworkPolicies that restrict ingress/egress for its controller and webhook pods. These are enabled by default. To opt out, set `spec.networkPolicy.disabled: true` on the ManualApprovalGate CR.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jul 23, 2026
@divyansh42
divyansh42 marked this pull request as draft July 23, 2026 07:29
@tekton-robot
tekton-robot requested review from jkhelil and khrm July 23, 2026 07:29
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jul 23, 2026
@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.36%. Comparing base (dfd582f) to head (7e33bbb).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3801      +/-   ##
==========================================
- Coverage   25.45%   25.36%   -0.10%     
==========================================
  Files         451      453       +2     
  Lines       23666    23750      +84     
==========================================
  Hits         6024     6024              
- Misses      16951    17035      +84     
  Partials      691      691              
Flag Coverage Δ
unit-tests 25.36% <ø> (-0.10%) ⬇️

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds first-class NetworkPolicy management for the ManualApprovalGate component, aligning it with existing operator support for TektonPipeline and TektonTrigger. It introduces default-deny plus workload-scoped policies, wires reconciliation/cleanup via an InstallerSet CustomSet, and exposes configuration via spec.networkPolicy on the ManualApprovalGate CR.

Changes:

  • Add reconciliation + finalizer cleanup for ManualApprovalGate NetworkPolicies using a CustomSet("mag-network-policies", ...).
  • Extend the ManualApprovalGate API with spec.networkPolicy including validation + deepcopy generation, and update CRD schemas/Helm templates accordingly.
  • Add e2e coverage and update NetworkPolicy documentation to include ManualApprovalGate defaults and configuration.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/e2e/common/06_manualapprovalgate_networkpolicy_test.go Adds an e2e test that asserts MAG NetworkPolicies are created by default and removed/restored when toggling spec.networkPolicy.disabled.
pkg/reconciler/kubernetes/manualapprovalgate/reconcile.go Invokes NetworkPolicy reconciliation after the main InstallerSet is applied.
pkg/reconciler/kubernetes/manualapprovalgate/networkpolicies.go Defines default MAG NetworkPolicies and reconciles them via an InstallerSet CustomSet, respecting spec.networkPolicy.disabled and overrides.
pkg/reconciler/kubernetes/manualapprovalgate/finalize.go Cleans up the MAG NetworkPolicy CustomSet on CR deletion.
pkg/reconciler/kubernetes/manualapprovalgate/controller.go Initializes platform-specific NetworkPolicy parameters (Kubernetes vs OpenShift) for rule generation.
pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go Ensures ManualApprovalGateSpec.NetworkPolicy is deep-copied.
pkg/apis/operator/v1alpha1/manualapprovalgate_validation.go Adds validation for one-instance naming plus spec.networkPolicy validation.
pkg/apis/operator/v1alpha1/manualapprovalgate_types.go Adds the networkPolicy field to the ManualApprovalGate spec.
docs/NetworkPolicy.md Documents the new MAG policies and configuration on the MAG CR.
config/base/generated-crds/operator.tekton.dev_manualapprovalgates.yaml Updates the generated CRD schema to include spec.networkPolicy.
charts/tekton-operator/templates/openshift-crds.yaml Updates Helm-rendered OpenShift CRD schema for spec.networkPolicy.
charts/tekton-operator/templates/kubernetes-crds.yaml Updates Helm-rendered Kubernetes CRD schema for spec.networkPolicy.
Files not reviewed (1)
  • pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/e2e/common/06_manualapprovalgate_networkpolicy_test.go Outdated
Comment thread test/e2e/common/06_manualapprovalgate_networkpolicy_test.go
@divyansh42
divyansh42 force-pushed the network-policy-mag branch from deb2752 to be1d244 Compare July 23, 2026 18:02
@divyansh42
divyansh42 marked this pull request as ready for review July 24, 2026 06:11
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 24, 2026
@divyansh42
divyansh42 force-pushed the network-policy-mag branch from be1d244 to 4c3b0ba Compare July 24, 2026 06:11
@divyansh42

Copy link
Copy Markdown
Member Author

I have manually tested this on OpenShift.

@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
Comment thread pkg/apis/operator/v1alpha1/manualapprovalgate_validation.go Outdated
@divyansh42
divyansh42 force-pushed the network-policy-mag branch from 4c3b0ba to 973134f Compare July 24, 2026 13:14
Comment thread docs/NetworkPolicy.md

@khrm khrm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you run code gen ?

@divyansh42

Copy link
Copy Markdown
Member Author

Did you run code gen ?

Yes, it is already done.

@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 3, 2026

@khrm khrm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please rebase with main.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 3, 2026
Add default-deny, controller, and webhook NetworkPolicies for the
ManualApprovalGate component, following the same pattern used by
TektonTrigger and TektonPipeline. Policies are reconciled via a
CustomSet and respect the spec.networkPolicy toggle for disabling
and custom overrides. Includes validation, cleanup on CR deletion,
e2e test, CRD schema updates, and documentation.

Signed-off-by: divyansh42 <diagrawa@redhat.com>
Assisted-by: Claude Opus 4.6 (via Cursor)
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 5, 2026
@divyansh42

Copy link
Copy Markdown
Member Author

Please rebase with main.

Done

@jkhelil

jkhelil commented Aug 5, 2026

Copy link
Copy Markdown
Member

/approve

@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jkhelil

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2026
@enarha

enarha commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2026
@tekton-robot
tekton-robot merged commit 602531e into tektoncd:main Aug 5, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/misc Categorizes issue or PR as a miscellaneuous one. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

7 participants