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
@@ -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,52 +177,79 @@ 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:
178
184
- ports:
179
185
- protocol: TCP
180
186
port: 6443
181
187
---
182
-
# Metrics ingress for all components
188
+
# DNS egress for cert-manager controller component
183
189
apiVersion: networking.k8s.io/v1
184
190
kind: NetworkPolicy
185
191
metadata:
186
-
name: allow-metrics-ingress
187
-
namespace: cert-manager
188
-
spec:
189
-
podSelector:
190
-
matchLabels:
191
-
app.kubernetes.io/name: cert-manager
192
-
policyTypes:
193
-
- Ingress
194
-
ingress:
195
-
- ports:
196
-
from:
197
-
- namespaceSelector:
198
-
matchLabels:
199
-
name: openshift-monitoring
200
-
- protocol: TCP
201
-
port: 9402
202
-
---
203
-
# Webhook ingress for admission control
204
-
apiVersion: networking.k8s.io/v1
205
-
kind: NetworkPolicy
206
-
metadata:
207
-
name: allow-webhook-ingress
192
+
name: allow-dns-egress
208
193
namespace: cert-manager
209
194
spec:
195
+
egress:
196
+
- ports:
197
+
- port: 5353
198
+
protocol: TCP
199
+
- port: 5353
200
+
protocol: UDP
201
+
to:
202
+
- namespaceSelector:
203
+
matchLabels:
204
+
kubernetes.io/metadata.name: openshift-dns
205
+
podSelector:
206
+
matchLabels:
207
+
dns.operator.openshift.io/daemonset-dns: default
210
208
podSelector:
211
209
matchLabels:
212
-
app: webhook
210
+
app: cert-manager
213
211
policyTypes:
214
-
- Ingress
215
-
ingress:
216
-
- ports:
217
-
- protocol: TCP
218
-
port: 10250
219
-
```
212
+
- Egress
213
+
214
+
---
215
+
# Metrics ingress for all components
216
+
apiVersion: networking.k8s.io/v1
217
+
kind: NetworkPolicy
218
+
metadata:
219
+
name: allow-metrics-ingress
220
+
namespace: cert-manager
221
+
spec:
222
+
podSelector:
223
+
matchLabels:
224
+
app.kubernetes.io/instance: cert-manager
225
+
policyTypes:
226
+
- Ingress
227
+
ingress:
228
+
- ports:
229
+
from:
230
+
- namespaceSelector:
231
+
matchLabels:
232
+
name: openshift-user-workload-monitoring
233
+
- protocol: TCP
234
+
port: 9402
235
+
---
236
+
# Webhook ingress for admission control
237
+
apiVersion: networking.k8s.io/v1
238
+
kind: NetworkPolicy
239
+
metadata:
240
+
name: allow-webhook-ingress
241
+
namespace: cert-manager
242
+
spec:
243
+
podSelector:
244
+
matchLabels:
245
+
app: webhook
246
+
policyTypes:
247
+
- Ingress
248
+
ingress:
249
+
- ports:
250
+
- protocol: TCP
251
+
port: 10250
252
+
```
220
253
221
254
3. **User-Configurable Policies:** Users must configure additional policies via the API for cert-manager controller egress (to communicate with external issuers). Example user configuration:
222
255
@@ -228,10 +261,22 @@ When `DefaultNetworkPolicy` is set to "true", the operator will create baseline
228
261
spec:
229
262
defaultNetworkPolicy: "true"
230
263
networkPolicies:
231
-
- name: allow-cert-manager-controller-egress
232
-
componentName: CoreController
233
-
egress:
234
-
- {} # Allow all egress for external issuers communication
264
+
- componentName: CoreController
265
+
egress:
266
+
- ports:
267
+
- port: 80
268
+
protocol: TCP
269
+
- port: 443
270
+
protocol: TCP
271
+
name: allow-egress-to-acme-server
272
+
- componentName: CoreController
273
+
egress:
274
+
- ports:
275
+
- port: 53
276
+
protocol: UDP
277
+
- port: 53
278
+
protocol: TCP
279
+
name: allow-egress-to-dns-service
235
280
```
236
281
237
282
#### Istio-CSR Namespace Policies
@@ -298,30 +343,13 @@ The `istio-csr` component requires specific network policies to function correct
298
343
from:
299
344
- namespaceSelector:
300
345
matchLabels:
301
-
name: openshift-monitoring
346
+
name: openshift-user-workload-monitoring
302
347
- protocol: TCP
303
348
port: 9402 # Metrics port
304
349
```
305
350
306
351
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
352
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
353
### API Extensions
326
354
327
355
This enhancement introduces new fields to the existing `CertManager` custom resource to support network policy configuration.
@@ -391,9 +419,6 @@ const (
391
419
392
420
// Webhook represents the cert-manager webhook component
393
421
Webhook ComponentName = "Webhook"
394
-
395
-
// IstioCSR represents the cert-manager Istio CSR component
396
-
IstioCSR ComponentName = "IstioCSR"
397
422
)
398
423
399
424
@@ -409,7 +434,7 @@ type NetworkPolicy struct {
409
434
Name string `json:"name"`
410
435
411
436
// ComponentName represents the different cert-manager components that can have network policies applied.
@@ -461,15 +486,15 @@ The main drawback is the added complexity of managing multiple `NetworkPolicy` o
461
486
## Test Plan
462
487
463
488
***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).
489
+
1. Test with `defaultNetworkPolicy: "false"` (default): Verify no NetworkPolicy objects are created and cert-manager functions normally.
490
+
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).
491
+
3. Test with `defaultNetworkPolicy: "true"` and custom `networkPolicies` for cert-manager controller egress: Verify cert-manager can communicate with external issuers.
492
+
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
493
5. Test istio-csr with automatic network policies: Verify istio-csr can communicate with required services with operator-managed policies.
469
494
6. Create a `curl` pod and confirm it **can** access the metrics endpoints (`:8443` for operator, `:9402` for operands) when policies are enabled.
470
495
7. Confirm the `curl` pod **cannot** access pods on non-allowed ports when policies are enabled.
471
496
***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.
497
+
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
498
2. Run the istio-csr E2E test suite with automatic operator-managed network policies enabled.
474
499
475
500
## Graduation Criteria
@@ -495,7 +520,7 @@ Not applicable.
495
520
496
521
## Upgrade / Downgrade Strategy
497
522
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.
523
+
***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
524
***Downgrade:** If a user downgrades to a version of the operator that is not aware of the new API fields:
500
525
- The API fields will be ignored by the older operator version
501
526
- Any existing `NetworkPolicy` objects created by the newer operator will be orphaned
@@ -518,8 +543,7 @@ Not applicable, as this enhancement does not introduce any API extensions.
518
543
Support personnel debugging potential network policy issues should follow these steps:
519
544
520
545
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
546
+
- Verify `CertManager` resource: `oc get certmanager cluster -o yaml` and check `defaultNetworkPolicy` and `networkPolicies` fields
523
547
524
548
2.**Verify NetworkPolicy Objects:**
525
549
- Check if NetworkPolicy objects exist: `oc get networkpolicy -n <namespace>`
0 commit comments