Skip to content

Commit 8016f9e

Browse files
committed
review changes
1 parent a6aa29d commit 8016f9e

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

enhancements/cert-manager/cert-manager-network-policies.md

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ In a multi-tenant or security-conscious environment, it is crucial to enforce ne
4646
- Define baseline ingress and egress rules for the `istio-csr` component (deny-all with metrics access), with user-configurable network policies via the API for additional access requirements.
4747
- Ensure that metrics collection for all components remains functional.
4848
- Ensure the API server can communicate with the `cert-manager-webhook` for admission control.
49-
- Provide backward compatibility by making network policies opt-in via the `DefaultNetworkPolicy` field.
49+
- Provide backward compatibility by making network policies opt-in via the `defaultNetworkPolicy` field.
5050

5151
### Non-Goals
5252

@@ -56,12 +56,12 @@ In a multi-tenant or security-conscious environment, it is crucial to enforce ne
5656

5757
## Proposal
5858

59-
The proposal is to extend the `CertManager` custom resource with new API fields to enable and configure network policies. The `cert-manager-operator` will create and manage `NetworkPolicy` objects across all managed namespaces. For cert-manager, network policies are opt-in via the `DefaultNetworkPolicy` field (default "false") for backward compatibility with user-configurable additional rules. For istio-csr, network policies are automatically managed by the operator with no user configuration required. The strategy is to first apply a default-deny policy and then allow appropriate traffic based on component requirements.
59+
The proposal is to extend the `CertManager` custom resource with new API fields to enable and configure network policies. The `cert-manager-operator` will create and manage `NetworkPolicy` objects across all managed namespaces. For cert-manager, network policies are opt-in via the `defaultNetworkPolicy ` field (default "false") for backward compatibility with user-configurable additional rules. For istio-csr, network policies are automatically managed by the operator with no user configuration required. The strategy is to first apply a default-deny policy and then allow appropriate traffic based on component requirements.
6060

6161
### Workflow Description
6262

6363
1. **API-Driven Configuration:** Users configure network policies through the `CertManager` custom resource specification:
64-
- For cert-manager: Set `DefaultNetworkPolicy: "true"` and optionally provide custom `NetworkPolicies` rules
64+
- For cert-manager: Set `defaultNetworkPolicy: "true"` and optionally provide custom `networkPolicies[]` rules
6565
- For istio-csr: Network policies are automatically managed by the operator with no user configuration required
6666

6767
2. **Default Deny:** When network policies are enabled, the operator will create baseline `NetworkPolicy` objects that deny all traffic for the respective components. This ensures that no traffic is allowed unless explicitly permitted.
@@ -71,20 +71,22 @@ The proposal is to extend the `CertManager` custom resource with new API fields
7171
* **Allow Egress to API Server:** Permit outgoing traffic from the operator pod to the Kubernetes API server on port 6443/TCP.
7272
* **Allow Ingress for Metrics:** Permit incoming traffic to the operator pod on port 8443/TCP for Prometheus metrics scraping.
7373

74-
4. **Cert-Manager Operand Policies:** When `DefaultNetworkPolicy` is "true", the operator will create baseline policies for each component:
74+
4. **Cert-Manager Operand Policies:** When `defaultNetworkPolicy ` is "true", the operator will create baseline policies for each component:
7575

7676
* **Default policies include:**
77-
* **API Server Egress:** For all components to communicate with the Kubernetes API server
78-
* **Metrics Ingress:** For all components to expose metrics on port 9402/TCP
79-
* **Webhook Ingress:** For the webhook component to receive admission requests on port 10250/TCP
77+
* **Egress to API Server:** For all components to communicate with the Kubernetes API server
78+
* **Egress to DNS:** For cert-manager controller to communicate with the cluster DNS service
79+
* **Ingress to Metrics Endpoint:** For OpenShift Monitoring components to access metrics endpoint on port 9402/TCP
80+
* **Ingress to Webhook:** For the Kubernetes API server to establish HTTPS connections to the webhook component for admission requests on port 10250/TCP
8081

81-
* **User-configurable egress policies:** Users can specify additional egress rules via the `NetworkPolicies` field in the `CertManager` spec. If no egress policies are provided, cert-manager components will have deny-all egress policies (which will prevent proper operation without user configuration).
82+
* **User-configurable egress policies:** Users can specify additional egress rules via the `networkPolicies` field in the `CertManager` spec. If no egress policies are provided, cert-manager components will have deny-all egress policies (which will prevent proper operation without user configuration).
8283

8384
5. **Istio-CSR Policies:** The operator will create baseline policies for istio-csr:
8485

8586
* **Default policies include:**
86-
* **API Server Egress:** For communication with the Kubernetes API server on port 6443/TCP
87-
* **Metrics Ingress:** For exposing metrics on port 9402/TCP
87+
* **Egress to API Server:** For communication with the Kubernetes API server on port 6443/TCP
88+
* **Ingress to gRPC Endpoint:** For incoming gRPC connections to the Istio-CSR on port 6443/TCP
89+
* **Ingress to Metrics Endpoint:** For OpenShift Monitoring components to access metrics endpoint on port 9402/TCP
8890

8991
* **Automatic policy management:** All istio-csr network policies (both ingress and egress) are automatically managed by the operator. No user configuration is required or supported for istio-csr network policies.
9092

@@ -105,7 +107,9 @@ The implementation will involve extending the existing APIs and creating `Networ
105107
name: deny-all-traffic
106108
namespace: cert-manager-operator
107109
spec:
108-
podSelector: {}
110+
podSelector:
111+
matchLabels:
112+
name: cert-manager-operator
109113
policyTypes:
110114
- Ingress
111115
- Egress
@@ -135,16 +139,16 @@ The implementation will involve extending the existing APIs and creating `Networ
135139
from:
136140
- namespaceSelector:
137141
matchLabels:
138-
name: openshift-monitoring
142+
name: openshift-user-workload-monitoring
139143
- protocol: TCP
140144
port: 8443
141145
```
142146
143147
#### Cert-Manager Operand Namespace Policies
144148
145-
When `DefaultNetworkPolicy` is set to "true", the operator will create baseline policies for cert-manager components. Users can provide additional or custom policies via the `NetworkPolicies` field in the `CertManager` spec.
149+
When `defaultNetworkPolicy` is set to "true", the operator will create baseline policies for cert-manager components. Users can provide additional or custom policies via the `networkPolicies` field in the `CertManager` spec.
146150

147-
1. **Baseline Deny-All Policy:** Applied when `DefaultNetworkPolicy` is "true".
151+
1. **Baseline Deny-All Policy:** Applied when `defaultNetworkPolicy` is "true".
148152

149153
```yaml
150154
apiVersion: networking.k8s.io/v1
@@ -153,13 +157,15 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
153157
name: deny-all-traffic
154158
namespace: cert-manager
155159
spec:
156-
podSelector: {}
160+
podSelector:
161+
matchLabels:
162+
app.kubernetes.io/instance: cert-manager
157163
policyTypes:
158164
- Ingress
159165
- Egress
160166
```
161167

162-
2. **Default Allow Policies:** The operator creates these baseline policies when `DefaultNetworkPolicy` is "true":
168+
2. **Default Allow Policies:** The operator creates these baseline policies when `defaultNetworkPolicy` is "true":
163169

164170
```yaml
165171
# API Server egress for all components
@@ -171,7 +177,7 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
171177
spec:
172178
podSelector:
173179
matchLabels:
174-
app.kubernetes.io/name: cert-manager
180+
app.kubernetes.io/instance: cert-manager
175181
policyTypes:
176182
- Egress
177183
egress:
@@ -188,15 +194,15 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
188194
spec:
189195
podSelector:
190196
matchLabels:
191-
app.kubernetes.io/name: cert-manager
197+
app.kubernetes.io/instance: cert-manager
192198
policyTypes:
193199
- Ingress
194200
ingress:
195201
- ports:
196202
from:
197203
- namespaceSelector:
198204
matchLabels:
199-
name: openshift-monitoring
205+
name: openshift-user-workload-monitoring
200206
- protocol: TCP
201207
port: 9402
202208
---
@@ -228,10 +234,22 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
228234
spec:
229235
defaultNetworkPolicy: "true"
230236
networkPolicies:
231-
- name: allow-cert-manager-controller-egress
232-
componentName: CoreController
233-
egress:
234-
- {} # Allow all egress for external issuers communication
237+
- componentName: CoreController
238+
egress:
239+
- ports:
240+
- port: 80
241+
protocol: TCP
242+
- port: 443
243+
protocol: TCP
244+
name: allow-egress-to-acme-server
245+
- componentName: CoreController
246+
egress:
247+
- ports:
248+
- port: 53
249+
protocol: UDP
250+
- port: 53
251+
protocol: TCP
252+
name: allow-egress-to-dns-service
235253
```
236254

237255
#### Istio-CSR Namespace Policies
@@ -298,30 +316,13 @@ The `istio-csr` component requires specific network policies to function correct
298316
from:
299317
- namespaceSelector:
300318
matchLabels:
301-
name: openshift-monitoring
319+
name: openshift-user-workload-monitoring
302320
- protocol: TCP
303321
port: 9402 # Metrics port
304322
```
305323

306324
3. **Automatic Policy Management:** All istio-csr network policies are automatically managed by the operator based on the component's requirements. No user configuration is needed.
307325

308-
```yaml
309-
apiVersion: operator.openshift.io/v1alpha1
310-
kind: IstioCSR
311-
metadata:
312-
name: cluster
313-
spec:
314-
networkPolicies:
315-
- name: allow-istio-csr-grpc-service
316-
componentName: IstioCSR
317-
policyTypes:
318-
- Ingress
319-
ingress:
320-
- ports:
321-
- protocol: TCP
322-
port: 6443 # Replace with actual configured gRPC service port
323-
```
324-
325326
### API Extensions
326327

327328
This enhancement introduces new fields to the existing `CertManager` custom resource to support network policy configuration.
@@ -409,7 +410,7 @@ type NetworkPolicy struct {
409410
Name string `json:"name"`
410411

411412
// ComponentName represents the different cert-manager components that can have network policies applied.
412-
// +kubebuilder:validation:Enum:=CAInjector;CoreController;WebHook;IstioCSR
413+
// +kubebuilder:validation:Enum:=CAInjector;CoreController;WebHook
413414
// +kubebuilder:validation:Required
414415
ComponentName ComponentName `json:"componentName"`
415416

@@ -461,15 +462,15 @@ The main drawback is the added complexity of managing multiple `NetworkPolicy` o
461462
## Test Plan
462463

463464
* **Integration Tests:**
464-
1. Test with `DefaultNetworkPolicy: "false"` (default): Verify no NetworkPolicy objects are created and cert-manager functions normally.
465-
2. Test with `DefaultNetworkPolicy: "true"` but no custom `NetworkPolicies` specified: Verify baseline policies are created and cert-manager controller cannot communicate with external issuers (expected behavior).
466-
3. Test with `DefaultNetworkPolicy: "true"` and custom `NetworkPolicies` for cert-manager controller egress: Verify cert-manager can communicate with external issuers.
467-
4. Test istio-csr with no `NetworkPolicies` specified: Verify baseline policies are created and external egress is blocked while ingress (gRPC service) is automatically allowed (expected behavior).
465+
1. Test with `defaultNetworkPolicy: "false"` (default): Verify no NetworkPolicy objects are created and cert-manager functions normally.
466+
2. Test with `defaultNetworkPolicy: "true"` but no custom `networkPolicies` specified: Verify baseline policies are created and cert-manager controller cannot communicate with external issuers (expected behavior).
467+
3. Test with `defaultNetworkPolicy: "true"` and custom `networkPolicies` for cert-manager controller egress: Verify cert-manager can communicate with external issuers.
468+
4. Test istio-csr with no `networkPolicies` specified: Verify baseline policies are created and external egress is blocked while ingress (gRPC service) is automatically allowed (expected behavior).
468469
5. Test istio-csr with automatic network policies: Verify istio-csr can communicate with required services with operator-managed policies.
469470
6. Create a `curl` pod and confirm it **can** access the metrics endpoints (`:8443` for operator, `:9402` for operands) when policies are enabled.
470471
7. Confirm the `curl` pod **cannot** access pods on non-allowed ports when policies are enabled.
471472
* **End-to-End (E2E) Tests:**
472-
1. Run the existing `cert-manager` E2E test suite with `DefaultNetworkPolicy: "true"`. Configure proper NetworkPolicy settings via the API and run the cert-manager E2E test suite with network policies enabled.
473+
1. Run the existing `cert-manager` E2E test suite with `defaultNetworkPolicy: "true"`. Configure proper NetworkPolicy settings via the API and run the cert-manager E2E test suite with network policies enabled.
473474
2. Run the istio-csr E2E test suite with automatic operator-managed network policies enabled.
474475

475476
## Graduation Criteria
@@ -495,7 +496,7 @@ Not applicable.
495496

496497
## Upgrade / Downgrade Strategy
497498

498-
* **Upgrade:** On upgrade, the new API fields will be available but network policies remain disabled by default (`DefaultNetworkPolicy: "false"`). This ensures backward compatibility. Users must explicitly enable network policies and configure them appropriately.
499+
* **Upgrade:** On upgrade, the new API fields will be available but network policies remain disabled by default (`defaultNetworkPolicy: "false"`). This ensures backward compatibility. Users must explicitly enable network policies and configure them appropriately.
499500
* **Downgrade:** If a user downgrades to a version of the operator that is not aware of the new API fields:
500501
- The API fields will be ignored by the older operator version
501502
- Any existing `NetworkPolicy` objects created by the newer operator will be orphaned
@@ -518,8 +519,7 @@ Not applicable, as this enhancement does not introduce any API extensions.
518519
Support personnel debugging potential network policy issues should follow these steps:
519520

520521
1. **Check API Configuration:**
521-
- Verify `CertManager` resource: `oc get certmanager cluster -o yaml` and check `defaultNetworkPolicy` and `NetworkPolicies` fields
522-
- Verify `IstioCSR` resource: `oc get istiocsr cluster -o yaml` and check `NetworkPolicies` field
522+
- Verify `CertManager` resource: `oc get certmanager cluster -o yaml` and check `defaultNetworkPolicy` and `networkPolicies` fields
523523

524524
2. **Verify NetworkPolicy Objects:**
525525
- Check if NetworkPolicy objects exist: `oc get networkpolicy -n <namespace>`

0 commit comments

Comments
 (0)