Search in sources :

Example 46 with KafkaBridgeBuilder

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

the class KafkaBridgeClusterTest method testGenerateDeploymentWithTlsSameSecret.

@ParallelTest
public void testGenerateDeploymentWithTlsSameSecret() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("my-secret").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endSpec().build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, null);
    // 2 = 1 volume from logging/metrics + just 1 from above certs Secret
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().size(), is(3));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(2).getName(), is("my-secret"));
}
Also used : CertSecretSourceBuilder(io.strimzi.api.kafka.model.CertSecretSourceBuilder) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) KafkaClientAuthenticationTlsBuilder(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 47 with KafkaBridgeBuilder

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

the class KafkaBridgeClusterTest method testDifferentHttpPort.

@ParallelTest
public void testDifferentHttpPort() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewHttp(1874).endSpec().build();
    KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    // Check ports in container
    Deployment dep = kb.generateDeployment(emptyMap(), true, null, null);
    Container cont = dep.getSpec().getTemplate().getSpec().getContainers().get(0);
    assertThat(cont.getLivenessProbe().getHttpGet().getPort(), is(new IntOrString(KafkaBridgeCluster.REST_API_PORT_NAME)));
    assertThat(cont.getReadinessProbe().getHttpGet().getPort(), is(new IntOrString(KafkaBridgeCluster.REST_API_PORT_NAME)));
    assertThat(cont.getPorts().get(0).getContainerPort(), is(Integer.valueOf(1874)));
    assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getName(), is(KafkaBridgeCluster.REST_API_PORT_NAME));
    assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getProtocol(), is("TCP"));
    // Check ports on Service
    Service svc = kb.generateService();
    assertThat(svc.getSpec().getType(), is("ClusterIP"));
    assertThat(svc.getMetadata().getLabels(), is(expectedServiceLabels(kb.getName())));
    assertThat(svc.getSpec().getSelector(), is(expectedSelectorLabels()));
    assertThat(svc.getSpec().getPorts().get(0).getPort(), is(Integer.valueOf(1874)));
    assertThat(svc.getSpec().getPorts().get(0).getName(), is(KafkaBridgeCluster.REST_API_PORT_NAME));
    assertThat(svc.getSpec().getPorts().get(0).getProtocol(), is("TCP"));
    assertThat(svc.getMetadata().getAnnotations(), is(kbc.getDiscoveryAnnotation(1874)));
    checkOwnerReference(kbc.createOwnerReference(), svc);
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) Service(io.fabric8.kubernetes.api.model.Service) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 48 with KafkaBridgeBuilder

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

the class KafkaBridgeClusterTest method testImagePullSecretsBoth.

@ParallelTest
public void testImagePullSecretsBoth() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewTemplate().withNewPod().withImagePullSecrets(secret2).endPod().endTemplate().endSpec().build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, singletonList(secret1));
    assertThat(dep.getSpec().getTemplate().getSpec().getImagePullSecrets().size(), is(1));
    assertThat(dep.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret1), is(false));
    assertThat(dep.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret2), is(true));
}
Also used : KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) LocalObjectReference(io.fabric8.kubernetes.api.model.LocalObjectReference) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 49 with KafkaBridgeBuilder

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

the class KafkaBridgeClusterTest method testTracingConfiguration.

@ParallelTest
public void testTracingConfiguration() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withJaegerTracing(new JaegerTracing()).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_STRIMZI_TRACING), is("jaeger"));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) JaegerTracing(io.strimzi.api.kafka.model.tracing.JaegerTracing) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 50 with KafkaBridgeBuilder

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

the class KafkaBridgeClusterTest method testGenerateDeploymentWithTlsAuth.

@ParallelTest
public void testGenerateDeploymentWithTlsAuth() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("user-secret").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endSpec().build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(3).getName(), is("user-secret"));
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    assertThat(containers.get(0).getVolumeMounts().get(3).getMountPath(), is(KafkaBridgeCluster.TLS_CERTS_BASE_VOLUME_MOUNT + "user-secret"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_TLS_AUTH_CERT), is("user-secret/user.crt"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_TLS_AUTH_KEY), is("user-secret/user.key"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_TLS), is("true"));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) CertSecretSourceBuilder(io.strimzi.api.kafka.model.CertSecretSourceBuilder) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) KafkaClientAuthenticationTlsBuilder(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) 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