feat: add NetworkPolicy template - #8052
Conversation
|
✅ All required contributors have signed the F5 CLA for this PR. Thank you! |
|
I have hereby read the F5 CLA and agree to its terms |
|
Hi @GabboPenna, Thanks for this PR, Can you please create an issue for this so we can track it appropriately. |
Hi @AlexFenlon, i open a new issue: #8060 |
|
hi @GabboPenna, can you please also update:
|
|
This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
This PR was closed because it has been stalled for 10 days with no activity. |
Hi, sorry for the delay: Let me know if I need to do anything else. |
|
I looked at https://github.com/nginx/kubernetes-ingress/blob/main/charts/nginx-ingress/templates/controller-pdb.yaml#L14-L16 Additionally, we can simplify What do you think? |
|
Hi @GabboPenna! This PR / Issue pair came up in our community call. There is a pending comment waiting for your input. Let us know what you think of the suggestions! Thank you! |
|
This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
This PR was closed because it has been stalled for 10 days with no activity. |
|
Hi @haywoodsh, apologies for the long delay. I agree with your suggestions and have updated the PR accordingly. The I verified the changes locally with Helm v3.21.2 using the full chart test suite and Thanks for reopening the PR and for your patience. Please let me know if anything else needs adjusting. |
There was a problem hiding this comment.
Pull request overview
Adds optional NetworkPolicy support to the charts/nginx-ingress Helm chart, allowing consumers to define ingress/egress rules for the controller pods via values.yaml while keeping label selection consistent with the chart’s controller workload.
Changes:
- Introduces
controller.networkPolicyvalues (enabled/ingress/egress) and corresponding JSON schema validation. - Adds a
controller-networkpolicy.yamltemplate that targets controller pods vianginx-ingress.selectorLabelsand auto-populatespolicyTypesbased on configured rules. - Extends Helm unit snapshot coverage with new test value sets and updated snapshots.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| charts/nginx-ingress/templates/controller-networkpolicy.yaml | New NetworkPolicy template gated by controller.networkPolicy.enabled, with selectorLabels-based pod selection and optional ingress/egress sections. |
| charts/nginx-ingress/values.yaml | Adds controller.networkPolicy configuration knobs and inline documentation. |
| charts/nginx-ingress/values.schema.json | Adds schema for controller.networkPolicy, referencing k8s NetworkPolicy rule definitions. |
| charts/tests/helmunit_test.go | Adds Helm unit test cases for NetworkPolicy disabled, ingress-only, and ingress+egress scenarios. |
| charts/tests/testdata/network-policy-disabled.yaml | Test values for NetworkPolicy disabled case. |
| charts/tests/testdata/network-policy-ingress.yaml | Test values for ingress-only NetworkPolicy. |
| charts/tests/testdata/network-policy-ingress-egress.yaml | Test values for ingress+egress NetworkPolicy. |
| charts/tests/snapshots/helmunit_test.snap | Updates snapshots to cover the new NetworkPolicy template output. |
|
Hi @GabboPenna, thanks for coming back to this PR! great to see you again. we really appreciate that you addressed the feedback, we will look into this as soon as we can! |
|
/approve-pipeline-run |
|
/approve-pipeline-run |
Proposed changes
This PR adds optional NetworkPolicy support to the nginx-ingress Helm chart.
It introduces:
controller.networkPolicysection invalues.yamlwith:enabledflag.ingressandegressrules.podSelectorfromnginx-ingress.selectorLabelsso it targets the correct controller pods.policyTypesgeneration based on whether ingress and/or egress rules are configured.With this change, chart consumers can declare fine-grained network controls for their Ingress Controller pods without maintaining external manifests.
Fixes: #8060
Checklist
helm lintpassmain