[WIP] feat: add NetworkPolicy support for TektonTrigger#3531
Open
khrm wants to merge 2 commits into
Open
Conversation
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Introduce NetworkPolicyConfig struct embedded in component specs, allowing operators to disable NetworkPolicies or override individual policies by name. Add pkg/reconciler/common/networkpolicy with: - platform.go: PlatformParams for Kubernetes and OpenShift DNS/Prometheus defaults - networkpolicy.go: Generate() with map-merge and deterministic sorted output - networkpolicy_test.go: 13 unit tests covering merge, disable, and rule helpers Wire NetworkPolicyConfig into TektonTriggerSpec and TektonConfigSpec (reconciler integration for TektonConfig is deferred). Regenerate zz_generated.deepcopy.go. Signed-off-by: Khurram Baig <khurram.baig@gmail.com> Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Add triggersDefaultPolicies() defining four NetworkPolicies for the
Triggers workloads (controller, webhook, core-interceptors ingress,
core-interceptors egress). Platform-specific DNS and Prometheus values
are resolved at controller startup via v1alpha1.IsOpenShiftPlatform().
reconcileNetworkPolicies() applies policies as a named CustomSet
("triggers-network-policies") or cleans it up when disabled.
Signed-off-by: Khurram Baig <khurram.baig@gmail.com>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
a483385 to
2c504d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Changes:
Introduces opt-in NetworkPolicy support for the TektonTrigger component.
New shared infrastructure (
pkg/reconciler/common/networkpolicy):NetworkPolicyConfigAPI type embedded in component specs — supportsdisabledflag and per-policy overrides via apoliciesmapGenerate()— merges user-supplied policies over defaults with deterministic sorted output for stable InstallerSet checksumsDefaultDenyPolicy()— shared helper for component-scoped or namespace-wide default-deny policiesPlatformParams) for Kubernetes and OpenShift DNS resolver and Prometheus namespace selectorsDNSEgressRule,APIServerEgressRule,InternetEgressRule,PrometheusIngressRule,WebhookIngressRuleTektonTrigger wiring:
triggers-network-policies):tekton-default-deny— default-deny scoped toapp.kubernetes.io/part-of: tekton-triggerspods (temporary; will move to TektonPipeline and become namespace-wide once all componentsimplement NP support)
triggers-controller— allows Prometheus ingress on port 9000triggers-webhook— allows webhook ingress on 8443 and Prometheus ingress on 9000triggers-core-interceptors— allows ingress on 8443 from all namespaces (EventListeners are user-controlled)triggers-core-interceptors-egress-internet— allows egress on TCP 80/443 for external API callsv1alpha1.IsOpenShiftPlatform()at controller startup; no extra parameters threaded through public APIsspec.networkPolicy.disabled: truecleans up all policiesNetworkPolicyConfigfield also added toTektonConfigSpec(reconciler integration deferred)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