feat(openshiftpipelinesascode): add NetworkPolicy support - #3828
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3828 +/- ##
==========================================
- Coverage 25.49% 25.41% -0.09%
==========================================
Files 449 450 +1
Lines 23508 23607 +99
==========================================
+ Hits 5994 5999 +5
- Misses 16824 16918 +94
Partials 690 690
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5360c80 to
8a6b8fd
Compare
|
/ok-to-test |
8a6b8fd to
7a83249
Compare
khrm
left a comment
There was a problem hiding this comment.
Can you also update release note?
| @@ -0,0 +1,128 @@ | |||
| # Copyright 2025 The Tekton Authors | |||
There was a problem hiding this comment.
it's generated and I think the copyright notice is taken from original file from where it's generated and year shows when this file is copied
| @@ -0,0 +1,132 @@ | |||
| /* | |||
| Copyright 2024 The Tekton Authors | |||
There was a problem hiding this comment.
Pull request overview
This PR adds first-class NetworkPolicy reconciliation for the OpenShift Pipelines-as-Code (OpenShiftPipelinesAsCode) component, aligning it with existing NetworkPolicy support patterns in the operator (e.g., TektonPipeline / TektonTrigger). It wires the NetworkPolicy config through the API surface, reconciler, tests, and documentation.
Changes:
- Introduces default-deny + per-workload NetworkPolicies for OpenShift Pipelines-as-Code and reconciles them via an InstallerSet CustomSet, respecting
spec.networkPolicy.disabled. - Propagates
spec.networkPolicyfromTektonConfiginto theOpenShiftPipelinesAsCodeCR and adds validation + deepcopy support for the new field. - Adds E2E/unit tests and updates NetworkPolicy documentation and generated CRD/chart schemas.
Reviewed changes
Copilot reviewed 26 out of 28 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/common/11_openshiftpipelinesascode_networkpolicy_test.go | Adds E2E coverage for PAC NetworkPolicy create/disable/re-enable. |
| pkg/reconciler/shared/tektonconfig/pipelinesascode/pipelinesascode.go | Propagates TektonConfig networkPolicy into the OpenShiftPipelinesAsCode spec. |
| pkg/reconciler/openshift/openshiftpipelinesascode/reconcile.go | Hooks NetworkPolicy reconciliation into PAC reconciler flow. |
| pkg/reconciler/openshift/openshiftpipelinesascode/networkpolicies.go | Defines PAC default NetworkPolicies and reconciles them via CustomSet. |
| pkg/reconciler/openshift/openshiftpipelinesascode/controller.go | Initializes platform-specific NetworkPolicy parameters for PAC reconciler. |
| pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go | Adds DeepCopy support for the new NetworkPolicy field in PAC spec. |
| pkg/apis/operator/v1alpha1/openshiftpipelinesascode_validation.go | Validates spec.networkPolicy for OpenShiftPipelinesAsCode. |
| pkg/apis/operator/v1alpha1/openshiftpipelinesascode_validation_test.go | Adds unit tests for NetworkPolicyConfig validation behavior. |
| pkg/apis/operator/v1alpha1/openshiftpipelinesascode_types.go | Extends PAC API type with spec.networkPolicy. |
| docs/NetworkPolicy.md | Documents default PAC policies and expected ingress/egress behavior. |
| config/openshift/base/300-operator_v1alpha1_openshiftpipelinesascode_crd.yaml | CRD schema includes spec.networkPolicy for PAC (OpenShift base). |
| config/openshift/base/300-operator_v1alpha1_addon_crd.yaml | Adds/updates CRD manifest in OpenShift base bundle. |
| config/kubernetes/base/300-operator_v1alpha1_dashboard_crd.yaml | Adds/updates CRD manifest in Kubernetes base bundle. |
| config/base/generated-crds/operator.tekton.dev_tektonconfigs.yaml | Updates generated TektonConfig CRD schema text for NetworkPolicy. |
| config/base/generated-crds/operator.tekton.dev_openshiftpipelinesascodes.yaml | Updates generated PAC CRD schema to include spec.networkPolicy. |
| config/base/300-operator_v1alpha1_trigger_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_syncerservice_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_scheduler_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_result_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_pruner_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_pipeline_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_multiclusterproxyaae_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_manualapprovalgate_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_installer_set_crd.yaml | Adds/updates CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_config_crd.yaml | Adds/updates TektonConfig CRD manifest in base bundle. |
| config/base/300-operator_v1alpha1_chain_crd.yaml | Adds/updates CRD manifest in base bundle. |
| charts/tekton-operator/templates/kubernetes-crds.yaml | Updates Helm chart CRD templates for PAC + TektonConfig schema text. |
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.
|
/hold |
Why this diff touches 14 unrelated CRDsMost of this PR's ~8,900 lines have nothing to do with the NetworkPolicy feature. The only intentional CRD change is Root cause: I've opened #3842 to fix the script so it stops reviving the dead manual CRDs. Two ways to unblock this PR, whichever is faster for you:
Either way, please see the follow-up comment below — there's one regression hiding in the regenerated CRDs that needs fixing regardless of which path you take. |
🔴 Regression hiding in the regenerated CRDs:
|
|
/unhold |
7a83249 to
f2a2982
Compare
|
New changes are detected. LGTM label has been removed. |
4c1b56f to
18c8f31
Compare
|
@jkhelil addressed your comments! |
18c8f31 to
448d72a
Compare
|
the failing test |
Add default-deny and per-pod NetworkPolicies for the three OpenShiftPipelinesAsCode workloads (controller, watcher, webhook), following the pattern established by TektonPipeline and TektonTrigger. Default policies: - pac-default-deny: deny all traffic to pods with app.kubernetes.io/part-of=pipelines-as-code - pac-controller: allow Prometheus metrics ingress (TCP/9090), Git provider webhook ingress (TCP/8082), DNS egress, API server egress, and internet egress (TCP/80,443) - pac-watcher: allow Prometheus metrics ingress (TCP/9090), DNS egress, API server egress, and internet egress (TCP/80,443) - pac-webhook: allow admission webhook ingress (TCP/8443), Prometheus metrics ingress (TCP/9090), DNS egress, and API server egress Policies are reconciled via InstallerSet.CustomSet and respect the spec.networkPolicy.disabled toggle. The NetworkPolicy field is propagated from TektonConfig to the OpenShiftPipelinesAsCode CR. Includes unit tests for NetworkPolicyConfig validation, an E2E test for policy creation/disable/re-enable, and updated NetworkPolicy documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
448d72a to
6320c6f
Compare
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Add default-deny and per-pod NetworkPolicies for the three OpenShiftPipelinesAsCode workloads (controller, watcher, webhook), following the pattern established by TektonPipeline and TektonTrigger.
Default policies:
Policies are reconciled via InstallerSet.CustomSet and respect the spec.networkPolicy.disabled toggle. The NetworkPolicy field is propagated from TektonConfig to the OpenShiftPipelinesAsCode CR.
Includes unit tests for NetworkPolicyConfig validation, an E2E test for policy creation/disable/re-enable, and updated NetworkPolicy documentation.
Changes
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make test lintbefore submitting a PRSee the contribution guide for more details.
Release Notes