Add NetworkPolicy controller to restrict operator pod traffic - #110
Add NetworkPolicy controller to restrict operator pod traffic#110ompushkara wants to merge 5 commits into
Conversation
Introduce a self-healing NetworkPolicy reconciler that enforces ingress (9443, 8081) and egress (DNS, HTTPS, K8s API) rules on the operator pod. The controller watches for drift and recreates or updates the policy automatically. Includes RBAC permissions, POD_NAMESPACE downward API injection, unit tests, and test utility updates for NetworkPolicy scheme.
PR Summary by QodoAdd self-healing NetworkPolicy reconciler for operator pod traffic
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
==========================================
+ Coverage 33.68% 36.34% +2.65%
==========================================
Files 19 20 +1
Lines 1879 1992 +113
==========================================
+ Hits 633 724 +91
- Misses 1202 1223 +21
- Partials 44 45 +1
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:
|
Code Review by Qodo
1.
|
Signed-off-by: ompushkara <omotilal@redhat.com> Add OLM upgrade version logic instead of manually hardcoding
4058d9a to
a75aa92
Compare
Signed-off-by: ompushkara <omotilal@redhat.com>
NetworkPolicy ControllerAdds a self-healing Ingress (allowed inbound traffic)
All other inbound traffic is denied. Egress (allowed outbound traffic)
All other outbound traffic is denied. Additional changes
|
|
Code review by qodo was updated up to the latest commit 8c4b9ef |
Signed-off-by: ompushkara <omotilal@redhat.com>
NetworkPolicy SummaryThe operator dynamically creates a Ingress (incoming traffic to operator pod)
Egress (outgoing traffic from operator pod)
Self-healingThe controller watches the NetworkPolicy resource and automatically recreates it if deleted or modified. |
miyunari
left a comment
There was a problem hiding this comment.
thanks @ompushkara, almost looking good to me. Only one thing we may should re-think. If the operator comes up and sets up a network policy for itself, I think we dont need an extra networkpolicy reconciler?
Lets run a simple routine at startup to install the NP. wdyt?
Instead of a dedicated controller that watches and reconciles the NetworkPolicy, install it once at operator startup using a direct client call. This simplifies the codebase while achieving the same result — the operator's NetworkPolicy is created or updated before the manager starts. Signed-off-by: ompushkara <omotilal@redhat.com>
|
@miyunari , Yeah good one 💯 Replaced the reconciler with a simple startup routine that installs the NetworkPolicy when the operator comes up and tested in 4.21 |
Introduce a self-healing NetworkPolicy reconciler that enforces ingress (9443, 8081) and egress (DNS, HTTPS, K8s API) rules on the operator pod. The controller watches for drift and recreates or updates the policy automatically. Includes RBAC permissions, POD_NAMESPACE downward API injection, unit tests, and test utility updates for NetworkPolicy scheme.