Skip to content

Add NetworkPolicy for destination mover pods - #31

Merged
Rakshith-R merged 2 commits into
RamenDR:mainfrom
Rakshith-R:mover-network-policy
Oct 30, 2026
Merged

Rakshith-R merged 2 commits into
RamenDR:mainfrom
Rakshith-R:mover-network-policy

Conversation

@Rakshith-R

Copy link
Copy Markdown
Collaborator

Summary

Restrict ingress to destination mover pods and stop exposing the plaintext gRPC backend outside the pod.

  • fix(worker): bind plaintext gRPC server to loopback. The destination gRPC server on 8080 listened on all interfaces. Its only client is stunnel on 127.0.0.1, so it now binds 127.0.0.1.
  • feat(mover): add NetworkPolicy for destination mover pods. The mover now creates a NetworkPolicy per ReplicationDestination, named like the mover Service and owned by the RD.
    • podSelector: the mover Service selector
    • Ingress: TCP 8000 (stunnel TLS), 8081 (direct mTLS), and 8873 (rsync stunnel, CephFS only), from any peer
    • Egress: open
    • Not marked for per-sync cleanup, so it persists like the Service
    • RBAC for networkpolicies and Owns(NetworkPolicy) on the RD controller

Design notes

Testing

  • make test: pass. New unit tests cover the loopback bind, RBD vs CephFS ports, selector, owner reference, skipping source movers, and full port replacement when the mover type changes.
  • make lint: 0 issues.
  • make docker-build and make docker-build-mover: pass.
  • Not yet tested on a cluster with NetworkPolicy enforcement.

🤖 Generated with Claude Code

@Rakshith-R
Rakshith-R marked this pull request as draft October 22, 2026 13:45
@Rakshith-R
Rakshith-R requested a balanced review from Copilot October 22, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused networking changes align with existing mover connection paths and have supporting unit coverage, with no blocking issues identified.

No open issues 🎉

What changed in this PR

This PR hardens destination mover networking by limiting inbound traffic to the transfer ports and keeping the plaintext gRPC backend accessible only within the pod.

Changes:

  • Binds plaintext gRPC to 127.0.0.1, preserving access through stunnel.
  • Adds persistent, destination-owned NetworkPolicies with mover-specific ingress ports and open egress; source movers are skipped.
  • Adds controller permissions, policy watches, and unit tests for listener binding and policy reconciliation.
File Description
internal/​worker/​common/​destination.go Binds the plaintext gRPC listener to loopback.
internal/​worker/​common/​destination_test.go Tests the loopback address and listener binding.
internal/​mover/​ceph/​networkpolicy.go Defines and reconciles destination NetworkPolicies.
internal/​mover/​ceph/​networkpolicy_test.go Tests ports, selectors, ownership, source skipping, and policy updates.
internal/​mover/​ceph/​mover.go Ensures the policy during synchronization.
internal/​controller/​replicationdestination_controller.go Adds NetworkPolicy permissions and ownership watches.
config/​rbac/​role.yaml Grants the controller NetworkPolicy access.

Review effort: Balanced

The destination gRPC server on port 8080 listened on all interfaces,
exposing a plaintext endpoint to any pod that can reach the mover. Its
only client is the stunnel sidecar at 127.0.0.1:8080, so bind to loopback.
Also mark the unused receive in RsyncDaemon.Stop as explicitly
discarded to fix the errcheck finding in golangci-lint v2.15.0.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Rakshith R <rar@redhat.com>
Destination movers accept TLS, direct mTLS and CephFS rsync connections on
their Service ports, but nothing restricts which pods can reach them. Add a
NetworkPolicy that allows only those ports on the destination mover pods.
Source movers run with hostNetwork, where NetworkPolicy is not enforced, so
they get no policy.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Rakshith R <rar@redhat.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The security-sensitive networking changes need human validation of replication connectivity and ingress isolation on a cluster enforcing NetworkPolicy.

No open issues 🎉

Review effort: Balanced

@Rakshith-R
Rakshith-R marked this pull request as ready for review October 30, 2026 06:45
@Rakshith-R
Rakshith-R merged commit d9d7337 into RamenDR:main Oct 30, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants