Search in sources :

Example 36 with CruiseControlSpec

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

the class CruiseControlTest method testTlsSidecarContainerSecurityContext.

@ParallelTest
public void testTlsSidecarContainerSecurityContext() {
    SecurityContext securityContext = new SecurityContextBuilder().withPrivileged(false).withReadOnlyRootFilesystem(false).withAllowPrivilegeEscalation(false).withRunAsNonRoot(true).withNewCapabilities().addNewDrop("ALL").endCapabilities().build();
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withConfig(ccConfig).withNewTemplate().withNewTlsSidecarContainer().withSecurityContext(securityContext).endTlsSidecarContainer().endTemplate().build();
    Kafka resource = createKafka(cruiseControlSpec);
    CruiseControl cc = createCruiseControl(resource);
    Deployment dep = cc.generateDeployment(true, null, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getContainers(), hasItem(allOf(hasProperty("name", equalTo(CruiseControl.TLS_SIDECAR_NAME)), hasProperty("securityContext", equalTo(securityContext)))));
}
Also used : SecurityContextBuilder(io.fabric8.kubernetes.api.model.SecurityContextBuilder) PodSecurityContextBuilder(io.fabric8.kubernetes.api.model.PodSecurityContextBuilder) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) SecurityContext(io.fabric8.kubernetes.api.model.SecurityContext) Kafka(io.strimzi.api.kafka.model.Kafka) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 37 with CruiseControlSpec

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

the class CruiseControlTest method testProbeConfiguration.

@ParallelTest
public void testProbeConfiguration() {
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withNewLivenessProbe().withInitialDelaySeconds(healthDelay).withTimeoutSeconds(healthTimeout).endLivenessProbe().withNewReadinessProbe().withInitialDelaySeconds(healthDelay).withTimeoutSeconds(healthTimeout).endReadinessProbe().build();
    Kafka resource = createKafka(cruiseControlSpec);
    CruiseControl cc = createCruiseControl(resource);
    Deployment dep = cc.generateDeployment(true, null, null, null);
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    // checks on the main Cruise Control container
    Container ccContainer = containers.stream().filter(container -> ccImage.equals(container.getImage())).findFirst().orElseThrow();
    assertThat(ccContainer.getImage(), is(cc.image));
    assertThat(ccContainer.getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay)));
    assertThat(ccContainer.getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout)));
    assertThat(ccContainer.getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay)));
    assertThat(ccContainer.getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout)));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Kafka(io.strimzi.api.kafka.model.Kafka) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 38 with CruiseControlSpec

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

the class CruiseControlTest method testJvmOptions.

@ParallelTest
public void testJvmOptions() {
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withNewJvmOptions().withXms("128m").withXmx("256m").withXx(Map.of("InitiatingHeapOccupancyPercent", "36")).withJavaSystemProperties(new SystemPropertyBuilder().withName("myProperty").withValue("myValue").build(), new SystemPropertyBuilder().withName("myProperty2").withValue("myValue2").build()).endJvmOptions().build();
    Kafka resource = createKafka(cruiseControlSpec);
    CruiseControl cc = CruiseControl.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS, kafkaStorage);
    EnvVar systemProps = cc.getEnvVars().stream().filter(var -> AbstractModel.ENV_VAR_STRIMZI_JAVA_SYSTEM_PROPERTIES.equals(var.getName())).findFirst().orElse(null);
    assertThat(systemProps, is(notNullValue()));
    assertThat(systemProps.getValue(), containsString("-DmyProperty=myValue"));
    assertThat(systemProps.getValue(), containsString("-DmyProperty2=myValue2"));
    EnvVar heapOpts = cc.getEnvVars().stream().filter(var -> AbstractModel.ENV_VAR_KAFKA_HEAP_OPTS.equals(var.getName())).findFirst().orElse(null);
    assertThat(heapOpts, is(notNullValue()));
    assertThat(heapOpts.getValue(), containsString("-Xms128m"));
    assertThat(heapOpts.getValue(), containsString("-Xmx256m"));
    EnvVar perfOptions = cc.getEnvVars().stream().filter(var -> AbstractModel.ENV_VAR_KAFKA_JVM_PERFORMANCE_OPTS.equals(var.getName())).findFirst().orElse(null);
    assertThat(perfOptions, is(notNullValue()));
    assertThat(perfOptions.getValue(), containsString("-XX:InitiatingHeapOccupancyPercent=36"));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) SystemPropertyBuilder(io.strimzi.api.kafka.model.SystemPropertyBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

CruiseControlSpec (io.strimzi.api.kafka.model.CruiseControlSpec)38 CruiseControlSpecBuilder (io.strimzi.api.kafka.model.CruiseControlSpecBuilder)34 Kafka (io.strimzi.api.kafka.model.Kafka)30 ParallelTest (io.strimzi.test.annotations.ParallelTest)30 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)16 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)16 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 Container (io.fabric8.kubernetes.api.model.Container)8 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)8 ContainerEnvVar (io.strimzi.api.kafka.model.ContainerEnvVar)8 PodSecurityContextBuilder (io.fabric8.kubernetes.api.model.PodSecurityContextBuilder)6 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)4 SecurityContext (io.fabric8.kubernetes.api.model.SecurityContext)4 SecurityContextBuilder (io.fabric8.kubernetes.api.model.SecurityContextBuilder)4 Capacity (io.strimzi.operator.cluster.model.cruisecontrol.Capacity)4 ParallelNamespaceTest (io.strimzi.systemtest.annotations.ParallelNamespaceTest)4 Affinity (io.fabric8.kubernetes.api.model.Affinity)2 AffinityBuilder (io.fabric8.kubernetes.api.model.AffinityBuilder)2 ConfigMapKeySelectorBuilder (io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder)2 HostAlias (io.fabric8.kubernetes.api.model.HostAlias)2