feat: Add NetworkPolicy support for chains - #3776
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3776 +/- ##
==========================================
+ Coverage 25.49% 25.54% +0.05%
==========================================
Files 449 450 +1
Lines 23508 23566 +58
==========================================
+ Hits 5994 6021 +27
- Misses 16824 16855 +31
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:
|
|
@ngelman1 have you verified this once on openshift ? |
|
|
||
| // chainsControllerPodSelector matches the tekton-chains-controller Deployment's | ||
| // spec.selector.matchLabels shipped in the upstream release manifest. | ||
| var chainsControllerPodSelector = metav1.LabelSelector{ |
There was a problem hiding this comment.
Can you add e2e for chains network policies please (similar to triggers, etc)
There was a problem hiding this comment.
I added test simialr to triggers with a small difference:
- setup is using
TektonConfiginstead of chain + pipeline, because creating CRs dierclty caused pre-reconciliation failures. - update of the NP is done through config and not directly through chain cause when I tried the latter chain was immediatly reverted by the
tektonConfigreconciler
Also- I named the file 03_tektonchain_networkpolicy_test.go cause I saw this is how the triggers test is named. let me know if I need to change the number
There was a problem hiding this comment.
@jkhelil was triggers e2e test was tested on openshift? I tested on ROSA and kept getting tektonconfig.operator.tekton.dev "config" not found when I tried creating standalone CRs withou TektonConfig like in here https://github.com/tektoncd/operator/blob/main/test/e2e/common/03_tektontrigger_networkpolicy_test.go#L61
There was a problem hiding this comment.
@ngelman1 e2e are running on kind, you need to add the test, and do manual testing on openshift as complementary test
0222aa4 to
c741785
Compare
6fcac66 to
0f2cc56
Compare
0f2cc56 to
fdb36ce
Compare
| @@ -31,6 +31,7 @@ import ( | |||
| pipelineinformer "github.com/tektoncd/operator/pkg/client/informers/externalversions/operator/v1alpha1" | |||
There was a problem hiding this comment.
also for pkg/reconciler/kubernetes/tektonchain/tektonchain.go, I see there is no unit test file for this but it's good to have
There was a problem hiding this comment.
should I create the file and only test NP related things, or add tets for the entire file? (out of scope here?)
There was a problem hiding this comment.
reconciliation is also tested in e2e
There was a problem hiding this comment.
you can just write unit tests for your changes and do for others in separate PR if you want
There was a problem hiding this comment.
added pkg/reconciler/kubernetes/tektonchain/networkpolicies_test.go
fdb36ce to
2a5f077
Compare
7ce5f60 to
bdab246
Compare
|
@ngelman1 you've conflict on this with recent merge on main. |
bdab246 to
ae07ba8
Compare
|
@ngelman1: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zakisk 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 |
Changes
Implements NetworkPolicy resources to restrict network access for the Tekton Chains controller.
Adds a
spec.networkPolicyfield toTektonChainSpec(propagated fromTektonConfig) and a newpkg/reconciler/kubernetes/tektonchain/networkpolicies.gothat reconciles default-deny + allow policies in the operand namespace.
Default policies for the Chains controller pod:
Both platforms (Kubernetes and OpenShift) are supported via the existing
networkpolicy.PlatformParamshelper. Updates generated CRDs/Helm chart output anddocs/NetworkPolicy.md.Ref: SRVKP-12056
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