Search in sources :

Example 1 with EntityOperatorTemplate

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

the class EntityOperator method fromCrd.

/**
 * Create a Entity Operator from given desired resource
 *
 * @param reconciliation The reconciliation
 * @param kafkaAssembly desired resource with cluster configuration containing the Entity Operator one
 * @param versions The versions.
 * @return Entity Operator instance, null if not configured in the ConfigMap
 */
public static EntityOperator fromCrd(Reconciliation reconciliation, Kafka kafkaAssembly, KafkaVersion.Lookup versions) {
    EntityOperator result = null;
    EntityOperatorSpec entityOperatorSpec = kafkaAssembly.getSpec().getEntityOperator();
    if (entityOperatorSpec != null) {
        result = new EntityOperator(reconciliation, kafkaAssembly);
        result.setOwnerReference(kafkaAssembly);
        EntityTopicOperator topicOperator = EntityTopicOperator.fromCrd(reconciliation, kafkaAssembly);
        EntityUserOperator userOperator = EntityUserOperator.fromCrd(reconciliation, kafkaAssembly);
        TlsSidecar tlsSidecar = entityOperatorSpec.getTlsSidecar();
        if (entityOperatorSpec.getTemplate() != null) {
            EntityOperatorTemplate template = entityOperatorSpec.getTemplate();
            if (template.getDeployment() != null && template.getDeployment().getMetadata() != null) {
                result.templateDeploymentLabels = template.getDeployment().getMetadata().getLabels();
                result.templateDeploymentAnnotations = template.getDeployment().getMetadata().getAnnotations();
            }
            ModelUtils.parsePodTemplate(result, template.getPod());
            if (template.getTopicOperatorContainer() != null && template.getTopicOperatorContainer().getEnv() != null) {
                topicOperator.setContainerEnvVars(template.getTopicOperatorContainer().getEnv());
            }
            if (template.getTopicOperatorContainer() != null && template.getTopicOperatorContainer().getSecurityContext() != null) {
                topicOperator.setContainerSecurityContext(template.getTopicOperatorContainer().getSecurityContext());
            }
            if (template.getUserOperatorContainer() != null && template.getUserOperatorContainer().getEnv() != null) {
                userOperator.setContainerEnvVars(template.getUserOperatorContainer().getEnv());
            }
            if (template.getUserOperatorContainer() != null && template.getUserOperatorContainer().getSecurityContext() != null) {
                userOperator.setContainerSecurityContext(template.getUserOperatorContainer().getSecurityContext());
            }
            if (template.getTlsSidecarContainer() != null && template.getTlsSidecarContainer().getEnv() != null) {
                result.templateTlsSidecarContainerEnvVars = template.getTlsSidecarContainer().getEnv();
            }
            if (template.getTlsSidecarContainer() != null && template.getTlsSidecarContainer().getSecurityContext() != null) {
                result.templateTlsSidecarContainerSecurityContext = template.getTlsSidecarContainer().getSecurityContext();
            }
            if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
                result.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
                result.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
            }
        }
        result.setTlsSidecar(tlsSidecar);
        result.setTopicOperator(topicOperator);
        result.setUserOperator(userOperator);
        result.setDeployed(result.getTopicOperator() != null || result.getUserOperator() != null);
        String tlsSideCarImage = tlsSidecar != null ? tlsSidecar.getImage() : null;
        if (tlsSideCarImage == null) {
            KafkaClusterSpec kafkaClusterSpec = kafkaAssembly.getSpec().getKafka();
            tlsSideCarImage = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TLS_SIDECAR_ENTITY_OPERATOR_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version()));
        }
        result.tlsSidecarImage = tlsSideCarImage;
        result.templatePodLabels = Util.mergeLabelsOrAnnotations(result.templatePodLabels, DEFAULT_POD_LABELS);
    }
    return result;
}
Also used : KafkaClusterSpec(io.strimzi.api.kafka.model.KafkaClusterSpec) EntityOperatorSpec(io.strimzi.api.kafka.model.EntityOperatorSpec) EntityOperatorTemplate(io.strimzi.api.kafka.model.template.EntityOperatorTemplate) TlsSidecar(io.strimzi.api.kafka.model.TlsSidecar)

Example 2 with EntityOperatorTemplate

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

the class EntityOperator method fromCrd.

/**
 * Create a Entity Operator from given desired resource
 *
 * @param reconciliation The reconciliation
 * @param kafkaAssembly desired resource with cluster configuration containing the Entity Operator one
 * @param versions The versions.
 * @return Entity Operator instance, null if not configured in the ConfigMap
 */
public static EntityOperator fromCrd(Reconciliation reconciliation, Kafka kafkaAssembly, KafkaVersion.Lookup versions) {
    EntityOperator result = null;
    EntityOperatorSpec entityOperatorSpec = kafkaAssembly.getSpec().getEntityOperator();
    if (entityOperatorSpec != null) {
        result = new EntityOperator(reconciliation, kafkaAssembly);
        result.setOwnerReference(kafkaAssembly);
        EntityTopicOperator topicOperator = EntityTopicOperator.fromCrd(reconciliation, kafkaAssembly);
        EntityUserOperator userOperator = EntityUserOperator.fromCrd(reconciliation, kafkaAssembly);
        TlsSidecar tlsSidecar = entityOperatorSpec.getTlsSidecar();
        if (entityOperatorSpec.getTemplate() != null) {
            EntityOperatorTemplate template = entityOperatorSpec.getTemplate();
            if (template.getDeployment() != null && template.getDeployment().getMetadata() != null) {
                result.templateDeploymentLabels = template.getDeployment().getMetadata().getLabels();
                result.templateDeploymentAnnotations = template.getDeployment().getMetadata().getAnnotations();
            }
            ModelUtils.parsePodTemplate(result, template.getPod());
            if (template.getTopicOperatorContainer() != null && template.getTopicOperatorContainer().getEnv() != null) {
                topicOperator.setContainerEnvVars(template.getTopicOperatorContainer().getEnv());
            }
            if (template.getTopicOperatorContainer() != null && template.getTopicOperatorContainer().getSecurityContext() != null) {
                topicOperator.setContainerSecurityContext(template.getTopicOperatorContainer().getSecurityContext());
            }
            if (template.getUserOperatorContainer() != null && template.getUserOperatorContainer().getEnv() != null) {
                userOperator.setContainerEnvVars(template.getUserOperatorContainer().getEnv());
            }
            if (template.getUserOperatorContainer() != null && template.getUserOperatorContainer().getSecurityContext() != null) {
                userOperator.setContainerSecurityContext(template.getUserOperatorContainer().getSecurityContext());
            }
            if (template.getTlsSidecarContainer() != null && template.getTlsSidecarContainer().getEnv() != null) {
                result.templateTlsSidecarContainerEnvVars = template.getTlsSidecarContainer().getEnv();
            }
            if (template.getTlsSidecarContainer() != null && template.getTlsSidecarContainer().getSecurityContext() != null) {
                result.templateTlsSidecarContainerSecurityContext = template.getTlsSidecarContainer().getSecurityContext();
            }
            if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
                result.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
                result.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
            }
        }
        result.setTlsSidecar(tlsSidecar);
        result.setTopicOperator(topicOperator);
        result.setUserOperator(userOperator);
        result.setDeployed(result.getTopicOperator() != null || result.getUserOperator() != null);
        String tlsSideCarImage = tlsSidecar != null ? tlsSidecar.getImage() : null;
        if (tlsSideCarImage == null) {
            KafkaClusterSpec kafkaClusterSpec = kafkaAssembly.getSpec().getKafka();
            tlsSideCarImage = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TLS_SIDECAR_ENTITY_OPERATOR_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version()));
        }
        result.tlsSidecarImage = tlsSideCarImage;
        result.templatePodLabels = Util.mergeLabelsOrAnnotations(result.templatePodLabels, DEFAULT_POD_LABELS);
    }
    return result;
}
Also used : KafkaClusterSpec(io.strimzi.api.kafka.model.KafkaClusterSpec) EntityOperatorSpec(io.strimzi.api.kafka.model.EntityOperatorSpec) EntityOperatorTemplate(io.strimzi.api.kafka.model.template.EntityOperatorTemplate) TlsSidecar(io.strimzi.api.kafka.model.TlsSidecar)

Aggregations

EntityOperatorSpec (io.strimzi.api.kafka.model.EntityOperatorSpec)2 KafkaClusterSpec (io.strimzi.api.kafka.model.KafkaClusterSpec)2 TlsSidecar (io.strimzi.api.kafka.model.TlsSidecar)2 EntityOperatorTemplate (io.strimzi.api.kafka.model.template.EntityOperatorTemplate)2