use of io.strimzi.api.kafka.model.template.ZookeeperClusterTemplateBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaCluster method buildZookeeperTemplate.
private ZookeeperClusterTemplate buildZookeeperTemplate(ManagedKafka managedKafka) {
// onePerNode = true - one zk per node exclusively
// onePerNode = false - one zk per node per managedkafka
boolean onePerNode = this.config.getKafka().isOneInstancePerNode();
PodNested<ZookeeperClusterTemplateBuilder> podNestedBuilder = new ZookeeperClusterTemplateBuilder().withNewPod().withImagePullSecrets(imagePullSecretManager.getOperatorImagePullSecrets(managedKafka)).withTopologySpreadConstraints(azAwareTopologySpreadConstraint(managedKafka.getMetadata().getName() + "-zookeeper", DO_NOT_SCHEDULE));
if (onePerNode) {
PodAffinityTerm affinityTerm = affinityTerm("app.kubernetes.io/name", "zookeeper");
affinityTerm.setNamespaceSelector(new LabelSelector());
PodAntiAffinity podAntiAffinity = new PodAntiAffinityBuilder().withRequiredDuringSchedulingIgnoredDuringExecution(affinityTerm).build();
AffinityBuilder affinityBuilder = new AffinityBuilder();
affinityBuilder.withPodAntiAffinity(podAntiAffinity);
podNestedBuilder.withAffinity(affinityBuilder.build());
}
ZookeeperClusterTemplateBuilder templateBuilder = podNestedBuilder.endPod();
if (drainCleanerManager.isDrainCleanerWebhookFound()) {
templateBuilder.withPodDisruptionBudget(new PodDisruptionBudgetTemplateBuilder().withMaxUnavailable(0).build());
}
return templateBuilder.build();
}
Aggregations