use of io.strimzi.api.kafka.model.KafkaClusterSpec in project strimzi-kafka-operator by strimzi.
the class ResourceUtils method createKafka.
public static Kafka createKafka(String namespace, String name, int replicas, String image, int healthDelay, int healthTimeout, MetricsConfig metricsConfig, Map<String, Object> kafkaConfiguration, Map<String, Object> zooConfiguration, Storage kafkaStorage, SingleVolumeStorage zkStorage, Logging kafkaLogging, Logging zkLogging, KafkaExporterSpec keSpec, CruiseControlSpec ccSpec) {
Kafka result = new Kafka();
ObjectMeta meta = new ObjectMetaBuilder().withNamespace(namespace).withName(name).withLabels(Labels.fromMap(TestUtils.map(Labels.KUBERNETES_DOMAIN + "part-of", "tests", "my-user-label", "cromulent")).toMap()).build();
result.setMetadata(meta);
KafkaSpec spec = new KafkaSpec();
KafkaClusterSpec kafkaClusterSpec = new KafkaClusterSpec();
kafkaClusterSpec.setReplicas(replicas);
kafkaClusterSpec.setListeners(singletonList(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withTls(false).withType(KafkaListenerType.INTERNAL).build()));
kafkaClusterSpec.setImage(image);
if (kafkaLogging != null) {
kafkaClusterSpec.setLogging(kafkaLogging);
}
Probe livenessProbe = new Probe();
livenessProbe.setInitialDelaySeconds(healthDelay);
livenessProbe.setTimeoutSeconds(healthTimeout);
livenessProbe.setSuccessThreshold(4);
livenessProbe.setFailureThreshold(10);
livenessProbe.setPeriodSeconds(33);
kafkaClusterSpec.setLivenessProbe(livenessProbe);
kafkaClusterSpec.setReadinessProbe(livenessProbe);
kafkaClusterSpec.setMetricsConfig(metricsConfig);
if (kafkaConfiguration != null) {
kafkaClusterSpec.setConfig(kafkaConfiguration);
}
kafkaClusterSpec.setStorage(kafkaStorage);
spec.setKafka(kafkaClusterSpec);
ZookeeperClusterSpec zk = new ZookeeperClusterSpec();
zk.setReplicas(replicas);
zk.setImage(image + "-zk");
if (zkLogging != null) {
zk.setLogging(zkLogging);
}
zk.setLivenessProbe(livenessProbe);
zk.setReadinessProbe(livenessProbe);
if (zooConfiguration != null) {
zk.setConfig(zooConfiguration);
}
zk.setStorage(zkStorage);
zk.setMetricsConfig(metricsConfig);
spec.setKafkaExporter(keSpec);
spec.setCruiseControl(ccSpec);
spec.setZookeeper(zk);
result.setSpec(spec);
return result;
}
Aggregations