Search in sources :

Example 1 with KafkaExporterTemplate

use of io.strimzi.api.kafka.model.template.KafkaExporterTemplate in project strimzi by strimzi.

the class KafkaExporter method fromCrd.

public static KafkaExporter fromCrd(Reconciliation reconciliation, Kafka kafkaAssembly, KafkaVersion.Lookup versions) {
    KafkaExporter kafkaExporter = new KafkaExporter(reconciliation, kafkaAssembly);
    KafkaExporterSpec spec = kafkaAssembly.getSpec().getKafkaExporter();
    if (spec != null) {
        kafkaExporter.isDeployed = true;
        kafkaExporter.setResources(spec.getResources());
        if (spec.getReadinessProbe() != null) {
            kafkaExporter.setReadinessProbe(spec.getReadinessProbe());
        }
        if (spec.getLivenessProbe() != null) {
            kafkaExporter.setLivenessProbe(spec.getLivenessProbe());
        }
        kafkaExporter.setGroupRegex(spec.getGroupRegex());
        kafkaExporter.setTopicRegex(spec.getTopicRegex());
        String image = spec.getImage();
        if (image == null) {
            KafkaClusterSpec kafkaClusterSpec = kafkaAssembly.getSpec().getKafka();
            image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_KAFKA_EXPORTER_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version()));
        }
        kafkaExporter.setImage(image);
        kafkaExporter.setLogging(spec.getLogging());
        kafkaExporter.setSaramaLoggingEnabled(spec.getEnableSaramaLogging());
        if (spec.getTemplate() != null) {
            KafkaExporterTemplate template = spec.getTemplate();
            if (template.getDeployment() != null && template.getDeployment().getMetadata() != null) {
                kafkaExporter.templateDeploymentLabels = template.getDeployment().getMetadata().getLabels();
                kafkaExporter.templateDeploymentAnnotations = template.getDeployment().getMetadata().getAnnotations();
            }
            if (template.getContainer() != null && template.getContainer().getEnv() != null) {
                kafkaExporter.templateContainerEnvVars = template.getContainer().getEnv();
            }
            if (template.getContainer() != null && template.getContainer().getSecurityContext() != null) {
                kafkaExporter.templateContainerSecurityContext = template.getContainer().getSecurityContext();
            }
            if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
                kafkaExporter.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
                kafkaExporter.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
            }
            ModelUtils.parsePodTemplate(kafkaExporter, template.getPod());
        }
        kafkaExporter.setVersion(versions.supportedVersion(kafkaAssembly.getSpec().getKafka().getVersion()).version());
        kafkaExporter.setOwnerReference(kafkaAssembly);
    } else {
        kafkaExporter.isDeployed = false;
    }
    kafkaExporter.templatePodLabels = Util.mergeLabelsOrAnnotations(kafkaExporter.templatePodLabels, DEFAULT_POD_LABELS);
    return kafkaExporter;
}
Also used : KafkaClusterSpec(io.strimzi.api.kafka.model.KafkaClusterSpec) KafkaExporterTemplate(io.strimzi.api.kafka.model.template.KafkaExporterTemplate) KafkaExporterSpec(io.strimzi.api.kafka.model.KafkaExporterSpec) IntOrString(io.fabric8.kubernetes.api.model.IntOrString)

Example 2 with KafkaExporterTemplate

use of io.strimzi.api.kafka.model.template.KafkaExporterTemplate in project strimzi-kafka-operator by strimzi.

the class KafkaExporter method fromCrd.

public static KafkaExporter fromCrd(Reconciliation reconciliation, Kafka kafkaAssembly, KafkaVersion.Lookup versions) {
    KafkaExporter kafkaExporter = new KafkaExporter(reconciliation, kafkaAssembly);
    KafkaExporterSpec spec = kafkaAssembly.getSpec().getKafkaExporter();
    if (spec != null) {
        kafkaExporter.isDeployed = true;
        kafkaExporter.setResources(spec.getResources());
        if (spec.getReadinessProbe() != null) {
            kafkaExporter.setReadinessProbe(spec.getReadinessProbe());
        }
        if (spec.getLivenessProbe() != null) {
            kafkaExporter.setLivenessProbe(spec.getLivenessProbe());
        }
        kafkaExporter.setGroupRegex(spec.getGroupRegex());
        kafkaExporter.setTopicRegex(spec.getTopicRegex());
        String image = spec.getImage();
        if (image == null) {
            KafkaClusterSpec kafkaClusterSpec = kafkaAssembly.getSpec().getKafka();
            image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_KAFKA_EXPORTER_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version()));
        }
        kafkaExporter.setImage(image);
        kafkaExporter.setLogging(spec.getLogging());
        kafkaExporter.setSaramaLoggingEnabled(spec.getEnableSaramaLogging());
        if (spec.getTemplate() != null) {
            KafkaExporterTemplate template = spec.getTemplate();
            if (template.getDeployment() != null && template.getDeployment().getMetadata() != null) {
                kafkaExporter.templateDeploymentLabels = template.getDeployment().getMetadata().getLabels();
                kafkaExporter.templateDeploymentAnnotations = template.getDeployment().getMetadata().getAnnotations();
            }
            if (template.getContainer() != null && template.getContainer().getEnv() != null) {
                kafkaExporter.templateContainerEnvVars = template.getContainer().getEnv();
            }
            if (template.getContainer() != null && template.getContainer().getSecurityContext() != null) {
                kafkaExporter.templateContainerSecurityContext = template.getContainer().getSecurityContext();
            }
            if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
                kafkaExporter.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
                kafkaExporter.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
            }
            ModelUtils.parsePodTemplate(kafkaExporter, template.getPod());
        }
        kafkaExporter.setVersion(versions.supportedVersion(kafkaAssembly.getSpec().getKafka().getVersion()).version());
        kafkaExporter.setOwnerReference(kafkaAssembly);
    } else {
        kafkaExporter.isDeployed = false;
    }
    kafkaExporter.templatePodLabels = Util.mergeLabelsOrAnnotations(kafkaExporter.templatePodLabels, DEFAULT_POD_LABELS);
    return kafkaExporter;
}
Also used : KafkaClusterSpec(io.strimzi.api.kafka.model.KafkaClusterSpec) KafkaExporterTemplate(io.strimzi.api.kafka.model.template.KafkaExporterTemplate) KafkaExporterSpec(io.strimzi.api.kafka.model.KafkaExporterSpec) IntOrString(io.fabric8.kubernetes.api.model.IntOrString)

Aggregations

IntOrString (io.fabric8.kubernetes.api.model.IntOrString)2 KafkaClusterSpec (io.strimzi.api.kafka.model.KafkaClusterSpec)2 KafkaExporterSpec (io.strimzi.api.kafka.model.KafkaExporterSpec)2 KafkaExporterTemplate (io.strimzi.api.kafka.model.template.KafkaExporterTemplate)2