Search in sources :

Example 1 with KafkaBridgeBuilder

use of io.strimzi.api.kafka.model.KafkaBridgeBuilder in project strimzi by strimzi.

the class KafkaBridgeTemplates method kafkaBridgeWithCors.

public static KafkaBridgeBuilder kafkaBridgeWithCors(String name, String clusterName, String bootstrap, int kafkaBridgeReplicas, String allowedCorsOrigin, String allowedCorsMethods) {
    KafkaBridge kafkaBridge = getKafkaBridgeFromYaml(Constants.PATH_TO_KAFKA_BRIDGE_CONFIG);
    KafkaBridgeBuilder kafkaBridgeBuilder = defaultKafkaBridge(kafkaBridge, name, clusterName, bootstrap, kafkaBridgeReplicas);
    kafkaBridgeBuilder.editSpec().editHttp().withNewCors().withAllowedOrigins(allowedCorsOrigin).withAllowedMethods(allowedCorsMethods != null ? allowedCorsMethods : "GET,POST,PUT,DELETE,OPTIONS,PATCH").endCors().endHttp().endSpec();
    return kafkaBridgeBuilder;
}
Also used : KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder)

Example 2 with KafkaBridgeBuilder

use of io.strimzi.api.kafka.model.KafkaBridgeBuilder in project strimzi by strimzi.

the class KafkaBridgeClusterTest method testCorsConfiguration.

@ParallelTest
public void testCorsConfiguration() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().editHttp().withNewCors().withAllowedOrigins("https://strimzi.io", "https://cncf.io").withAllowedMethods("GET", "POST", "PUT", "DELETE", "PATCH").endCors().endHttp().endSpec().build();
    KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment deployment = kb.generateDeployment(new HashMap<>(), true, null, null);
    Container container = deployment.getSpec().getTemplate().getSpec().getContainers().get(0);
    assertThat(AbstractModel.containerEnvVars(container).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_CORS_ENABLED), is("true"));
    assertThat(AbstractModel.containerEnvVars(container).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_CORS_ALLOWED_ORIGINS), is("https://strimzi.io,https://cncf.io"));
    assertThat(AbstractModel.containerEnvVars(container).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_CORS_ALLOWED_METHODS), is("GET,POST,PUT,DELETE,PATCH"));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 3 with KafkaBridgeBuilder

use of io.strimzi.api.kafka.model.KafkaBridgeBuilder in project strimzi by strimzi.

the class KafkaBridgeClusterTest method testJvmOptions.

@ParallelTest
public void testJvmOptions() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withJvmOptions(new JvmOptionsBuilder().withXms("128m").withXmx("256m").withXx(Collections.singletonMap("InitiatingHeapOccupancyPercent", "36")).withJavaSystemProperties(new SystemPropertyBuilder().withName("myProperty1").withValue("myValue1").build(), new SystemPropertyBuilder().withName("myProperty2").withValue("myValue2").build()).build()).endSpec().build();
    KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    EnvVar systemProps = kb.getEnvVars().stream().filter(envVar -> AbstractModel.ENV_VAR_STRIMZI_JAVA_SYSTEM_PROPERTIES.equals(envVar.getName())).findFirst().orElse(null);
    assertThat(systemProps, is(notNullValue()));
    assertThat(systemProps.getValue(), containsString("-DmyProperty1=myValue1"));
    assertThat(systemProps.getValue(), containsString("-DmyProperty2=myValue2"));
    EnvVar javaOpts = kb.getEnvVars().stream().filter(envVar -> AbstractModel.ENV_VAR_STRIMZI_JAVA_OPTS.equals(envVar.getName())).findFirst().orElse(null);
    assertThat(javaOpts, is(notNullValue()));
    assertThat(javaOpts.getValue(), containsString("-Xms128m"));
    assertThat(javaOpts.getValue(), containsString("-Xmx256m"));
    assertThat(javaOpts.getValue(), containsString("-XX:InitiatingHeapOccupancyPercent=36"));
}
Also used : SystemPropertyBuilder(io.strimzi.api.kafka.model.SystemPropertyBuilder) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) JvmOptionsBuilder(io.strimzi.api.kafka.model.JvmOptionsBuilder) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 4 with KafkaBridgeBuilder

use of io.strimzi.api.kafka.model.KafkaBridgeBuilder in project strimzi by strimzi.

the class KafkaBridgeClusterTest method testGracePeriod.

@ParallelTest
public void testGracePeriod() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewTemplate().withNewPod().withTerminationGracePeriodSeconds(123).endPod().endTemplate().endSpec().build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getTerminationGracePeriodSeconds(), is(Long.valueOf(123)));
}
Also used : KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 5 with KafkaBridgeBuilder

use of io.strimzi.api.kafka.model.KafkaBridgeBuilder in project strimzi by strimzi.

the class KafkaBridgeClusterTest method testProbeConfiguration.

@ParallelTest
public void testProbeConfiguration() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewLivenessProbe().withInitialDelaySeconds(20).withPeriodSeconds(21).withTimeoutSeconds(22).endLivenessProbe().withNewReadinessProbe().withInitialDelaySeconds(30).withPeriodSeconds(31).withTimeoutSeconds(32).endReadinessProbe().endSpec().build();
    KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kb.generateDeployment(new HashMap<String, String>(), true, null, null);
    Container cont = dep.getSpec().getTemplate().getSpec().getContainers().get(0);
    assertThat(cont.getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(20)));
    assertThat(cont.getLivenessProbe().getPeriodSeconds(), is(Integer.valueOf(21)));
    assertThat(cont.getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(22)));
    assertThat(cont.getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(30)));
    assertThat(cont.getReadinessProbe().getPeriodSeconds(), is(Integer.valueOf(31)));
    assertThat(cont.getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(32)));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

KafkaBridge (io.strimzi.api.kafka.model.KafkaBridge)66 KafkaBridgeBuilder (io.strimzi.api.kafka.model.KafkaBridgeBuilder)66 ParallelTest (io.strimzi.test.annotations.ParallelTest)62 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)54 Container (io.fabric8.kubernetes.api.model.Container)34 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)26 PodDisruptionBudget (io.fabric8.kubernetes.api.model.policy.v1.PodDisruptionBudget)22 Service (io.fabric8.kubernetes.api.model.Service)20 CertSecretSourceBuilder (io.strimzi.api.kafka.model.CertSecretSourceBuilder)20 HashMap (java.util.HashMap)20 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 LocalObjectReference (io.fabric8.kubernetes.api.model.LocalObjectReference)18 Quantity (io.fabric8.kubernetes.api.model.Quantity)18 KafkaClientAuthenticationOAuthBuilder (io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationOAuthBuilder)18 KafkaClientAuthenticationTlsBuilder (io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder)18 Affinity (io.fabric8.kubernetes.api.model.Affinity)16 AffinityBuilder (io.fabric8.kubernetes.api.model.AffinityBuilder)16 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)16 LabelSelectorBuilder (io.fabric8.kubernetes.api.model.LabelSelectorBuilder)16 NodeSelectorTermBuilder (io.fabric8.kubernetes.api.model.NodeSelectorTermBuilder)16