Skip to content

Commit a3e97bc

Browse files
committed
allow the StaticResourceController to manage the networkpolicies after CVO application
1 parent 5134a63 commit a3e97bc

11 files changed

+212
-274
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Allow all egress for guard, installer, and pruner pods in the openshift-kube-apiserver namespace.
2+
#
3+
# These pods run on the pod network (unlike kube-apiserver which uses hostNetwork and
4+
# bypasses NetworkPolicy entirely). They need egress for:
5+
# - installer/pruner: API server access to manage static pod manifests
6+
# - guard: kube-apiserver health checks on port 6443
7+
# - all: DNS resolution via openshift-dns
8+
#
9+
# All egress is permitted because the API server address can vary by cluster configuration.
10+
apiVersion: networking.k8s.io/v1
11+
kind: NetworkPolicy
12+
metadata:
13+
name: allow-all-egress
14+
namespace: openshift-kube-apiserver
15+
spec:
16+
podSelector:
17+
matchExpressions:
18+
- key: app
19+
operator: In
20+
values:
21+
- guard
22+
- installer
23+
- pruner
24+
egress:
25+
- {}
26+
policyTypes:
27+
- Egress
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Default-deny policy for the openshift-kube-apiserver namespace.
2+
# This policy selects all pods in the namespace and enables default-deny for both
3+
# ingress and egress by specifying policyTypes without any allow rules.
4+
#
5+
# NetworkPolicies are additive (use OR logic):
6+
# - This policy enables default-deny for all pods
7+
# - Subsequent policies add specific allow rules
8+
# - If any policy allows traffic, that traffic is permitted
9+
# - Policies cannot override or block traffic allowed by other policies
10+
#
11+
# Note: kube-apiserver static pods use hostNetwork: true and bypass all NetworkPolicy rules.
12+
# This policy only affects pods running on the pod network (guard, installer, pruner).
13+
apiVersion: networking.k8s.io/v1
14+
kind: NetworkPolicy
15+
metadata:
16+
name: default-deny
17+
namespace: openshift-kube-apiserver
18+
spec:
19+
podSelector: {}
20+
policyTypes:
21+
- Ingress
22+
- Egress
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Allow all egress and metrics ingress for the kube-apiserver-operator pod.
2+
#
3+
# Egress is needed for:
4+
# - DNS resolution via openshift-dns
5+
# - Kubernetes API server communication (address varies by cluster configuration)
6+
# - kube-apiserver health checks on port 6443 (hostNetwork, accessed via node IPs)
7+
#
8+
# Ingress is needed for:
9+
# - Prometheus metrics scraping on port 8443
10+
apiVersion: networking.k8s.io/v1
11+
kind: NetworkPolicy
12+
metadata:
13+
name: allow-all-egress-and-metrics-ingress
14+
namespace: openshift-kube-apiserver-operator
15+
spec:
16+
podSelector:
17+
matchLabels:
18+
app: kube-apiserver-operator
19+
egress:
20+
- {}
21+
ingress:
22+
- ports:
23+
- protocol: TCP
24+
port: 8443
25+
policyTypes:
26+
- Ingress
27+
- Egress
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Default-deny policy for the openshift-kube-apiserver-operator namespace.
2+
# This policy selects all pods in the namespace and enables default-deny for both
3+
# ingress and egress by specifying policyTypes without any allow rules.
4+
#
5+
# NetworkPolicies are additive (use OR logic):
6+
# - This policy enables default-deny for all pods
7+
# - Subsequent policies add specific allow rules
8+
# - If any policy allows traffic, that traffic is permitted
9+
# - Policies cannot override or block traffic allowed by other policies
10+
#
11+
# Without this policy, all pods would have unrestricted network access (allow-all).
12+
apiVersion: networking.k8s.io/v1
13+
kind: NetworkPolicy
14+
metadata:
15+
name: default-deny
16+
namespace: openshift-kube-apiserver-operator
17+
spec:
18+
podSelector: {}
19+
policyTypes:
20+
- Ingress
21+
- Egress

manifests/0000_12_kube-apiserver-operand_networkpolicies.yaml

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Allow all egress for guard, installer, and pruner pods in the openshift-kube-apiserver namespace.
2+
#
3+
# These pods run on the pod network (unlike kube-apiserver which uses hostNetwork and
4+
# bypasses NetworkPolicy entirely). They need egress for:
5+
# - installer/pruner: API server access to manage static pod manifests
6+
# - guard: kube-apiserver health checks on port 6443
7+
# - all: DNS resolution via openshift-dns
8+
#
9+
# All egress is permitted because the API server address can vary by cluster configuration.
10+
apiVersion: networking.k8s.io/v1
11+
kind: NetworkPolicy
12+
metadata:
13+
name: allow-all-egress
14+
namespace: openshift-kube-apiserver
15+
annotations:
16+
include.release.openshift.io/self-managed-high-availability: "true"
17+
include.release.openshift.io/single-node-developer: "true"
18+
spec:
19+
podSelector:
20+
matchExpressions:
21+
- key: app
22+
operator: In
23+
values:
24+
- guard
25+
- installer
26+
- pruner
27+
egress:
28+
- {}
29+
policyTypes:
30+
- Egress
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Default-deny policy for the openshift-kube-apiserver namespace.
2+
# This policy selects all pods in the namespace and enables default-deny for both
3+
# ingress and egress by specifying policyTypes without any allow rules.
4+
#
5+
# NetworkPolicies are additive (use OR logic):
6+
# - This policy enables default-deny for all pods
7+
# - Subsequent policies add specific allow rules
8+
# - If any policy allows traffic, that traffic is permitted
9+
# - Policies cannot override or block traffic allowed by other policies
10+
#
11+
# Note: kube-apiserver static pods use hostNetwork: true and bypass all NetworkPolicy rules.
12+
# This policy only affects pods running on the pod network (guard, installer, pruner).
13+
apiVersion: networking.k8s.io/v1
14+
kind: NetworkPolicy
15+
metadata:
16+
name: default-deny
17+
namespace: openshift-kube-apiserver
18+
annotations:
19+
include.release.openshift.io/self-managed-high-availability: "true"
20+
include.release.openshift.io/single-node-developer: "true"
21+
spec:
22+
podSelector: {}
23+
policyTypes:
24+
- Ingress
25+
- Egress

0 commit comments

Comments
 (0)