Search in sources :

Example 1 with KafkaClientAuthenticationTlsBuilder

use of io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder in project strimzi by strimzi.

the class KafkaMirrorMakerClusterTest method testGenerateDeploymentWithTlsAuth.

@ParallelTest
public void testGenerateDeploymentWithTlsAuth() {
    KafkaMirrorMaker resource = new KafkaMirrorMakerBuilder(this.resource).editSpec().editOrNewConsumer().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret-c").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("user-secret-c").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endConsumer().editOrNewProducer().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret-p").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("user-secret-p").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endProducer().endSpec().build();
    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = mmc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(5).getName(), is("user-secret-c"));
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    assertThat(containers.get(0).getVolumeMounts().get(5).getMountPath(), is(KafkaMirrorMakerCluster.TLS_CERTS_VOLUME_MOUNT_CONSUMER + "user-secret-c"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaMirrorMakerCluster.ENV_VAR_KAFKA_MIRRORMAKER_TLS_AUTH_CERT_CONSUMER), is("user-secret-c/user.crt"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaMirrorMakerCluster.ENV_VAR_KAFKA_MIRRORMAKER_TLS_AUTH_KEY_CONSUMER), is("user-secret-c/user.key"));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(3).getName(), is("user-secret-p"));
    assertThat(containers.get(0).getVolumeMounts().get(3).getMountPath(), is(KafkaMirrorMakerCluster.TLS_CERTS_VOLUME_MOUNT_PRODUCER + "user-secret-p"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaMirrorMakerCluster.ENV_VAR_KAFKA_MIRRORMAKER_TLS_AUTH_CERT_PRODUCER), is("user-secret-p/user.crt"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaMirrorMakerCluster.ENV_VAR_KAFKA_MIRRORMAKER_TLS_AUTH_KEY_PRODUCER), is("user-secret-p/user.key"));
}
Also used : KafkaMirrorMakerBuilder(io.strimzi.api.kafka.model.KafkaMirrorMakerBuilder) Container(io.fabric8.kubernetes.api.model.Container) CertSecretSourceBuilder(io.strimzi.api.kafka.model.CertSecretSourceBuilder) KafkaClientAuthenticationTlsBuilder(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) KafkaMirrorMaker(io.strimzi.api.kafka.model.KafkaMirrorMaker) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 2 with KafkaClientAuthenticationTlsBuilder

use of io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder in project strimzi by strimzi.

the class KafkaMirrorMakerClusterTest method testGenerateDeploymentWithTlsSameSecret.

@ParallelTest
public void testGenerateDeploymentWithTlsSameSecret() {
    KafkaMirrorMaker resource = new KafkaMirrorMakerBuilder(this.resource).editSpec().editOrNewConsumer().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret-c").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("my-secret-c").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endConsumer().editOrNewProducer().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret-p").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("my-secret-p").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endProducer().endSpec().build();
    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = mmc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().size(), is(4));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(0).getName(), is(AbstractModel.STRIMZI_TMP_DIRECTORY_DEFAULT_VOLUME_NAME));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(2).getName(), is("my-secret-p"));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(3).getName(), is("my-secret-c"));
}
Also used : KafkaMirrorMakerBuilder(io.strimzi.api.kafka.model.KafkaMirrorMakerBuilder) CertSecretSourceBuilder(io.strimzi.api.kafka.model.CertSecretSourceBuilder) KafkaClientAuthenticationTlsBuilder(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) KafkaMirrorMaker(io.strimzi.api.kafka.model.KafkaMirrorMaker) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 3 with KafkaClientAuthenticationTlsBuilder

use of io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder in project strimzi-kafka-operator 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 4 with KafkaClientAuthenticationTlsBuilder

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

the class KafkaMirrorMakerClusterTest method testGenerateDeploymentWithTlsSameSecret.

@ParallelTest
public void testGenerateDeploymentWithTlsSameSecret() {
    KafkaMirrorMaker resource = new KafkaMirrorMakerBuilder(this.resource).editSpec().editOrNewConsumer().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret-c").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("my-secret-c").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endConsumer().editOrNewProducer().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret-p").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("my-secret-p").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endProducer().endSpec().build();
    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = mmc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().size(), is(4));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(0).getName(), is(AbstractModel.STRIMZI_TMP_DIRECTORY_DEFAULT_VOLUME_NAME));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(2).getName(), is("my-secret-p"));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(3).getName(), is("my-secret-c"));
}
Also used : KafkaMirrorMakerBuilder(io.strimzi.api.kafka.model.KafkaMirrorMakerBuilder) CertSecretSourceBuilder(io.strimzi.api.kafka.model.CertSecretSourceBuilder) KafkaClientAuthenticationTlsBuilder(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) KafkaMirrorMaker(io.strimzi.api.kafka.model.KafkaMirrorMaker) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 5 with KafkaClientAuthenticationTlsBuilder

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

the class KafkaMirrorMakerClusterTest method testGenerateDeploymentWithTlsAuth.

@ParallelTest
public void testGenerateDeploymentWithTlsAuth() {
    KafkaMirrorMaker resource = new KafkaMirrorMakerBuilder(this.resource).editSpec().editOrNewConsumer().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret-c").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("user-secret-c").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endConsumer().editOrNewProducer().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret-p").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("user-secret-p").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endProducer().endSpec().build();
    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = mmc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(5).getName(), is("user-secret-c"));
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    assertThat(containers.get(0).getVolumeMounts().get(5).getMountPath(), is(KafkaMirrorMakerCluster.TLS_CERTS_VOLUME_MOUNT_CONSUMER + "user-secret-c"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaMirrorMakerCluster.ENV_VAR_KAFKA_MIRRORMAKER_TLS_AUTH_CERT_CONSUMER), is("user-secret-c/user.crt"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaMirrorMakerCluster.ENV_VAR_KAFKA_MIRRORMAKER_TLS_AUTH_KEY_CONSUMER), is("user-secret-c/user.key"));
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(3).getName(), is("user-secret-p"));
    assertThat(containers.get(0).getVolumeMounts().get(3).getMountPath(), is(KafkaMirrorMakerCluster.TLS_CERTS_VOLUME_MOUNT_PRODUCER + "user-secret-p"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaMirrorMakerCluster.ENV_VAR_KAFKA_MIRRORMAKER_TLS_AUTH_CERT_PRODUCER), is("user-secret-p/user.crt"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaMirrorMakerCluster.ENV_VAR_KAFKA_MIRRORMAKER_TLS_AUTH_KEY_PRODUCER), is("user-secret-p/user.key"));
}
Also used : KafkaMirrorMakerBuilder(io.strimzi.api.kafka.model.KafkaMirrorMakerBuilder) Container(io.fabric8.kubernetes.api.model.Container) CertSecretSourceBuilder(io.strimzi.api.kafka.model.CertSecretSourceBuilder) KafkaClientAuthenticationTlsBuilder(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) KafkaMirrorMaker(io.strimzi.api.kafka.model.KafkaMirrorMaker) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)16 CertSecretSourceBuilder (io.strimzi.api.kafka.model.CertSecretSourceBuilder)16 KafkaClientAuthenticationTlsBuilder (io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTlsBuilder)16 ParallelTest (io.strimzi.test.annotations.ParallelTest)16 Container (io.fabric8.kubernetes.api.model.Container)8 KafkaBridge (io.strimzi.api.kafka.model.KafkaBridge)4 KafkaBridgeBuilder (io.strimzi.api.kafka.model.KafkaBridgeBuilder)4 KafkaConnect (io.strimzi.api.kafka.model.KafkaConnect)4 KafkaConnectBuilder (io.strimzi.api.kafka.model.KafkaConnectBuilder)4 KafkaMirrorMaker (io.strimzi.api.kafka.model.KafkaMirrorMaker)4 KafkaMirrorMaker2 (io.strimzi.api.kafka.model.KafkaMirrorMaker2)4 KafkaMirrorMaker2Builder (io.strimzi.api.kafka.model.KafkaMirrorMaker2Builder)4 KafkaMirrorMaker2ClusterSpec (io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpec)4 KafkaMirrorMaker2ClusterSpecBuilder (io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpecBuilder)4 KafkaMirrorMakerBuilder (io.strimzi.api.kafka.model.KafkaMirrorMakerBuilder)4