-
Notifications
You must be signed in to change notification settings - Fork 282
CORENET-6816: Add NetworkPolicies for CNO and its operands #2892
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
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,41 @@ | ||
| kind: NetworkPolicy | ||
| apiVersion: networking.k8s.io/v1 | ||
| metadata: | ||
| name: network-check-source | ||
| namespace: openshift-network-diagnostics | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: network-check-source | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| ingress: | ||
| # Allow ingress to metrics | ||
| - ports: | ||
| - port: 17698 | ||
| egress: | ||
| # Allow egress to network-check-target pods. | ||
| - to: | ||
| - podSelector: | ||
| matchLabels: | ||
| app: network-check-target | ||
| # Allow egress to apiserver | ||
| - {} | ||
|
danwinship marked this conversation as resolved.
|
||
| --- | ||
| kind: NetworkPolicy | ||
| apiVersion: networking.k8s.io/v1 | ||
| metadata: | ||
| name: network-check-target | ||
| namespace: openshift-network-diagnostics | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: network-check-target | ||
| policyTypes: | ||
| # network-check-target does no egress | ||
| - Ingress | ||
| ingress: | ||
| # Allow to the check-target port. For debuggability we don't restrict the source. | ||
| - ports: | ||
| - port: 8080 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| kind: NetworkPolicy | ||
| apiVersion: networking.k8s.io/v1 | ||
| metadata: | ||
| name: iptables-alerter | ||
| namespace: openshift-network-operator | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: iptables-alerter | ||
| policyTypes: | ||
| - Egress | ||
| egress: | ||
| # Allow to apiserver | ||
| - {} | ||
|
danwinship marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| kind: NetworkPolicy | ||
| apiVersion: networking.k8s.io/v1 | ||
| metadata: | ||
| name: multus-admission-controller | ||
| namespace: openshift-multus | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: multus-admission-controller | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| ingress: | ||
| # Allow from apiserver to webhook port | ||
| - ports: | ||
| - port: 6443 | ||
| # Allow all to metrics port | ||
| - ports: | ||
| - port: 8443 | ||
|
danwinship marked this conversation as resolved.
|
||
| egress: | ||
| # Allow to apiserver; currently requires allow all | ||
| - {} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| kind: NetworkPolicy | ||
| apiVersion: networking.k8s.io/v1 | ||
| metadata: | ||
| name: network-metrics | ||
| namespace: openshift-multus | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: network-metrics-daemon | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| ingress: | ||
| # Allow ingress to metrics | ||
| - ports: | ||
| - port: 8443 | ||
|
danwinship marked this conversation as resolved.
|
||
| egress: | ||
| # Allow egress to apiserver | ||
| - {} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| kind: NetworkPolicy | ||
| apiVersion: networking.k8s.io/v1 | ||
| metadata: | ||
| name: networking-console-plugin | ||
| namespace: openshift-network-console | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: networking-console-plugin | ||
| policyTypes: | ||
| - Ingress | ||
| ingress: | ||
| # Allow from console | ||
| - from: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: openshift-console | ||
| ports: | ||
| - port: 9443 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,17 @@ metadata: | |
| pod-security.kubernetes.io/enforce: privileged | ||
| pod-security.kubernetes.io/audit: privileged | ||
| pod-security.kubernetes.io/warn: privileged | ||
| openshift.io/cluster-monitoring: "true" | ||
| openshift.io/cluster-monitoring: "true" | ||
| --- | ||
| kind: NetworkPolicy | ||
| apiVersion: networking.k8s.io/v1 | ||
| metadata: | ||
| name: default-deny | ||
|
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. @danwinship I do not see default deny policy in the namespace. I have a upgraded cluster. Upgrade path oc get clusterversion -o json|jq ".items[0].status.history"
[
{
"acceptedRisks": "Target release version=\"\" image=\"registry.build10.ci.openshift.org/ci-ln-qziy2xb/release:latest\" cannot be verified, but continuing anyway because the update was forced: release images that are not accessed via digest cannot be verified\nForced through blocking failures: Multiple precondition checks failed:\n* Precondition \"ClusterVersionUpgradeable\" failed because of \"ClusterVersionOverridesSet\": Disabling ownership via cluster version overrides prevents upgrades. Please remove overrides before continuing.\n* Precondition \"ClusterVersionRecommendedUpdate\" failed because of \"UnknownUpdate\": RetrievedUpdates=False (VersionNotFound), so the recommended status of updating from 4.21.0-0.nightly-2026-04-02-002715 to 4.22.0-0-2026-04-06-143042-test-ci-ln-qziy2xb-latest is unknown.",
"completionTime": "2026-04-06T16:18:07Z",
"image": "registry.build10.ci.openshift.org/ci-ln-qziy2xb/release:latest",
"startedTime": "2026-04-06T15:08:05Z",
"state": "Completed",
"verified": false,
"version": "4.22.0-0-2026-04-06-143042-test-ci-ln-qziy2xb-latest"
},
{
"completionTime": "2026-04-06T13:57:57Z",
"image": "registry.ci.openshift.org/ocp/release@sha256:7f463370e2f79ada93b7953338f33fc13bee9ec911f63aa0baddf369ed785024",
"startedTime": "2026-04-06T13:28:25Z",
"state": "Completed",
"verified": false,
"version": "4.21.0-0.nightly-2026-04-02-002715"
}
]
Policy oc -n openshift-network-operator get networkpolicy NAME POD-SELECTOR AGE iptables-alerter app=iptables-alerter 5h23m |
||
| namespace: openshift-network-operator | ||
| spec: | ||
| podSelector: {} | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| ingress: [] | ||
| egress: [] | ||
|
danwinship marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,12 +74,13 @@ func TestRenderMultusAdmissionController(t *testing.T) { | |
| g.Expect(objs).To(ContainElement(HaveKubernetesID("Deployment", "openshift-multus", "multus-admission-controller"))) | ||
|
|
||
| // Check rendered object | ||
| g.Expect(len(objs)).To(Equal(10)) | ||
| g.Expect(len(objs)).To(Equal(11)) | ||
|
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. @danwinship Is this counting additional object i.e. network policy? In openshift-multus there are two objects increased.
Contributor
Author
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. This unit test is only calling |
||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("Service", "openshift-multus", "multus-admission-controller"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("ClusterRole", "", "multus-admission-controller-webhook"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("ClusterRoleBinding", "", "multus-admission-controller-webhook"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("ValidatingWebhookConfiguration", "", names.MULTUS_VALIDATING_WEBHOOK))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("Deployment", "openshift-multus", "multus-admission-controller"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("NetworkPolicy", "openshift-multus", "multus-admission-controller"))) | ||
| } | ||
|
|
||
| // TestRenderMultusAdmissionController has some simple rendering tests | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,12 +46,13 @@ func TestRenderMultus(t *testing.T) { | |
| g.Expect(objs).To(ContainElement(HaveKubernetesID("DaemonSet", "openshift-multus", "multus"))) | ||
|
|
||
| // It's important that the namespace is first | ||
| g.Expect(len(objs)).To(Equal(32), "Expected 32 multus related objects") | ||
| g.Expect(len(objs)).To(Equal(34), "Expected 34 multus related objects") | ||
|
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. @danwinship Could you clarify, in context of the previous response, how does a network policy results in increasing the count by 2?
Contributor
Author
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. in this case, |
||
| g.Expect(objs[0]).To(HaveKubernetesID("CustomResourceDefinition", "", "network-attachment-definitions.k8s.cni.cncf.io")) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("Namespace", "", "openshift-multus"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("ServiceAccount", "openshift-multus", "multus-ancillary-tools"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("ClusterRole", "", "multus-ancillary-tools"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("ClusterRoleBinding", "", "multus-ancillary-tools"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("ClusterRole", "", "multus"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("DaemonSet", "openshift-multus", "multus"))) | ||
| g.Expect(objs).To(ContainElement(HaveKubernetesID("NetworkPolicy", "openshift-multus", "default-deny"))) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.