Search in sources :

Example 1 with DefaultNetworkPolicy

use of io.strimzi.systemtest.enums.DefaultNetworkPolicy in project strimzi by strimzi.

the class NetworkPolicyTemplates method applyDefaultNetworkPolicy.

public static NetworkPolicy applyDefaultNetworkPolicy(ExtensionContext extensionContext, String namespace, DefaultNetworkPolicy policy) {
    NetworkPolicy networkPolicy = new NetworkPolicyBuilder().withApiVersion("networking.k8s.io/v1").withKind(Constants.NETWORK_POLICY).withNewMetadata().withName("global-network-policy").withNamespace(namespace).endMetadata().withNewSpec().withNewPodSelector().endPodSelector().withPolicyTypes("Ingress").endSpec().build();
    if (policy.equals(DefaultNetworkPolicy.DEFAULT_TO_ALLOW)) {
        networkPolicy = new NetworkPolicyBuilder(networkPolicy).editSpec().addNewIngress().endIngress().endSpec().build();
    }
    LOGGER.debug("Creating NetworkPolicy: {}", networkPolicy.toString());
    return networkPolicy;
}
Also used : NetworkPolicy(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy) DefaultNetworkPolicy(io.strimzi.systemtest.enums.DefaultNetworkPolicy) NetworkPolicyBuilder(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyBuilder)

Example 2 with DefaultNetworkPolicy

use of io.strimzi.systemtest.enums.DefaultNetworkPolicy in project strimzi-kafka-operator by strimzi.

the class NetworkPolicyTemplates method applyDefaultNetworkPolicy.

public static NetworkPolicy applyDefaultNetworkPolicy(ExtensionContext extensionContext, String namespace, DefaultNetworkPolicy policy) {
    NetworkPolicy networkPolicy = new NetworkPolicyBuilder().withApiVersion("networking.k8s.io/v1").withKind(Constants.NETWORK_POLICY).withNewMetadata().withName("global-network-policy").withNamespace(namespace).endMetadata().withNewSpec().withNewPodSelector().endPodSelector().withPolicyTypes("Ingress").endSpec().build();
    if (policy.equals(DefaultNetworkPolicy.DEFAULT_TO_ALLOW)) {
        networkPolicy = new NetworkPolicyBuilder(networkPolicy).editSpec().addNewIngress().endIngress().endSpec().build();
    }
    LOGGER.debug("Creating NetworkPolicy: {}", networkPolicy.toString());
    return networkPolicy;
}
Also used : NetworkPolicy(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy) DefaultNetworkPolicy(io.strimzi.systemtest.enums.DefaultNetworkPolicy) NetworkPolicyBuilder(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyBuilder)

Aggregations

NetworkPolicy (io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy)2 NetworkPolicyBuilder (io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyBuilder)2 DefaultNetworkPolicy (io.strimzi.systemtest.enums.DefaultNetworkPolicy)2