Skip to content

Conversation

@stevsmit
Copy link
Member

@stevsmit stevsmit commented Apr 14, 2025

@openshift-ci openshift-ci bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 14, 2025
@ocpdocs-previewbot
Copy link

ocpdocs-previewbot commented Apr 14, 2025

🤖 Thu Sep 18 16:15:49 - Prow CI generated the docs preview:
https://92159--ocpdocs-pr.netlify.app
Complete list of updated preview URLs: artifacts/updated_preview_urls.txt

@openshift-ci openshift-ci bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 16, 2025
@stevsmit stevsmit force-pushed the OCPBUGS-54674 branch 3 times, most recently from b1988cc to 912c8df Compare April 17, 2025 19:50
@openshift-ci openshift-ci bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 18, 2025
@bergerhoffer
Copy link
Contributor

The branch/enterprise-4.20 label has been added to this PR.

This is because your PR targets the main branch and is labeled for enterprise-4.19. And any PR going into main must also target the latest version branch (enterprise-4.20).

If the update in your PR does NOT apply to version 4.20 onward, please re-target this PR to go directly into the appropriate version branch or branches (enterprise-4.x) instead of main.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 16, 2025
@stevsmit
Copy link
Member Author

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 16, 2025
@openshift-ci
Copy link

openshift-ci bot commented Sep 18, 2025

@stevsmit: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

$ oc apply -f ingress-access.yaml -n project-a
----

. Apply the network policy to the `project-b` namespace by entering the following command:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To simplify the example, please get rid of project-b

+
[source,terminal]
----
$ oc exec -it test-pod-b -n project-b -- ping -c 2 10.132.0.44

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ oc exec -it test-pod-b -n project-b -- ping -c 2 10.132.0.44
$ oc exec -it test-pod-a -n project-a -- ping -c 2 10.132.0.38

+
[source,terminal]
----
PING 10.132.0.44 (10.132.0.44): 56 data bytes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PING 10.132.0.44 (10.132.0.44): 56 data bytes
PING 10.132.0.38 (10.132.0.38): 56 data bytes

[source,terminal]
----
PING 10.132.0.44 (10.132.0.44): 56 data bytes
64 bytes from 10.132.0.44: seq=0 ttl=42 time=1.137 ms

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
64 bytes from 10.132.0.44: seq=0 ttl=42 time=1.137 ms
64 bytes from 10.132.0.38: seq=0 ttl=42 time=1.137 ms

----
PING 10.132.0.44 (10.132.0.44): 56 data bytes
64 bytes from 10.132.0.44: seq=0 ttl=42 time=1.137 ms
64 bytes from 10.132.0.44: seq=1 ttl=42 time=0.672 ms

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
64 bytes from 10.132.0.44: seq=1 ttl=42 time=0.672 ms
64 bytes from 10.132.0.38: seq=1 ttl=42 time=0.672 ms

+
[source,terminal]
----
$ oc new-project project-c

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ oc new-project project-c
oc new-project project-c

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This nit makes cut and paste easier

+
[source,terminal]
----
$ cat <<EOF | oc apply -f - -n project-c

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ cat <<EOF | oc apply -f - -n project-c
cat <<EOF | oc apply -f - -n project-c

+
[source,yaml]
----
apiVersion: networking.k8s.io/v1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this one should be

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-ingress-to-new
spec:
  podSelector:
    matchLabels:
      networking/allow-all-connections: "true"
  policyTypes:
  - Ingress
  ingress:
  - from:
    - podSelector: {}

+
[source,terminal]
----
$ oc apply -f allow-n1-a-to-n2-b.yaml -n project-b

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ oc apply -f allow-n1-a-to-n2-b.yaml -n project-b
oc apply -f allow-n1-a-to-n2-b.yaml -n project-b


.Procedure

. Create the following YAML that defines a `default-deny-all-egress` network policy to deny egress for all pods in the namespace. Save the YAML in the `default-deny-all-egress.yaml` file:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This policy is allow egress to dns.

+
[source,yaml]
----
apiVersion: networking.k8s.io/v1
Copy link

@asood-rh asood-rh Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Policy YAML that works

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-egress-to-openshift-dns
spec:
  egress:
  - ports:
    - port: 5353
      protocol: TCP
    - port: 5353
      protocol: UDP
  - to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: openshift-dns
  podSelector: {}
  policyTypes:
  - Egress

+
[source,terminal]
----
$ oc apply -f default-deny-all-egress.yaml -n project-a

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ oc apply -f default-deny-all-egress.yaml -n project-a
$ oc apply -f allow-egress-to-openshift-dns -n project-a

policyTypes:
- Egress
----
<1> Allows connections to port `53` on any IP to facilitate DNS lookups.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<1> Allows connections to port `53` on any IP to facilitate DNS lookups.
<1> Allows connections to port `5353` on any IP to facilitate DNS lookups.

* You have created pods in your cluster.

.Procedure

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: default-deny-all-egress
spec:
  podSelector: {}
  policyTypes:
  - Egress
 

+
[IMPORTANT]
====
Do not apply this network policy to the `kube-system` namespace, as it can break cluster functionality.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Do not apply this network policy to the `kube-system` namespace, as it can break cluster functionality.
Do not apply default-deny-all-egress network policy to the `kube-system` namespace, as it can break cluster functionality.

$ oc apply -f default-deny-all-egress.yaml -n project-b
----
+
With the application of the `default-deny-all-egress` network policy, pods in those namespaces cannot receive external traffic.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
With the application of the `default-deny-all-egress` network policy, pods in those namespaces cannot receive external traffic.
With the application of the `default-deny-all-egress` network policy, pods in those namespaces cannot send external traffic.

;; connection timed out; no servers could be reached
----

. Test ingress connection between pods in the `project-a` and `project-b` namespaces by entering the following command. Because the `default-deny-all-egress` network policy breaks pod-to-pod communication for egress, pods should not longer be able to communicate.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
. Test ingress connection between pods in the `project-a` and `project-b` namespaces by entering the following command. Because the `default-deny-all-egress` network policy breaks pod-to-pod communication for egress, pods should not longer be able to communicate.
. Test egress connection between pods in the `project-a` and `project-b` namespaces by entering the following command. Because the `default-deny-all-egress` network policy breaks pod-to-pod communication for egress, pods should not longer be able to communicate.

@bergerhoffer
Copy link
Contributor

The branch/enterprise-4.21 label has been added to this PR.

This is because your PR targets the main branch and is labeled for enterprise-4.20. And any PR going into main must also target the latest version branch (enterprise-4.21).

If the update in your PR does NOT apply to version 4.21 onward, please re-target this PR to go directly into the appropriate version branch or branches (enterprise-4.x) instead of main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants