Search in sources :

Example 1 with ZookeeperClusterTemplateBuilder

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();
}
Also used : PodAffinityTerm(io.fabric8.kubernetes.api.model.PodAffinityTerm) PodAntiAffinityBuilder(io.fabric8.kubernetes.api.model.PodAntiAffinityBuilder) AffinityBuilder(io.fabric8.kubernetes.api.model.AffinityBuilder) PodAntiAffinityBuilder(io.fabric8.kubernetes.api.model.PodAntiAffinityBuilder) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) ZookeeperClusterTemplateBuilder(io.strimzi.api.kafka.model.template.ZookeeperClusterTemplateBuilder) PodAntiAffinity(io.fabric8.kubernetes.api.model.PodAntiAffinity) PodDisruptionBudgetTemplateBuilder(io.strimzi.api.kafka.model.template.PodDisruptionBudgetTemplateBuilder)

Aggregations

AffinityBuilder (io.fabric8.kubernetes.api.model.AffinityBuilder)1 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)1 PodAffinityTerm (io.fabric8.kubernetes.api.model.PodAffinityTerm)1 PodAntiAffinity (io.fabric8.kubernetes.api.model.PodAntiAffinity)1 PodAntiAffinityBuilder (io.fabric8.kubernetes.api.model.PodAntiAffinityBuilder)1 PodDisruptionBudgetTemplateBuilder (io.strimzi.api.kafka.model.template.PodDisruptionBudgetTemplateBuilder)1 ZookeeperClusterTemplateBuilder (io.strimzi.api.kafka.model.template.ZookeeperClusterTemplateBuilder)1