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);
}
Aggregations