Search in sources :

Example 41 with EphemeralStorage

use of io.strimzi.api.kafka.model.storage.EphemeralStorage in project strimzi-kafka-operator by strimzi.

the class ZooKeeperSpecCheckerTest method checkZookeeperStorage.

@Test
public void checkZookeeperStorage() {
    Map<String, Object> kafkaOptions = new HashMap<>();
    kafkaOptions.put(KafkaConfiguration.DEFAULT_REPLICATION_FACTOR, 3);
    kafkaOptions.put(KafkaConfiguration.MIN_INSYNC_REPLICAS, 2);
    Kafka kafka = new KafkaBuilder(ResourceUtils.createKafka(NAMESPACE, NAME, 3, IMAGE, HEALTH_DELAY, HEALTH_TIMEOUT, null, kafkaOptions, emptyMap(), new EphemeralStorage(), new EphemeralStorage(), null, null, null, null)).editSpec().editZookeeper().withReplicas(1).endZookeeper().endSpec().build();
    ZooKeeperSpecChecker checker = generateChecker(kafka);
    List<Condition> warnings = checker.run();
    assertThat(warnings, hasSize(1));
    Condition warning = warnings.get(0);
    assertThat(warning.getReason(), is("ZooKeeperStorage"));
    assertThat(warning.getStatus(), is("True"));
    assertThat(warning.getMessage(), is("A ZooKeeper cluster with a single replica and ephemeral storage will be in a defective state after any restart or rolling update. It is recommended that a minimum of three replicas are used."));
}
Also used : Condition(io.strimzi.api.kafka.model.status.Condition) HashMap(java.util.HashMap) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) Test(org.junit.jupiter.api.Test)

Example 42 with EphemeralStorage

use of io.strimzi.api.kafka.model.storage.EphemeralStorage in project strimzi by strimzi.

the class Capacity method generateJbodDiskCapacity.

/**
 * Generate JBOD disk capacity configuration for a broker using the supplied storage configuration
 *
 * @param storage Storage configuration for Kafka cluster
 * @param brokerId Id of the broker
 * @return Disk capacity configuration value for broker brokerId
 */
private static DiskCapacity generateJbodDiskCapacity(Storage storage, int brokerId) {
    DiskCapacity disks = new DiskCapacity();
    String size = "";
    for (SingleVolumeStorage volume : ((JbodStorage) storage).getVolumes()) {
        String name = VolumeUtils.createVolumePrefix(volume.getId(), true);
        String path = AbstractModel.KAFKA_MOUNT_PATH + "/" + name + "/" + AbstractModel.KAFKA_LOG_DIR + brokerId;
        if (volume instanceof PersistentClaimStorage) {
            size = ((PersistentClaimStorage) volume).getSize();
        } else if (volume instanceof EphemeralStorage) {
            size = ((EphemeralStorage) volume).getSizeLimit();
        }
        disks.add(path, String.valueOf(getSizeInMiB(size)));
    }
    return disks;
}
Also used : SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) JbodStorage(io.strimzi.api.kafka.model.storage.JbodStorage)

Example 43 with EphemeralStorage

use of io.strimzi.api.kafka.model.storage.EphemeralStorage in project strimzi by strimzi.

the class VolumeUtils method createPodSetVolumes.

/**
 * Generates the list of data volumes as used in PodSets and individual Pods. This includes both ephemeral and
 * persistent data volumes. This method calls itself recursively to create the volumes from a JBOD storage array.
 * When it does so, it sets the {@code jbod} parameter to {@code true}. When called from outside, it should be set
 * to {@code false}.
 *
 * @param podName   Name of the pod used to name the volumes
 * @param storage   Storage configuration
 * @param jbod      Indicates that the storage is part of JBOD storage and volume names are created accordingly
 *
 * @return          List of data volumes to be included in the StrimziPodSet pod
 */
public static List<Volume> createPodSetVolumes(String podName, Storage storage, boolean jbod) {
    List<Volume> volumes = new ArrayList<>();
    if (storage != null) {
        if (storage instanceof JbodStorage) {
            for (SingleVolumeStorage volume : ((JbodStorage) storage).getVolumes()) {
                // it's called recursively for setting the information from the current volume
                volumes.addAll(createPodSetVolumes(podName, volume, true));
            }
        } else if (storage instanceof EphemeralStorage) {
            EphemeralStorage ephemeralStorage = (EphemeralStorage) storage;
            volumes.add(createEmptyDirVolume(createVolumePrefix(ephemeralStorage.getId(), jbod), ephemeralStorage.getSizeLimit(), null));
        } else if (storage instanceof PersistentClaimStorage) {
            String name = createVolumePrefix(((PersistentClaimStorage) storage).getId(), jbod);
            volumes.add(createPvcVolume(name, name + "-" + podName));
        }
    }
    return volumes;
}
Also used : Volume(io.fabric8.kubernetes.api.model.Volume) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) ArrayList(java.util.ArrayList) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) JbodStorage(io.strimzi.api.kafka.model.storage.JbodStorage)

Example 44 with EphemeralStorage

use of io.strimzi.api.kafka.model.storage.EphemeralStorage in project strimzi by strimzi.

the class KafkaClusterOAuthValidationTest method testOAuthAuthzWithoutAuthn.

@ParallelTest
public void testOAuthAuthzWithoutAuthn() {
    assertThrows(InvalidResourceException.class, () -> {
        List<GenericKafkaListener> listeners = asList(new GenericKafkaListenerBuilder().withName("listener1").withPort(9900).withType(KafkaListenerType.INTERNAL).withAuth(new KafkaListenerAuthenticationScramSha512Builder().build()).build());
        Kafka kafkaAssembly = new KafkaBuilder().withNewMetadata().withName("my-cluster").withNamespace("my-namespace").endMetadata().withNewSpec().withNewKafka().withReplicas(3).withStorage(new EphemeralStorage()).withListeners(listeners).withAuthorization(new KafkaAuthorizationKeycloakBuilder().withTokenEndpointUri("http://token-endpoint").withClientId("my-client-id").withDelegateToKafkaAcls(true).withGrantsRefreshPeriodSeconds(60).withGrantsRefreshPoolSize(5).withSuperUsers("alice", "CN=alice").build()).endKafka().withNewZookeeper().withReplicas(3).withStorage(new EphemeralStorage()).endZookeeper().endSpec().build();
        KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS);
    });
}
Also used : GenericKafkaListener(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) KafkaAuthorizationKeycloakBuilder(io.strimzi.api.kafka.model.KafkaAuthorizationKeycloakBuilder) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) KafkaListenerAuthenticationScramSha512Builder(io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationScramSha512Builder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 45 with EphemeralStorage

use of io.strimzi.api.kafka.model.storage.EphemeralStorage in project strimzi by strimzi.

the class ZooKeeperSpecCheckerTest method checkZookeeperReplicas.

@Test
public void checkZookeeperReplicas() {
    Map<String, Object> kafkaOptions = new HashMap<>();
    kafkaOptions.put(KafkaConfiguration.DEFAULT_REPLICATION_FACTOR, 2);
    kafkaOptions.put(KafkaConfiguration.MIN_INSYNC_REPLICAS, 1);
    Kafka kafka = ResourceUtils.createKafka(NAMESPACE, NAME, 2, IMAGE, HEALTH_DELAY, HEALTH_TIMEOUT, null, kafkaOptions, emptyMap(), new EphemeralStorage(), new EphemeralStorage(), null, null, null, null);
    ZooKeeperSpecChecker checker = generateChecker(kafka);
    List<Condition> warnings = checker.run();
    assertThat(warnings, hasSize(1));
    Condition warning = warnings.get(0);
    assertThat(warning.getReason(), is("ZooKeeperReplicas"));
    assertThat(warning.getStatus(), is("True"));
    assertThat(warning.getMessage(), is("Running ZooKeeper with two nodes is not advisable as both replicas will be needed to avoid downtime. It is recommended that a minimum of three replicas are used."));
}
Also used : Condition(io.strimzi.api.kafka.model.status.Condition) HashMap(java.util.HashMap) Kafka(io.strimzi.api.kafka.model.Kafka) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) Test(org.junit.jupiter.api.Test)

Aggregations

EphemeralStorage (io.strimzi.api.kafka.model.storage.EphemeralStorage)64 Kafka (io.strimzi.api.kafka.model.Kafka)52 Test (org.junit.jupiter.api.Test)46 HashMap (java.util.HashMap)44 Condition (io.strimzi.api.kafka.model.status.Condition)42 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)24 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)16 SingleVolumeStorage (io.strimzi.api.kafka.model.storage.SingleVolumeStorage)12 PersistentClaimStorage (io.strimzi.api.kafka.model.storage.PersistentClaimStorage)10 ArrayList (java.util.ArrayList)8 Map (java.util.Map)8 GenericKafkaListener (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener)6 KafkaListenerType (io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType)6 EphemeralStorageBuilder (io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder)6 JbodStorageBuilder (io.strimzi.api.kafka.model.storage.JbodStorageBuilder)6 PersistentClaimStorageBuilder (io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder)6 KafkaVersionTestUtils (io.strimzi.operator.cluster.KafkaVersionTestUtils)6 ResourceUtils (io.strimzi.operator.cluster.ResourceUtils)6 KafkaVersion (io.strimzi.operator.cluster.model.KafkaVersion)6 Reconciliation (io.strimzi.operator.common.Reconciliation)6