-
Notifications
You must be signed in to change notification settings - Fork 88
CNTRLPLANE-2905: add network policies #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Network policy for the openshift-controller-manager pods. | ||
| # | ||
| # Egress: | ||
| # - Allow all egress to support communication with the Kubernetes API server, | ||
| # whose IP address and port are not known at manifest time. This implicitly | ||
| # covers DNS resolution as well. | ||
| # | ||
| # Ingress: | ||
| # - Allow ingress on port 8443 (metrics) from the openshift-monitoring namespace | ||
| # so that Prometheus can scrape metrics from the controller-manager pods. | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: allow-controller-manager | ||
| namespace: openshift-controller-manager | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: openshift-controller-manager-a | ||
| controller-manager: "true" | ||
| ingress: | ||
| - ports: | ||
| - protocol: TCP | ||
| port: 8443 | ||
| egress: | ||
| - {} # Allow all egress for API server access | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Default-deny network policy for the openshift-controller-manager namespace. | ||
| # This policy selects all pods in the namespace and enables default-deny for both | ||
| # ingress and egress by specifying policyTypes without any allow rules. | ||
| # | ||
| # NetworkPolicies are additive (use OR logic): | ||
| # - This policy enables default-deny for all pods | ||
| # - Subsequent policies add specific allow rules | ||
| # - If any policy allows traffic, that traffic is permitted | ||
| # - Policies cannot override or block traffic allowed by other policies | ||
| # | ||
| # Without this policy, all pods would have unrestricted network access (allow-all). | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: default-deny | ||
| namespace: openshift-controller-manager | ||
| spec: | ||
| podSelector: {} # Selects all pods in the namespace | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| # No ingress or egress rules - denies all traffic by default |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Network policy for the route-controller-manager pods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Egress: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # - Allow all egress to support communication with the Kubernetes API server, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # whose IP address and port are not known at manifest time. This implicitly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # covers DNS resolution as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Ingress: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # - Allow ingress on port 8443 (metrics) from the openshift-monitoring namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # so that Prometheus can scrape metrics from the route-controller-manager pods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| apiVersion: networking.k8s.io/v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kind: NetworkPolicy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: allow-route-controller-manager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace: openshift-route-controller-manager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| spec: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| podSelector: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| matchLabels: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app: route-controller-manager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| route-controller-manager: "true" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ingress: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - protocol: TCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| port: 8443 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment claims restricted source but ingress rule allows all sources. The comment on lines 8-10 states ingress is allowed "from the openshift-monitoring namespace", but the ingress rule at lines 21-24 has no If the intent is to restrict to Prometheus only, add a namespace selector: 🔒 Proposed fix to restrict ingress source ingress:
+ - from:
+ - namespaceSelector:
+ matchLabels:
+ kubernetes.io/metadata.name: openshift-monitoring
ports:
- protocol: TCP
port: 8443If allowing from all sources is intentional, update the comment to reflect that. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| egress: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - {} # Allow all egress for API server access | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| policyTypes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Ingress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Egress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Default-deny network policy for the openshift-route-controller-manager namespace. | ||
| # This policy selects all pods in the namespace and enables default-deny for both | ||
| # ingress and egress by specifying policyTypes without any allow rules. | ||
| # | ||
| # NetworkPolicies are additive (use OR logic): | ||
| # - This policy enables default-deny for all pods | ||
| # - Subsequent policies add specific allow rules | ||
| # - If any policy allows traffic, that traffic is permitted | ||
| # - Policies cannot override or block traffic allowed by other policies | ||
| # | ||
| # Without this policy, all pods would have unrestricted network access (allow-all). | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: default-deny | ||
| namespace: openshift-route-controller-manager | ||
| spec: | ||
| podSelector: {} # Selects all pods in the namespace | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| # No ingress or egress rules - denies all traffic by default |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Default-deny network policy for the openshift-controller-manager-operator namespace. | ||
| # This policy selects all pods in the namespace and enables default-deny for both | ||
| # ingress and egress by specifying policyTypes without any allow rules. | ||
| # | ||
| # NetworkPolicies are additive (use OR logic): | ||
| # - This policy enables default-deny for all pods | ||
| # - Subsequent policies add specific allow rules | ||
| # - If any policy allows traffic, that traffic is permitted | ||
| # - Policies cannot override or block traffic allowed by other policies | ||
| # | ||
| # Without this policy, all pods would have unrestricted network access (allow-all). | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: default-deny | ||
| namespace: openshift-controller-manager-operator | ||
| annotations: | ||
| include.release.openshift.io/self-managed-high-availability: "true" | ||
| include.release.openshift.io/single-node-developer: "true" | ||
| spec: | ||
| podSelector: {} # Selects all pods in the namespace | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| # No ingress or egress rules - denies all traffic by default |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Network policy for the openshift-controller-manager-operator pod. | ||
| # | ||
| # Egress: | ||
| # - Allow all egress to support communication with the Kubernetes API server, | ||
| # whose IP address and port are not known at manifest time. This implicitly | ||
| # covers DNS resolution as well. | ||
| # | ||
| # Ingress: | ||
| # - Allow ingress on port 8443 (metrics) from the openshift-monitoring namespace | ||
| # so that Prometheus can scrape metrics from the operator. | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: allow-operator | ||
| namespace: openshift-controller-manager-operator | ||
| annotations: | ||
| include.release.openshift.io/self-managed-high-availability: "true" | ||
| include.release.openshift.io/single-node-developer: "true" | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: openshift-controller-manager-operator | ||
| ingress: | ||
| - ports: | ||
| - protocol: TCP | ||
| port: 8443 | ||
|
Comment on lines
+8
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same documentation inconsistency: comment says "from openshift-monitoring" but rule allows all sources. The comment claims ingress is restricted to the openshift-monitoring namespace, but the ingress rule at lines 23-26 has no 🤖 Prompt for AI Agents |
||
| egress: | ||
| - {} # Allow all egress for API server access | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue: comment mentions restricted source but ingress allows all.
Lines 8-10 claim ingress is "from the openshift-monitoring namespace", but the ingress rule has no
fromselector. This allows any source to connect to port 8443. Same fix as the route-controller-manager policy if restriction is intended.🤖 Prompt for AI Agents