feat: Add NetworkPolicy support for chains - #3776
Conversation
|
[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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3776 +/- ##
==========================================
- Coverage 25.40% 25.38% -0.03%
==========================================
Files 449 450 +1
Lines 23477 23535 +58
==========================================
+ Hits 5964 5974 +10
- Misses 16822 16870 +48
Partials 691 691
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
| | | egress | UDP+TCP/53 or 5353 | DNS resolver pods | | ||
| | | egress | all | Unrestricted (API server, OCI registries, Sigstore, KMS, storage backends — NP cannot select host-network endpoints) | |
There was a problem hiding this comment.
what's the reason to have a separate policy for DNS if we're allowing egress to all? policy towards egress-all will allow to DNS as well.
There was a problem hiding this comment.
Currently no reason.
In the original ticket definition the egress rule was not allow-all, it was separated to DNS, API, and also 27017 and 8200 specifically for chains.
After it was decided to allow all, I was pretty much following the patterns in othe NP PRs.
I thought leaving it this way to keep the same line as other components, but I can definitly remove the DNS rule.
What do you say? @zakisk
| required: | ||
| - options |
There was a problem hiding this comment.
@ngelman1 I don't see this in MAG network policy PR, why is it needed?
There was a problem hiding this comment.
this is not related to my change. I regenrated the CRDs using ./hack/update-codegen.sh and it comes from there.
I see this commit manually removes it..
let me remove them here as well
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
fdb36ce to
2a5f077
Compare
2a5f077 to
967caab
Compare
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