Search in sources :

Example 1 with NetworkPolicyPortBuilder

use of io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyPortBuilder in project debezium by debezium.

the class OcpKafkaConnectController method allowServiceAccess.

/**
 * Creates network policy allowing access to ports exposed by Kafka Connect
 *
 * @return
 */
public NetworkPolicy allowServiceAccess() {
    LOGGER.info("Creating NetworkPolicy allowing public access to " + kafkaConnect.getMetadata().getName() + "'s services");
    Map<String, String> labels = new HashMap<>();
    labels.put("strimzi.io/cluster", kafkaConnect.getMetadata().getName());
    labels.put("strimzi.io/kind", "KafkaConnect");
    labels.put("strimzi.io/name", kafkaConnect.getMetadata().getName() + "-connect");
    List<NetworkPolicyPort> ports = Stream.of(8083, 8404, 9404).map(IntOrString::new).map(p -> new NetworkPolicyPortBuilder().withProtocol("TCP").withPort(p).build()).collect(Collectors.toList());
    return ocpUtils.createNetworkPolicy(project, kafkaConnect.getMetadata().getName() + "-allowed", labels, ports);
}
Also used : WaitConditions(io.debezium.testing.system.tools.WaitConditions) Crds.kafkaConnectOperation(io.strimzi.api.kafka.Crds.kafkaConnectOperation) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) LoggerFactory(org.slf4j.LoggerFactory) MINUTES(java.util.concurrent.TimeUnit.MINUTES) HashMap(java.util.HashMap) Crds(io.strimzi.api.kafka.Crds) WaitConditions.scaled(io.debezium.testing.system.tools.WaitConditions.scaled) RestPrometheusMetricReader(io.debezium.testing.system.tools.kafka.connectors.RestPrometheusMetricReader) Route(io.fabric8.openshift.api.model.Route) Map(java.util.Map) NetworkPolicyPort(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyPort) NetworkPolicyPortBuilder(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyPortBuilder) Service(io.fabric8.kubernetes.api.model.Service) CustomResourceConnectorDeployer(io.debezium.testing.system.tools.kafka.connectors.CustomResourceConnectorDeployer) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) Awaitility.await(org.awaitility.Awaitility.await) Logger(org.slf4j.Logger) ConnectorMetricsReader(io.debezium.testing.system.tools.kafka.connectors.ConnectorMetricsReader) JsonConnectorDeployer(io.debezium.testing.system.tools.kafka.connectors.JsonConnectorDeployer) OpenShiftUtils(io.debezium.testing.system.tools.OpenShiftUtils) IOException(java.io.IOException) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Collectors(java.util.stream.Collectors) HttpUtils(io.debezium.testing.system.tools.HttpUtils) List(java.util.List) Stream(java.util.stream.Stream) OkHttpClient(okhttp3.OkHttpClient) NetworkPolicy(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy) HttpUrl(okhttp3.HttpUrl) ConnectorDeployer(io.debezium.testing.system.tools.kafka.connectors.ConnectorDeployer) SECONDS(java.util.concurrent.TimeUnit.SECONDS) NetworkPolicyPort(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyPort) HashMap(java.util.HashMap) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) NetworkPolicyPortBuilder(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyPortBuilder) IntOrString(io.fabric8.kubernetes.api.model.IntOrString)

Aggregations

HttpUtils (io.debezium.testing.system.tools.HttpUtils)1 OpenShiftUtils (io.debezium.testing.system.tools.OpenShiftUtils)1 WaitConditions (io.debezium.testing.system.tools.WaitConditions)1 WaitConditions.scaled (io.debezium.testing.system.tools.WaitConditions.scaled)1 ConnectorDeployer (io.debezium.testing.system.tools.kafka.connectors.ConnectorDeployer)1 ConnectorMetricsReader (io.debezium.testing.system.tools.kafka.connectors.ConnectorMetricsReader)1 CustomResourceConnectorDeployer (io.debezium.testing.system.tools.kafka.connectors.CustomResourceConnectorDeployer)1 JsonConnectorDeployer (io.debezium.testing.system.tools.kafka.connectors.JsonConnectorDeployer)1 RestPrometheusMetricReader (io.debezium.testing.system.tools.kafka.connectors.RestPrometheusMetricReader)1 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)1 Service (io.fabric8.kubernetes.api.model.Service)1 NetworkPolicy (io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy)1 NetworkPolicyPort (io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyPort)1 NetworkPolicyPortBuilder (io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyPortBuilder)1 Route (io.fabric8.openshift.api.model.Route)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1 Crds (io.strimzi.api.kafka.Crds)1 Crds.kafkaConnectOperation (io.strimzi.api.kafka.Crds.kafkaConnectOperation)1 KafkaConnect (io.strimzi.api.kafka.model.KafkaConnect)1 IOException (java.io.IOException)1