Search in sources :

Example 1 with Capacity

use of io.strimzi.operator.cluster.model.cruisecontrol.Capacity in project strimzi-kafka-operator by strimzi.

the class CruiseControlTest method testBrokerCapacities.

@ParallelTest
public void testBrokerCapacities() {
    // Test user defined capacities
    BrokerCapacity userDefinedBrokerCapacity = new BrokerCapacity();
    userDefinedBrokerCapacity.setInboundNetwork("50000KB/s");
    userDefinedBrokerCapacity.setOutboundNetwork("50000KB/s");
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withBrokerCapacity(userDefinedBrokerCapacity).build();
    Kafka resource = createKafka(cruiseControlSpec);
    Capacity capacity = new Capacity(resource.getSpec(), kafkaStorage);
    assertThat(getCapacityConfigurationFromEnvVar(resource, ENV_VAR_CRUISE_CONTROL_CAPACITY_CONFIGURATION), is(capacity.generateCapacityConfig()));
    // Test generated disk capacity
    JbodStorage jbodStorage = new JbodStorage();
    List<SingleVolumeStorage> volumes = new ArrayList<>();
    PersistentClaimStorage p1 = new PersistentClaimStorage();
    p1.setId(0);
    p1.setSize("50Gi");
    volumes.add(p1);
    PersistentClaimStorage p2 = new PersistentClaimStorage();
    p2.setId(1);
    volumes.add(p2);
    jbodStorage.setVolumes(volumes);
    resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().editKafka().withVersion(version).withStorage(jbodStorage).endKafka().withCruiseControl(cruiseControlSpec).endSpec().build();
    capacity = new Capacity(resource.getSpec(), jbodStorage);
    assertThat(getCapacityConfigurationFromEnvVar(resource, ENV_VAR_CRUISE_CONTROL_CAPACITY_CONFIGURATION), is(capacity.generateCapacityConfig()));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) BrokerCapacity(io.strimzi.api.kafka.model.balancing.BrokerCapacity) Capacity(io.strimzi.operator.cluster.model.cruisecontrol.Capacity) BrokerCapacity(io.strimzi.api.kafka.model.balancing.BrokerCapacity) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) Kafka(io.strimzi.api.kafka.model.Kafka) ArrayList(java.util.ArrayList) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) JbodStorage(io.strimzi.api.kafka.model.storage.JbodStorage) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 2 with Capacity

use of io.strimzi.operator.cluster.model.cruisecontrol.Capacity in project strimzi by strimzi.

the class CruiseControlTest method testBrokerCapacities.

@ParallelTest
public void testBrokerCapacities() {
    // Test user defined capacities
    BrokerCapacity userDefinedBrokerCapacity = new BrokerCapacity();
    userDefinedBrokerCapacity.setInboundNetwork("50000KB/s");
    userDefinedBrokerCapacity.setOutboundNetwork("50000KB/s");
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withBrokerCapacity(userDefinedBrokerCapacity).build();
    Kafka resource = createKafka(cruiseControlSpec);
    Capacity capacity = new Capacity(resource.getSpec(), kafkaStorage);
    assertThat(getCapacityConfigurationFromEnvVar(resource, ENV_VAR_CRUISE_CONTROL_CAPACITY_CONFIGURATION), is(capacity.generateCapacityConfig()));
    // Test generated disk capacity
    JbodStorage jbodStorage = new JbodStorage();
    List<SingleVolumeStorage> volumes = new ArrayList<>();
    PersistentClaimStorage p1 = new PersistentClaimStorage();
    p1.setId(0);
    p1.setSize("50Gi");
    volumes.add(p1);
    PersistentClaimStorage p2 = new PersistentClaimStorage();
    p2.setId(1);
    volumes.add(p2);
    jbodStorage.setVolumes(volumes);
    resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().editKafka().withVersion(version).withStorage(jbodStorage).endKafka().withCruiseControl(cruiseControlSpec).endSpec().build();
    capacity = new Capacity(resource.getSpec(), jbodStorage);
    assertThat(getCapacityConfigurationFromEnvVar(resource, ENV_VAR_CRUISE_CONTROL_CAPACITY_CONFIGURATION), is(capacity.generateCapacityConfig()));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) BrokerCapacity(io.strimzi.api.kafka.model.balancing.BrokerCapacity) Capacity(io.strimzi.operator.cluster.model.cruisecontrol.Capacity) BrokerCapacity(io.strimzi.api.kafka.model.balancing.BrokerCapacity) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) Kafka(io.strimzi.api.kafka.model.Kafka) ArrayList(java.util.ArrayList) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) JbodStorage(io.strimzi.api.kafka.model.storage.JbodStorage) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 3 with Capacity

use of io.strimzi.operator.cluster.model.cruisecontrol.Capacity in project strimzi by strimzi.

the class CruiseControl method fromCrd.

public static CruiseControl fromCrd(Reconciliation reconciliation, Kafka kafkaAssembly, KafkaVersion.Lookup versions, Storage storage) {
    CruiseControl cruiseControl = null;
    CruiseControlSpec spec = kafkaAssembly.getSpec().getCruiseControl();
    KafkaClusterSpec kafkaClusterSpec = kafkaAssembly.getSpec().getKafka();
    if (spec != null) {
        cruiseControl = new CruiseControl(reconciliation, kafkaAssembly);
        cruiseControl.isDeployed = true;
        cruiseControl.setReplicas(DEFAULT_REPLICAS);
        String image = spec.getImage();
        if (image == null) {
            image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_CRUISE_CONTROL_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version()));
        }
        cruiseControl.setImage(image);
        TlsSidecar tlsSidecar = spec.getTlsSidecar();
        if (tlsSidecar == null) {
            tlsSidecar = new TlsSidecar();
        }
        String tlsSideCarImage = tlsSidecar.getImage();
        if (tlsSideCarImage == null) {
            tlsSideCarImage = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TLS_SIDECAR_CRUISE_CONTROL_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version()));
        }
        tlsSidecar.setImage(tlsSideCarImage);
        cruiseControl.tlsSidecarImage = tlsSideCarImage;
        cruiseControl.setTlsSidecar(tlsSidecar);
        cruiseControl = cruiseControl.updateConfiguration(spec);
        CruiseControlConfiguration ccConfiguration = (CruiseControlConfiguration) cruiseControl.getConfiguration();
        cruiseControl.sslEnabled = isApiSslEnabled(ccConfiguration);
        cruiseControl.authEnabled = isApiAuthEnabled(ccConfiguration);
        KafkaConfiguration configuration = new KafkaConfiguration(reconciliation, kafkaClusterSpec.getConfig().entrySet());
        if (configuration.getConfigOption(MIN_INSYNC_REPLICAS) != null) {
            cruiseControl.minInsyncReplicas = configuration.getConfigOption(MIN_INSYNC_REPLICAS);
        }
        // To avoid illegal storage configurations provided by the user,
        // we rely on the storage configuration provided by the KafkaAssemblyOperator
        cruiseControl.capacity = new Capacity(kafkaAssembly.getSpec(), storage);
        // Parse different types of metrics configurations
        ModelUtils.parseMetrics(cruiseControl, spec);
        if (spec.getReadinessProbe() != null) {
            cruiseControl.setReadinessProbe(spec.getReadinessProbe());
        }
        if (spec.getLivenessProbe() != null) {
            cruiseControl.setLivenessProbe(spec.getLivenessProbe());
        }
        Logging logging = spec.getLogging();
        cruiseControl.setLogging(logging == null ? new InlineLogging() : logging);
        cruiseControl.setGcLoggingEnabled(spec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : spec.getJvmOptions().isGcLoggingEnabled());
        cruiseControl.setJvmOptions(spec.getJvmOptions());
        if (spec.getJvmOptions() != null) {
            cruiseControl.setJavaSystemProperties(spec.getJvmOptions().getJavaSystemProperties());
        }
        cruiseControl.setResources(spec.getResources());
        cruiseControl.setOwnerReference(kafkaAssembly);
        cruiseControl = updateTemplate(spec, cruiseControl);
        cruiseControl.templatePodLabels = Util.mergeLabelsOrAnnotations(cruiseControl.templatePodLabels, DEFAULT_POD_LABELS);
    }
    return cruiseControl;
}
Also used : KafkaClusterSpec(io.strimzi.api.kafka.model.KafkaClusterSpec) InlineLogging(io.strimzi.api.kafka.model.InlineLogging) Logging(io.strimzi.api.kafka.model.Logging) TlsSidecar(io.strimzi.api.kafka.model.TlsSidecar) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Capacity(io.strimzi.operator.cluster.model.cruisecontrol.Capacity) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) InlineLogging(io.strimzi.api.kafka.model.InlineLogging)

Example 4 with Capacity

use of io.strimzi.operator.cluster.model.cruisecontrol.Capacity in project strimzi-kafka-operator by strimzi.

the class CruiseControl method fromCrd.

public static CruiseControl fromCrd(Reconciliation reconciliation, Kafka kafkaAssembly, KafkaVersion.Lookup versions, Storage storage) {
    CruiseControl cruiseControl = null;
    CruiseControlSpec spec = kafkaAssembly.getSpec().getCruiseControl();
    KafkaClusterSpec kafkaClusterSpec = kafkaAssembly.getSpec().getKafka();
    if (spec != null) {
        cruiseControl = new CruiseControl(reconciliation, kafkaAssembly);
        cruiseControl.isDeployed = true;
        cruiseControl.setReplicas(DEFAULT_REPLICAS);
        String image = spec.getImage();
        if (image == null) {
            image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_CRUISE_CONTROL_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version()));
        }
        cruiseControl.setImage(image);
        TlsSidecar tlsSidecar = spec.getTlsSidecar();
        if (tlsSidecar == null) {
            tlsSidecar = new TlsSidecar();
        }
        String tlsSideCarImage = tlsSidecar.getImage();
        if (tlsSideCarImage == null) {
            tlsSideCarImage = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TLS_SIDECAR_CRUISE_CONTROL_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version()));
        }
        tlsSidecar.setImage(tlsSideCarImage);
        cruiseControl.tlsSidecarImage = tlsSideCarImage;
        cruiseControl.setTlsSidecar(tlsSidecar);
        cruiseControl = cruiseControl.updateConfiguration(spec);
        CruiseControlConfiguration ccConfiguration = (CruiseControlConfiguration) cruiseControl.getConfiguration();
        cruiseControl.sslEnabled = isApiSslEnabled(ccConfiguration);
        cruiseControl.authEnabled = isApiAuthEnabled(ccConfiguration);
        KafkaConfiguration configuration = new KafkaConfiguration(reconciliation, kafkaClusterSpec.getConfig().entrySet());
        if (configuration.getConfigOption(MIN_INSYNC_REPLICAS) != null) {
            cruiseControl.minInsyncReplicas = configuration.getConfigOption(MIN_INSYNC_REPLICAS);
        }
        // To avoid illegal storage configurations provided by the user,
        // we rely on the storage configuration provided by the KafkaAssemblyOperator
        cruiseControl.capacity = new Capacity(kafkaAssembly.getSpec(), storage);
        // Parse different types of metrics configurations
        ModelUtils.parseMetrics(cruiseControl, spec);
        if (spec.getReadinessProbe() != null) {
            cruiseControl.setReadinessProbe(spec.getReadinessProbe());
        }
        if (spec.getLivenessProbe() != null) {
            cruiseControl.setLivenessProbe(spec.getLivenessProbe());
        }
        Logging logging = spec.getLogging();
        cruiseControl.setLogging(logging == null ? new InlineLogging() : logging);
        cruiseControl.setGcLoggingEnabled(spec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : spec.getJvmOptions().isGcLoggingEnabled());
        cruiseControl.setJvmOptions(spec.getJvmOptions());
        if (spec.getJvmOptions() != null) {
            cruiseControl.setJavaSystemProperties(spec.getJvmOptions().getJavaSystemProperties());
        }
        cruiseControl.setResources(spec.getResources());
        cruiseControl.setOwnerReference(kafkaAssembly);
        cruiseControl = updateTemplate(spec, cruiseControl);
        cruiseControl.templatePodLabels = Util.mergeLabelsOrAnnotations(cruiseControl.templatePodLabels, DEFAULT_POD_LABELS);
    }
    return cruiseControl;
}
Also used : KafkaClusterSpec(io.strimzi.api.kafka.model.KafkaClusterSpec) InlineLogging(io.strimzi.api.kafka.model.InlineLogging) Logging(io.strimzi.api.kafka.model.Logging) TlsSidecar(io.strimzi.api.kafka.model.TlsSidecar) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Capacity(io.strimzi.operator.cluster.model.cruisecontrol.Capacity) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) InlineLogging(io.strimzi.api.kafka.model.InlineLogging)

Aggregations

CruiseControlSpec (io.strimzi.api.kafka.model.CruiseControlSpec)4 Capacity (io.strimzi.operator.cluster.model.cruisecontrol.Capacity)4 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)2 CruiseControlSpecBuilder (io.strimzi.api.kafka.model.CruiseControlSpecBuilder)2 InlineLogging (io.strimzi.api.kafka.model.InlineLogging)2 Kafka (io.strimzi.api.kafka.model.Kafka)2 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)2 KafkaClusterSpec (io.strimzi.api.kafka.model.KafkaClusterSpec)2 Logging (io.strimzi.api.kafka.model.Logging)2 TlsSidecar (io.strimzi.api.kafka.model.TlsSidecar)2 BrokerCapacity (io.strimzi.api.kafka.model.balancing.BrokerCapacity)2 JbodStorage (io.strimzi.api.kafka.model.storage.JbodStorage)2 PersistentClaimStorage (io.strimzi.api.kafka.model.storage.PersistentClaimStorage)2 SingleVolumeStorage (io.strimzi.api.kafka.model.storage.SingleVolumeStorage)2 ParallelTest (io.strimzi.test.annotations.ParallelTest)2 ArrayList (java.util.ArrayList)2