@@ -28,6 +28,7 @@ import (
2828
2929 appsv1 "k8s.io/api/apps/v1"
3030 corev1 "k8s.io/api/core/v1"
31+ networkingv1 "k8s.io/api/networking/v1"
3132 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3233 "sigs.k8s.io/controller-runtime/pkg/client"
3334
@@ -236,7 +237,10 @@ func upstreamPod(name, ns, image, cfgMap string) *corev1.Pod {
236237 ObjectMeta : metav1.ObjectMeta {
237238 Name : name ,
238239 Namespace : ns ,
239- Labels : map [string ]string {"test" : "upstream" },
240+ Labels : map [string ]string {
241+ "test" : "upstream" ,
242+ "type" : "test-pod" ,
243+ },
240244 },
241245 Spec : corev1.PodSpec {
242246 Volumes : []corev1.Volume {cfgVol },
@@ -297,6 +301,7 @@ func buildPod(name, ns, image string, cmd []string) *corev1.Pod {
297301 ObjectMeta : metav1.ObjectMeta {
298302 Name : name ,
299303 Namespace : ns ,
304+ Labels : map [string ]string {"type" : "test-pod" },
300305 },
301306 Spec : corev1.PodSpec {
302307 Containers : []corev1.Container {container },
@@ -433,7 +438,10 @@ func upstreamTLSPod(name, ns, image string, configMap *corev1.ConfigMap) *corev1
433438 ObjectMeta : metav1.ObjectMeta {
434439 Name : name ,
435440 Namespace : ns ,
436- Labels : map [string ]string {"test" : "upstream-tls" },
441+ Labels : map [string ]string {
442+ "test" : "upstream-tls" ,
443+ "type" : "test-pod" ,
444+ },
437445 },
438446 Spec : corev1.PodSpec {
439447 Volumes : []corev1.Volume {volume },
@@ -585,3 +593,23 @@ func lookForSubStringsInPodLogOneShot(ns, pod, container string, expectedStrings
585593 slicedResultToString := strings .Join (slicedResult , " " )
586594 return checkSubStrings (slicedResultToString , expectedStrings )
587595}
596+
597+ func buildTestPodNetworkPolicy (name types.NamespacedName ) * networkingv1.NetworkPolicy {
598+ return & networkingv1.NetworkPolicy {
599+ ObjectMeta : metav1.ObjectMeta {
600+ Namespace : name .Namespace ,
601+ Name : name .Name ,
602+ },
603+ Spec : networkingv1.NetworkPolicySpec {
604+ PodSelector : metav1.LabelSelector {
605+ MatchLabels : map [string ]string {"type" : "test-pod" },
606+ },
607+ Ingress : []networkingv1.NetworkPolicyIngressRule {{
608+ From : []networkingv1.NetworkPolicyPeer {{IPBlock : & networkingv1.IPBlock {CIDR : "0.0.0.0/0" }}},
609+ }},
610+ Egress : []networkingv1.NetworkPolicyEgressRule {{
611+ To : []networkingv1.NetworkPolicyPeer {{IPBlock : & networkingv1.IPBlock {CIDR : "0.0.0.0/0" }}},
612+ }},
613+ },
614+ }
615+ }
0 commit comments