|
| 1 | +# NetworkPolicy for Ceph-CSI Operator and Driver Pods |
| 2 | + |
| 3 | +This document describes the NetworkPolicy implementation for the |
| 4 | +ceph-csi-operator and the CSI driver pods it manages. |
| 5 | + |
| 6 | +## Component Inventory |
| 7 | + |
| 8 | +| Component | Pod Labels | hostNetwork | NP Coverage | |
| 9 | +|---|---|---|---| |
| 10 | +| Operator pod | `control-plane: ceph-csi-op-controller-manager` | No | Static manifest | |
| 11 | +| Controller-plugin (per driver) | `app: {driver}-ctrlplugin` | Configurable | Code-generated | |
| 12 | +| csi-addons node agent (per driver) | `app: {driver}-nodeplugin-csi-addons` | No | Code-generated | |
| 13 | +| Node-plugin DaemonSet | `app: {driver}-nodeplugin` | Yes (hardcoded) | Exempt | |
| 14 | + |
| 15 | +## Policies |
| 16 | + |
| 17 | +### Operator Pod |
| 18 | + |
| 19 | +- **Ingress:** Deny all. No exposed ports (metrics disabled by default, |
| 20 | + kubelet health probes bypass NetworkPolicy). |
| 21 | +- **Egress:** Open (`- {}`). Required for API server access. The API server |
| 22 | + ClusterIP varies per cluster (10.96.0.1 on kubeadm, 172.30.0.1 on OpenShift) |
| 23 | + and CNI ipBlock behavior is inconsistent across implementations, so |
| 24 | + restricting egress to a specific IP is not portable. |
| 25 | + |
| 26 | +### Controller-Plugin |
| 27 | + |
| 28 | +- **Ingress:** Two rules: |
| 29 | + 1. csi-addons controller-manager → csi-addons gRPC port (9070 for RBD, |
| 30 | + 9080 for CephFS). Source restricted to pods with labels |
| 31 | + `app.kubernetes.io/name: csi-addons` + `control-plane: controller-manager` |
| 32 | + in any namespace. |
| 33 | + 2. (RBD only) Any pod → snapshot-metadata gRPC port 50051. Open source |
| 34 | + because backup applications (Velero, etc.) can run in any namespace |
| 35 | + with any labels. See [CSI snapshot-metadata](https://kubernetes-csi.github.io/docs/external-snapshot-metadata.html). |
| 36 | +- **Egress:** Open. Required for API server and Ceph cluster access. |
| 37 | + |
| 38 | +### csi-addons Node Agent |
| 39 | + |
| 40 | +- **Ingress:** csi-addons controller-manager → port 9071 only. |
| 41 | +- **Egress:** Open. |
| 42 | +- **Lifecycle:** Mirrors the csi-addons DaemonSet — created when |
| 43 | + `DeployCsiAddons` is true, deleted when false. Not created for NFS drivers. |
| 44 | + |
| 45 | +### Node-Plugin DaemonSet |
| 46 | + |
| 47 | +No NetworkPolicy. Runs with `hostNetwork: true`, which makes it exempt |
| 48 | +from NetworkPolicy enforcement. |
| 49 | + |
| 50 | +## Gating |
| 51 | + |
| 52 | +### Static Manifest (Operator Pod) |
| 53 | + |
| 54 | +The operator pod NP is in `config/network-policy/` and referenced from |
| 55 | +`config/default/kustomization.yaml` as a commented resource. It is |
| 56 | +**disabled by default**. Set `NETWORK_POLICY=true` when building to include it: |
| 57 | + |
| 58 | +```console |
| 59 | +NETWORK_POLICY=true make build-installer |
| 60 | +``` |
| 61 | + |
| 62 | +### Code-Generated NPs (Driver Pods) |
| 63 | + |
| 64 | +Driver pod NPs are created by the operator at runtime. The operator checks |
| 65 | +for the `networking.k8s.io/v1` API group at startup via the discovery client. |
| 66 | +If the API is not available, no NPs are created and a log message is emitted. |
| 67 | + |
| 68 | +## API Server Egress Rationale |
| 69 | + |
| 70 | +Open egress (`- {}`) is used instead of restricting to a specific API server |
| 71 | +IP because: |
| 72 | + |
| 73 | +1. The API server ClusterIP varies per cluster and is unknown at manifest |
| 74 | + authoring time. |
| 75 | +2. CNI implementations handle `ipBlock` inconsistently with DNAT (OVN-K8s |
| 76 | + timing, Cilium quirks). |
| 77 | +3. HyperShift clusters may use non-standard API server ports. |
| 78 | + |
| 79 | +This follows the precedent set by |
| 80 | +[operator-marketplace PR #723](https://github.com/operator-framework/operator-marketplace/pull/723). |
| 81 | + |
| 82 | +## References |
| 83 | + |
| 84 | +- [CSI snapshot-metadata sidecar](https://kubernetes-csi.github.io/docs/external-snapshot-metadata.html) |
| 85 | +- [kubernetes-csi/external-snapshot-metadata](https://github.com/kubernetes-csi/external-snapshot-metadata) |
| 86 | +- [operator-marketplace NP precedent](https://github.com/operator-framework/operator-marketplace/pull/723) |
0 commit comments