Search in sources :

Example 11 with KafkaBridge

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

the class KafkaBridgeClusterTest method testGenerateDeploymentWithTls.

@ParallelTest
public void testGenerateDeploymentWithTls() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret").withCertificate("cert.crt").build()).addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret").withCertificate("new-cert.crt").build()).addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-another-secret").withCertificate("another-cert.crt").build()).endTls().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(2).getName(), is("my-secret"));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(3).getName(), is("my-another-secret"));
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    assertThat(containers.get(0).getVolumeMounts().get(2).getMountPath(), is(KafkaBridgeCluster.TLS_CERTS_BASE_VOLUME_MOUNT + "my-secret"));
    assertThat(containers.get(0).getVolumeMounts().get(3).getMountPath(), is(KafkaBridgeCluster.TLS_CERTS_BASE_VOLUME_MOUNT + "my-another-secret"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_TRUSTED_CERTS), is("my-secret/cert.crt;my-secret/new-cert.crt;my-another-secret/another-cert.crt"));
    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) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 12 with KafkaBridge

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

the class KafkaBridgeClusterTest method testGenerateDeploymentWithScramSha512Auth.

@ParallelTest
public void testGenerateDeploymentWithScramSha512Auth() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewKafkaClientAuthenticationScramSha512().withUsername("user1").withNewPasswordSecret().withSecretName("user1-secret").withPassword("password").endPasswordSecret().endKafkaClientAuthenticationScramSha512().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(2).getName(), is("user1-secret"));
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    assertThat(containers.get(0).getVolumeMounts().get(2).getMountPath(), is(KafkaBridgeCluster.PASSWORD_VOLUME_MOUNT + "user1-secret"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_SASL_PASSWORD_FILE), is("user1-secret/password"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_SASL_USERNAME), is("user1"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_SASL_MECHANISM), is("scram-sha-512"));
}
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 13 with KafkaBridge

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

the class KafkaBridgeClusterTest method testImagePullSecrets.

@ParallelTest
public void testImagePullSecrets() {
    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(secret1, secret2).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().getImagePullSecrets().size(), is(2));
    assertThat(dep.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret1), is(true));
    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 14 with KafkaBridge

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

the class KafkaBridgeClusterTest method testSecurityContext.

@ParallelTest
public void testSecurityContext() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewTemplate().withNewPod().withSecurityContext(new PodSecurityContextBuilder().withFsGroup(123L).withRunAsGroup(456L).withRunAsUser(789L).build()).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().getSecurityContext(), is(notNullValue()));
    assertThat(dep.getSpec().getTemplate().getSpec().getSecurityContext().getFsGroup(), is(Long.valueOf(123)));
    assertThat(dep.getSpec().getTemplate().getSpec().getSecurityContext().getRunAsGroup(), is(Long.valueOf(456)));
    assertThat(dep.getSpec().getTemplate().getSpec().getSecurityContext().getRunAsUser(), is(Long.valueOf(789)));
}
Also used : PodSecurityContextBuilder(io.fabric8.kubernetes.api.model.PodSecurityContextBuilder) 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 15 with KafkaBridge

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

the class KafkaBridgeClusterTest method testDefaultSecurityContext.

@ParallelTest
public void testDefaultSecurityContext() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getSecurityContext(), is(nullValue()));
}
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)

Aggregations

KafkaBridge (io.strimzi.api.kafka.model.KafkaBridge)88 KafkaBridgeBuilder (io.strimzi.api.kafka.model.KafkaBridgeBuilder)82 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)70 ParallelTest (io.strimzi.test.annotations.ParallelTest)62 Service (io.fabric8.kubernetes.api.model.Service)38 PodDisruptionBudget (io.fabric8.kubernetes.api.model.policy.v1.PodDisruptionBudget)38 HashMap (java.util.HashMap)38 KafkaBridgeResources (io.strimzi.api.kafka.model.KafkaBridgeResources)36 Collections (java.util.Collections)36 List (java.util.List)36 Container (io.fabric8.kubernetes.api.model.Container)34 Reconciliation (io.strimzi.operator.common.Reconciliation)34 Labels (io.strimzi.operator.common.model.Labels)34 Map (java.util.Map)34 CoreMatchers.is (org.hamcrest.CoreMatchers.is)34 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)34 KafkaBridgeHttpConfig (io.strimzi.api.kafka.model.KafkaBridgeHttpConfig)32 KafkaVersionTestUtils (io.strimzi.operator.cluster.KafkaVersionTestUtils)32 ResourceUtils (io.strimzi.operator.cluster.ResourceUtils)32 TestUtils (io.strimzi.test.TestUtils)32