You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: enhancements/cert-manager/cert-manager-network-policies.md
+50-50Lines changed: 50 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ In a multi-tenant or security-conscious environment, it is crucial to enforce ne
46
46
- 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.
47
47
- Ensure that metrics collection for all components remains functional.
48
48
- 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.
50
50
51
51
### Non-Goals
52
52
@@ -56,12 +56,12 @@ In a multi-tenant or security-conscious environment, it is crucial to enforce ne
56
56
57
57
## Proposal
58
58
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.
60
60
61
61
### Workflow Description
62
62
63
63
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
65
65
- For istio-csr: Network policies are automatically managed by the operator with no user configuration required
66
66
67
67
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
71
71
***Allow Egress to API Server:** Permit outgoing traffic from the operator pod to the Kubernetes API server on port 6443/TCP.
72
72
***Allow Ingress for Metrics:** Permit incoming traffic to the operator pod on port 8443/TCP for Prometheus metrics scraping.
73
73
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:
75
75
76
76
***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
80
81
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).
82
83
83
84
5.**Istio-CSR Policies:** The operator will create baseline policies for istio-csr:
84
85
85
86
***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
88
90
89
91
***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.
90
92
@@ -105,7 +107,9 @@ The implementation will involve extending the existing APIs and creating `Networ
105
107
name: deny-all-traffic
106
108
namespace: cert-manager-operator
107
109
spec:
108
-
podSelector: {}
110
+
podSelector:
111
+
matchLabels:
112
+
name: cert-manager-operator
109
113
policyTypes:
110
114
- Ingress
111
115
- Egress
@@ -135,16 +139,16 @@ The implementation will involve extending the existing APIs and creating `Networ
135
139
from:
136
140
- namespaceSelector:
137
141
matchLabels:
138
-
name: openshift-monitoring
142
+
name: openshift-user-workload-monitoring
139
143
- protocol: TCP
140
144
port: 8443
141
145
```
142
146
143
147
#### Cert-Manager Operand Namespace Policies
144
148
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.
146
150
147
-
1. **Baseline Deny-All Policy:** Applied when `DefaultNetworkPolicy` is "true".
151
+
1. **Baseline Deny-All Policy:** Applied when `defaultNetworkPolicy` is "true".
148
152
149
153
```yaml
150
154
apiVersion: networking.k8s.io/v1
@@ -153,13 +157,15 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
153
157
name: deny-all-traffic
154
158
namespace: cert-manager
155
159
spec:
156
-
podSelector: {}
160
+
podSelector:
161
+
matchLabels:
162
+
app.kubernetes.io/instance: cert-manager
157
163
policyTypes:
158
164
- Ingress
159
165
- Egress
160
166
```
161
167
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":
163
169
164
170
```yaml
165
171
# API Server egress for all components
@@ -171,7 +177,7 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
171
177
spec:
172
178
podSelector:
173
179
matchLabels:
174
-
app.kubernetes.io/name: cert-manager
180
+
app.kubernetes.io/instance: cert-manager
175
181
policyTypes:
176
182
- Egress
177
183
egress:
@@ -188,15 +194,15 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
188
194
spec:
189
195
podSelector:
190
196
matchLabels:
191
-
app.kubernetes.io/name: cert-manager
197
+
app.kubernetes.io/instance: cert-manager
192
198
policyTypes:
193
199
- Ingress
194
200
ingress:
195
201
- ports:
196
202
from:
197
203
- namespaceSelector:
198
204
matchLabels:
199
-
name: openshift-monitoring
205
+
name: openshift-user-workload-monitoring
200
206
- protocol: TCP
201
207
port: 9402
202
208
---
@@ -228,10 +234,22 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
228
234
spec:
229
235
defaultNetworkPolicy: "true"
230
236
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
235
253
```
236
254
237
255
#### Istio-CSR Namespace Policies
@@ -298,30 +316,13 @@ The `istio-csr` component requires specific network policies to function correct
298
316
from:
299
317
- namespaceSelector:
300
318
matchLabels:
301
-
name: openshift-monitoring
319
+
name: openshift-user-workload-monitoring
302
320
- protocol: TCP
303
321
port: 9402 # Metrics port
304
322
```
305
323
306
324
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.
307
325
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
-
325
326
### API Extensions
326
327
327
328
This enhancement introduces new fields to the existing `CertManager` custom resource to support network policy configuration.
@@ -409,7 +410,7 @@ type NetworkPolicy struct {
409
410
Name string `json:"name"`
410
411
411
412
// ComponentName represents the different cert-manager components that can have network policies applied.
@@ -461,15 +462,15 @@ The main drawback is the added complexity of managing multiple `NetworkPolicy` o
461
462
## Test Plan
462
463
463
464
***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).
468
469
5. Test istio-csr with automatic network policies: Verify istio-csr can communicate with required services with operator-managed policies.
469
470
6. Create a `curl` pod and confirm it **can** access the metrics endpoints (`:8443` for operator, `:9402` for operands) when policies are enabled.
470
471
7. Confirm the `curl` pod **cannot** access pods on non-allowed ports when policies are enabled.
471
472
***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.
473
474
2. Run the istio-csr E2E test suite with automatic operator-managed network policies enabled.
474
475
475
476
## Graduation Criteria
@@ -495,7 +496,7 @@ Not applicable.
495
496
496
497
## Upgrade / Downgrade Strategy
497
498
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.
499
500
***Downgrade:** If a user downgrades to a version of the operator that is not aware of the new API fields:
500
501
- The API fields will be ignored by the older operator version
501
502
- 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.
518
519
Support personnel debugging potential network policy issues should follow these steps:
519
520
520
521
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
523
523
524
524
2.**Verify NetworkPolicy Objects:**
525
525
- Check if NetworkPolicy objects exist: `oc get networkpolicy -n <namespace>`
0 commit comments