Search in sources :

Example 1 with KafkaMirrorMakerTemplate

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

the class KafkaMirrorMakerCluster method fromCrd.

@SuppressWarnings("deprecation")
public static KafkaMirrorMakerCluster fromCrd(Reconciliation reconciliation, KafkaMirrorMaker kafkaMirrorMaker, KafkaVersion.Lookup versions) {
    KafkaMirrorMakerCluster kafkaMirrorMakerCluster = new KafkaMirrorMakerCluster(reconciliation, kafkaMirrorMaker);
    KafkaMirrorMakerSpec spec = kafkaMirrorMaker.getSpec();
    if (spec != null) {
        kafkaMirrorMakerCluster.setReplicas(spec.getReplicas());
        kafkaMirrorMakerCluster.setResources(spec.getResources());
        if (spec.getReadinessProbe() != null) {
            kafkaMirrorMakerCluster.setReadinessProbe(spec.getReadinessProbe());
        }
        if (spec.getLivenessProbe() != null) {
            kafkaMirrorMakerCluster.setLivenessProbe(spec.getLivenessProbe());
        }
        String whitelist = spec.getWhitelist();
        String include = spec.getInclude();
        if (include == null && whitelist == null) {
            throw new InvalidResourceException("One of the fields include or whitelist needs to be specified.");
        } else if (whitelist != null && include != null) {
            LOGGER.warnCr(reconciliation, "Both include and whitelist fields are present. Whitelist is deprecated and will be ignored.");
        }
        kafkaMirrorMakerCluster.setInclude(include != null ? include : whitelist);
        String warnMsg = AuthenticationUtils.validateClientAuthentication(spec.getProducer().getAuthentication(), spec.getProducer().getTls() != null);
        if (!warnMsg.isEmpty()) {
            LOGGER.warnCr(reconciliation, warnMsg);
        }
        kafkaMirrorMakerCluster.setProducer(spec.getProducer());
        warnMsg = AuthenticationUtils.validateClientAuthentication(spec.getConsumer().getAuthentication(), spec.getConsumer().getTls() != null);
        if (!warnMsg.isEmpty()) {
            LOGGER.warnCr(reconciliation, warnMsg);
        }
        kafkaMirrorMakerCluster.setConsumer(spec.getConsumer());
        kafkaMirrorMakerCluster.setImage(versions.kafkaMirrorMakerImage(spec.getImage(), spec.getVersion()));
        kafkaMirrorMakerCluster.setLogging(spec.getLogging());
        kafkaMirrorMakerCluster.setGcLoggingEnabled(spec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : spec.getJvmOptions().isGcLoggingEnabled());
        if (spec.getJvmOptions() != null) {
            kafkaMirrorMakerCluster.setJavaSystemProperties(spec.getJvmOptions().getJavaSystemProperties());
        }
        kafkaMirrorMakerCluster.setJvmOptions(spec.getJvmOptions());
        // Parse different types of metrics configurations
        ModelUtils.parseMetrics(kafkaMirrorMakerCluster, spec);
        if (spec.getTemplate() != null) {
            KafkaMirrorMakerTemplate template = spec.getTemplate();
            if (template.getMirrorMakerContainer() != null && template.getMirrorMakerContainer().getEnv() != null) {
                kafkaMirrorMakerCluster.templateContainerEnvVars = template.getMirrorMakerContainer().getEnv();
            }
            if (template.getMirrorMakerContainer() != null && template.getMirrorMakerContainer().getSecurityContext() != null) {
                kafkaMirrorMakerCluster.templateContainerSecurityContext = template.getMirrorMakerContainer().getSecurityContext();
            }
            if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
                kafkaMirrorMakerCluster.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
                kafkaMirrorMakerCluster.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
            }
            ModelUtils.parseDeploymentTemplate(kafkaMirrorMakerCluster, template.getDeployment());
            ModelUtils.parsePodTemplate(kafkaMirrorMakerCluster, template.getPod());
            ModelUtils.parsePodDisruptionBudgetTemplate(kafkaMirrorMakerCluster, template.getPodDisruptionBudget());
        }
        kafkaMirrorMakerCluster.tracing = spec.getTracing();
    }
    kafkaMirrorMakerCluster.templatePodLabels = Util.mergeLabelsOrAnnotations(kafkaMirrorMakerCluster.templatePodLabels, DEFAULT_POD_LABELS);
    kafkaMirrorMakerCluster.setOwnerReference(kafkaMirrorMaker);
    return kafkaMirrorMakerCluster;
}
Also used : KafkaMirrorMakerSpec(io.strimzi.api.kafka.model.KafkaMirrorMakerSpec) KafkaMirrorMakerTemplate(io.strimzi.api.kafka.model.template.KafkaMirrorMakerTemplate)

Example 2 with KafkaMirrorMakerTemplate

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

the class KafkaMirrorMakerCluster method fromCrd.

@SuppressWarnings("deprecation")
public static KafkaMirrorMakerCluster fromCrd(Reconciliation reconciliation, KafkaMirrorMaker kafkaMirrorMaker, KafkaVersion.Lookup versions) {
    KafkaMirrorMakerCluster kafkaMirrorMakerCluster = new KafkaMirrorMakerCluster(reconciliation, kafkaMirrorMaker);
    KafkaMirrorMakerSpec spec = kafkaMirrorMaker.getSpec();
    if (spec != null) {
        kafkaMirrorMakerCluster.setReplicas(spec.getReplicas());
        kafkaMirrorMakerCluster.setResources(spec.getResources());
        if (spec.getReadinessProbe() != null) {
            kafkaMirrorMakerCluster.setReadinessProbe(spec.getReadinessProbe());
        }
        if (spec.getLivenessProbe() != null) {
            kafkaMirrorMakerCluster.setLivenessProbe(spec.getLivenessProbe());
        }
        String whitelist = spec.getWhitelist();
        String include = spec.getInclude();
        if (include == null && whitelist == null) {
            throw new InvalidResourceException("One of the fields include or whitelist needs to be specified.");
        } else if (whitelist != null && include != null) {
            LOGGER.warnCr(reconciliation, "Both include and whitelist fields are present. Whitelist is deprecated and will be ignored.");
        }
        kafkaMirrorMakerCluster.setInclude(include != null ? include : whitelist);
        String warnMsg = AuthenticationUtils.validateClientAuthentication(spec.getProducer().getAuthentication(), spec.getProducer().getTls() != null);
        if (!warnMsg.isEmpty()) {
            LOGGER.warnCr(reconciliation, warnMsg);
        }
        kafkaMirrorMakerCluster.setProducer(spec.getProducer());
        warnMsg = AuthenticationUtils.validateClientAuthentication(spec.getConsumer().getAuthentication(), spec.getConsumer().getTls() != null);
        if (!warnMsg.isEmpty()) {
            LOGGER.warnCr(reconciliation, warnMsg);
        }
        kafkaMirrorMakerCluster.setConsumer(spec.getConsumer());
        kafkaMirrorMakerCluster.setImage(versions.kafkaMirrorMakerImage(spec.getImage(), spec.getVersion()));
        kafkaMirrorMakerCluster.setLogging(spec.getLogging());
        kafkaMirrorMakerCluster.setGcLoggingEnabled(spec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : spec.getJvmOptions().isGcLoggingEnabled());
        if (spec.getJvmOptions() != null) {
            kafkaMirrorMakerCluster.setJavaSystemProperties(spec.getJvmOptions().getJavaSystemProperties());
        }
        kafkaMirrorMakerCluster.setJvmOptions(spec.getJvmOptions());
        // Parse different types of metrics configurations
        ModelUtils.parseMetrics(kafkaMirrorMakerCluster, spec);
        if (spec.getTemplate() != null) {
            KafkaMirrorMakerTemplate template = spec.getTemplate();
            if (template.getMirrorMakerContainer() != null && template.getMirrorMakerContainer().getEnv() != null) {
                kafkaMirrorMakerCluster.templateContainerEnvVars = template.getMirrorMakerContainer().getEnv();
            }
            if (template.getMirrorMakerContainer() != null && template.getMirrorMakerContainer().getSecurityContext() != null) {
                kafkaMirrorMakerCluster.templateContainerSecurityContext = template.getMirrorMakerContainer().getSecurityContext();
            }
            if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
                kafkaMirrorMakerCluster.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
                kafkaMirrorMakerCluster.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
            }
            ModelUtils.parseDeploymentTemplate(kafkaMirrorMakerCluster, template.getDeployment());
            ModelUtils.parsePodTemplate(kafkaMirrorMakerCluster, template.getPod());
            ModelUtils.parsePodDisruptionBudgetTemplate(kafkaMirrorMakerCluster, template.getPodDisruptionBudget());
        }
        kafkaMirrorMakerCluster.tracing = spec.getTracing();
    }
    kafkaMirrorMakerCluster.templatePodLabels = Util.mergeLabelsOrAnnotations(kafkaMirrorMakerCluster.templatePodLabels, DEFAULT_POD_LABELS);
    kafkaMirrorMakerCluster.setOwnerReference(kafkaMirrorMaker);
    return kafkaMirrorMakerCluster;
}
Also used : KafkaMirrorMakerSpec(io.strimzi.api.kafka.model.KafkaMirrorMakerSpec) KafkaMirrorMakerTemplate(io.strimzi.api.kafka.model.template.KafkaMirrorMakerTemplate)

Aggregations

KafkaMirrorMakerSpec (io.strimzi.api.kafka.model.KafkaMirrorMakerSpec)2 KafkaMirrorMakerTemplate (io.strimzi.api.kafka.model.template.KafkaMirrorMakerTemplate)2