Search in sources :

Example 1 with KafkaBridgeTemplate

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

the class KafkaBridgeCluster method fromCrd.

public static KafkaBridgeCluster fromCrd(Reconciliation reconciliation, KafkaBridge kafkaBridge, KafkaVersion.Lookup versions) {
    KafkaBridgeCluster kafkaBridgeCluster = new KafkaBridgeCluster(reconciliation, kafkaBridge);
    KafkaBridgeSpec spec = kafkaBridge.getSpec();
    kafkaBridgeCluster.tracing = spec.getTracing();
    kafkaBridgeCluster.setResources(spec.getResources());
    kafkaBridgeCluster.setLogging(spec.getLogging());
    kafkaBridgeCluster.setGcLoggingEnabled(spec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : spec.getJvmOptions().isGcLoggingEnabled());
    if (spec.getJvmOptions() != null) {
        kafkaBridgeCluster.setJavaSystemProperties(spec.getJvmOptions().getJavaSystemProperties());
    }
    kafkaBridgeCluster.setJvmOptions(spec.getJvmOptions());
    String image = spec.getImage();
    if (image == null) {
        image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_KAFKA_BRIDGE_IMAGE, "quay.io/strimzi/kafka-bridge:latest");
    }
    kafkaBridgeCluster.setImage(image);
    kafkaBridgeCluster.setReplicas(spec.getReplicas());
    kafkaBridgeCluster.setBootstrapServers(spec.getBootstrapServers());
    kafkaBridgeCluster.setKafkaAdminClientConfiguration(spec.getAdminClient());
    kafkaBridgeCluster.setKafkaConsumerConfiguration(spec.getConsumer());
    kafkaBridgeCluster.setKafkaProducerConfiguration(spec.getProducer());
    if (kafkaBridge.getSpec().getLivenessProbe() != null) {
        kafkaBridgeCluster.setLivenessProbe(kafkaBridge.getSpec().getLivenessProbe());
    }
    if (kafkaBridge.getSpec().getReadinessProbe() != null) {
        kafkaBridgeCluster.setReadinessProbe(kafkaBridge.getSpec().getReadinessProbe());
    }
    kafkaBridgeCluster.setMetricsEnabled(spec.getEnableMetrics());
    kafkaBridgeCluster.setTls(spec.getTls() != null ? spec.getTls() : null);
    String warnMsg = AuthenticationUtils.validateClientAuthentication(spec.getAuthentication(), spec.getTls() != null);
    if (!warnMsg.isEmpty()) {
        LOGGER.warnCr(reconciliation, warnMsg);
    }
    kafkaBridgeCluster.setAuthentication(spec.getAuthentication());
    if (spec.getTemplate() != null) {
        KafkaBridgeTemplate template = spec.getTemplate();
        ModelUtils.parseDeploymentTemplate(kafkaBridgeCluster, template.getDeployment());
        ModelUtils.parsePodTemplate(kafkaBridgeCluster, template.getPod());
        ModelUtils.parseInternalServiceTemplate(kafkaBridgeCluster, template.getApiService());
        if (template.getApiService() != null && template.getApiService().getMetadata() != null) {
            kafkaBridgeCluster.templateServiceLabels = template.getApiService().getMetadata().getLabels();
            kafkaBridgeCluster.templateServiceAnnotations = template.getApiService().getMetadata().getAnnotations();
        }
        if (template.getBridgeContainer() != null && template.getBridgeContainer().getEnv() != null) {
            kafkaBridgeCluster.templateContainerEnvVars = template.getBridgeContainer().getEnv();
        }
        if (template.getBridgeContainer() != null && template.getBridgeContainer().getSecurityContext() != null) {
            kafkaBridgeCluster.templateContainerSecurityContext = template.getBridgeContainer().getSecurityContext();
        }
        if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
            kafkaBridgeCluster.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
            kafkaBridgeCluster.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
        }
        ModelUtils.parsePodDisruptionBudgetTemplate(kafkaBridgeCluster, template.getPodDisruptionBudget());
    }
    kafkaBridgeCluster.templatePodLabels = Util.mergeLabelsOrAnnotations(kafkaBridgeCluster.templatePodLabels, DEFAULT_POD_LABELS);
    if (spec.getHttp() != null) {
        kafkaBridgeCluster.setHttpEnabled(true);
        kafkaBridgeCluster.setKafkaBridgeHttpConfig(spec.getHttp());
    } else {
        LOGGER.warnCr(reconciliation, "No protocol specified.");
        throw new InvalidResourceException("No protocol for communication with Bridge specified. Use HTTP.");
    }
    kafkaBridgeCluster.setOwnerReference(kafkaBridge);
    return kafkaBridgeCluster;
}
Also used : KafkaBridgeSpec(io.strimzi.api.kafka.model.KafkaBridgeSpec) KafkaBridgeTemplate(io.strimzi.api.kafka.model.template.KafkaBridgeTemplate)

Example 2 with KafkaBridgeTemplate

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

the class KafkaBridgeCluster method fromCrd.

public static KafkaBridgeCluster fromCrd(Reconciliation reconciliation, KafkaBridge kafkaBridge, KafkaVersion.Lookup versions) {
    KafkaBridgeCluster kafkaBridgeCluster = new KafkaBridgeCluster(reconciliation, kafkaBridge);
    KafkaBridgeSpec spec = kafkaBridge.getSpec();
    kafkaBridgeCluster.tracing = spec.getTracing();
    kafkaBridgeCluster.setResources(spec.getResources());
    kafkaBridgeCluster.setLogging(spec.getLogging());
    kafkaBridgeCluster.setGcLoggingEnabled(spec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : spec.getJvmOptions().isGcLoggingEnabled());
    if (spec.getJvmOptions() != null) {
        kafkaBridgeCluster.setJavaSystemProperties(spec.getJvmOptions().getJavaSystemProperties());
    }
    kafkaBridgeCluster.setJvmOptions(spec.getJvmOptions());
    String image = spec.getImage();
    if (image == null) {
        image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_KAFKA_BRIDGE_IMAGE, "quay.io/strimzi/kafka-bridge:latest");
    }
    kafkaBridgeCluster.setImage(image);
    kafkaBridgeCluster.setReplicas(spec.getReplicas());
    kafkaBridgeCluster.setBootstrapServers(spec.getBootstrapServers());
    kafkaBridgeCluster.setKafkaAdminClientConfiguration(spec.getAdminClient());
    kafkaBridgeCluster.setKafkaConsumerConfiguration(spec.getConsumer());
    kafkaBridgeCluster.setKafkaProducerConfiguration(spec.getProducer());
    if (kafkaBridge.getSpec().getLivenessProbe() != null) {
        kafkaBridgeCluster.setLivenessProbe(kafkaBridge.getSpec().getLivenessProbe());
    }
    if (kafkaBridge.getSpec().getReadinessProbe() != null) {
        kafkaBridgeCluster.setReadinessProbe(kafkaBridge.getSpec().getReadinessProbe());
    }
    kafkaBridgeCluster.setMetricsEnabled(spec.getEnableMetrics());
    kafkaBridgeCluster.setTls(spec.getTls() != null ? spec.getTls() : null);
    String warnMsg = AuthenticationUtils.validateClientAuthentication(spec.getAuthentication(), spec.getTls() != null);
    if (!warnMsg.isEmpty()) {
        LOGGER.warnCr(reconciliation, warnMsg);
    }
    kafkaBridgeCluster.setAuthentication(spec.getAuthentication());
    if (spec.getTemplate() != null) {
        KafkaBridgeTemplate template = spec.getTemplate();
        ModelUtils.parseDeploymentTemplate(kafkaBridgeCluster, template.getDeployment());
        ModelUtils.parsePodTemplate(kafkaBridgeCluster, template.getPod());
        ModelUtils.parseInternalServiceTemplate(kafkaBridgeCluster, template.getApiService());
        if (template.getApiService() != null && template.getApiService().getMetadata() != null) {
            kafkaBridgeCluster.templateServiceLabels = template.getApiService().getMetadata().getLabels();
            kafkaBridgeCluster.templateServiceAnnotations = template.getApiService().getMetadata().getAnnotations();
        }
        if (template.getBridgeContainer() != null && template.getBridgeContainer().getEnv() != null) {
            kafkaBridgeCluster.templateContainerEnvVars = template.getBridgeContainer().getEnv();
        }
        if (template.getBridgeContainer() != null && template.getBridgeContainer().getSecurityContext() != null) {
            kafkaBridgeCluster.templateContainerSecurityContext = template.getBridgeContainer().getSecurityContext();
        }
        if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
            kafkaBridgeCluster.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
            kafkaBridgeCluster.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
        }
        ModelUtils.parsePodDisruptionBudgetTemplate(kafkaBridgeCluster, template.getPodDisruptionBudget());
    }
    kafkaBridgeCluster.templatePodLabels = Util.mergeLabelsOrAnnotations(kafkaBridgeCluster.templatePodLabels, DEFAULT_POD_LABELS);
    if (spec.getHttp() != null) {
        kafkaBridgeCluster.setHttpEnabled(true);
        kafkaBridgeCluster.setKafkaBridgeHttpConfig(spec.getHttp());
    } else {
        LOGGER.warnCr(reconciliation, "No protocol specified.");
        throw new InvalidResourceException("No protocol for communication with Bridge specified. Use HTTP.");
    }
    kafkaBridgeCluster.setOwnerReference(kafkaBridge);
    return kafkaBridgeCluster;
}
Also used : KafkaBridgeSpec(io.strimzi.api.kafka.model.KafkaBridgeSpec) KafkaBridgeTemplate(io.strimzi.api.kafka.model.template.KafkaBridgeTemplate)

Aggregations

KafkaBridgeSpec (io.strimzi.api.kafka.model.KafkaBridgeSpec)2 KafkaBridgeTemplate (io.strimzi.api.kafka.model.template.KafkaBridgeTemplate)2