This repository contains automation and manifests to deploy multiple test applications
(webmirinda-X) across namespaces and validate NetworkPolicy and AdminNetworkPolicy
behavior in OpenShift with OVN-Kubernetes.
-
scripts/
-
.create-ns-app.shCreates multiple namespaces (mirinda-1 … mirinda-N) with the labelcompany=rh, deploys a demo httpd app (webmirinda-X) and applies aNetworkPolicyon each of those namespaces. The NetworkPolicy allows ingress/egress traffic only between namespaces labeledcompany=rh. Finally the script creates the namespace (amador) and deploys the same httpd application, but does not add the labelcompany=rh -
test-connectivity.shHelper script to:- Gather ACL and
Logical_Flowcounts from anovnkube-nodepod. - Run curl-based connectivity tests between pods in
ALLOWED_NS(mirinda-1,mirinda-2) andBLOCKED_NS(amador). - Validate that traffic is allowed/denied according to applied policies.
- Gather ACL and
-
-
manifests/
-
admin-networkpolicy.yamlExampleAdminNetworkPolicyaffecting namespaces with the labelcompany=rh. This policy: allows ingress traffic from namespaces labeledcompany=rhand blocks any other ingress traffic; allows egress traffic to namespaces labeledcompany=rh; allows egress traffic to the internal Openshift DNS resolver; denies any other egress traffic. -
networkpolicy.yamlStandardNetworkPolicythat allows ingress and egress only from/to namespaces labeledcompany=rh.
-
By default, the script creates X namespaces (mirinda-1 … mirinda-5):
sh ./scripts/create-ns-app.shThis will:
- Create projects mirinda-1 … mirinda-5 and amador
- Deploy webmirinda-X apps (based on UBI9 httpd)
- Apply the NetworkPolicy (enable-company-rh)
- Create the blocked amador project
- Deploy the webcliamador app (based on UBI9 httpd)
After deployment, run:
sh ./scripts/test-connectivity.shThis will:
- Show OVN ACL and Logical Flow counts from an ovnkube-node pod
== Información de OVN al inicio === Número de ACLs: 310 Número de Logical_Flow UUIDs: 1572 ===================================
- Test connectivity between:
- Allowed namespaces (mirinda-1, mirinda-2) → should succeed ✅
- Allowed → Blocked (mirinda-* → amador) → should fail ❌
- Blocked → Allowed (amador → mirinda-*) → should fail ❌
Make sure all NetworkPolicies are deleted:
for x in $(oc get ns | grep 'mirinda-'|awk '{print $1}'); do oc delete networkpolicy enable-company-rh -n $x; doneApply the AdminNetworkPolicy, which has a similar effect to the previous network policies:
oc apply -f manifests/admin-networkpolicy.yamlRun the connectivity tests again.
./scripts/test-connectivity.shThe tests results should be the same as before, but the number of ACLs should be significantly reduced:
- Show OVN ACL and Logical Flow counts from an ovnkube-node pod
== Información de OVN al inicio === Número de ACLs: 70 Número de Logical_Flow UUIDs: 1103 ===================================
- Test connectivity between:
- Allowed namespaces (mirinda-1, mirinda-2) → should succeed ✅
- Allowed → Blocked (mirinda-* → amador) → should fail ❌
- Blocked → Allowed (amador → mirinda-*) → should fail ❌