io.fabric8.kubernetes.api.model.LocalObjectReference Java Examples

The following examples show how to use io.fabric8.kubernetes.api.model.LocalObjectReference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaConnectClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsCO() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    List<LocalObjectReference> secrets = new ArrayList<>(2);
    secrets.add(secret1);
    secrets.add(secret2);

    KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(this.resource, VERSIONS);

    Deployment dep = kc.generateDeployment(emptyMap(), true, null, secrets);
    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));
}
 
Example #2
Source File: KafkaBridgeClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
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(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));
}
 
Example #3
Source File: KafkaBridgeClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsCO() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    List<LocalObjectReference> secrets = new ArrayList<>(2);
    secrets.add(secret1);
    secrets.add(secret2);

    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(this.resource, VERSIONS);

    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, secrets);
    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));
}
 
Example #4
Source File: KafkaBridgeClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
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(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));
}
 
Example #5
Source File: EntityOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecrets() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    Kafka resource = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas, image, healthDelay, healthTimeout))
            .editSpec()
                .withNewEntityOperator()
                .withTopicOperator(entityTopicOperatorSpec)
                .withUserOperator(entityUserOperatorSpec)
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret1, secret2)
                    .endPod()
                .endTemplate()
                .endEntityOperator()
            .endSpec()
            .build();
    EntityOperator eo = EntityOperator.fromCrd(resource, VERSIONS);

    Deployment dep = eo.generateDeployment(true, Collections.EMPTY_MAP, 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));
}
 
Example #6
Source File: EntityOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsFromCo() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    List<LocalObjectReference> secrets = new ArrayList<>(2);
    secrets.add(secret1);
    secrets.add(secret2);

    Kafka resource = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas, image, healthDelay, healthTimeout))
            .editSpec()
                .withNewEntityOperator()
                    .withTopicOperator(entityTopicOperatorSpec)
                    .withUserOperator(entityUserOperatorSpec)
                .endEntityOperator()
            .endSpec()
            .build();
    EntityOperator eo = EntityOperator.fromCrd(resource, VERSIONS);

    Deployment dep = eo.generateDeployment(true, Collections.EMPTY_MAP, null, secrets);
    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));
}
 
Example #7
Source File: EntityOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsFromBoth() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    Kafka resource = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas, image, healthDelay, healthTimeout))
            .editSpec()
            .withNewEntityOperator()
            .withTopicOperator(entityTopicOperatorSpec)
            .withUserOperator(entityUserOperatorSpec)
            .withNewTemplate()
            .withNewPod()
            .withImagePullSecrets(secret2)
            .endPod()
            .endTemplate()
            .endEntityOperator()
            .endSpec()
            .build();
    EntityOperator eo = EntityOperator.fromCrd(resource, VERSIONS);

    Deployment dep = eo.generateDeployment(true, Collections.EMPTY_MAP, 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));
}
 
Example #8
Source File: KafkaMirrorMakerClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecrets() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    KafkaMirrorMaker resource = new KafkaMirrorMakerBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret1, secret2)
                    .endPod()
                .endTemplate()
            .endSpec()
            .build();
    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(resource, VERSIONS);

    Deployment dep = mmc.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));
}
 
Example #9
Source File: KafkaMirrorMakerClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsFromCo() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    List<LocalObjectReference> secrets = new ArrayList<>(2);
    secrets.add(secret1);
    secrets.add(secret2);

    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(this.resource, VERSIONS);

    Deployment dep = mmc.generateDeployment(emptyMap(), true, null, secrets);
    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));
}
 
Example #10
Source File: KafkaMirrorMakerClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsFromBoth() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    KafkaMirrorMaker resource = new KafkaMirrorMakerBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret2)
                    .endPod()
                .endTemplate()
            .endSpec()
            .build();
    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(resource, VERSIONS);

    Deployment dep = mmc.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));
}
 
Example #11
Source File: KafkaConnectClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecrets() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    KafkaConnect resource = new KafkaConnectBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret1, secret2)
                    .endPod()
                .endTemplate()
            .endSpec()
            .build();
    KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(resource, VERSIONS);

    Deployment dep = kc.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));
}
 
Example #12
Source File: KafkaConnectS2IClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsBoth() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    KafkaConnectS2I resource = new KafkaConnectS2IBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret2)
                    .endPod()
                .endTemplate()
            .endSpec()
            .build();
    KafkaConnectS2ICluster kc = KafkaConnectS2ICluster.fromCrd(resource, VERSIONS);

    Deployment dep = kc.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));
}
 
Example #13
Source File: KafkaConnectClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsBoth() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    KafkaConnect resource = new KafkaConnectBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret2)
                    .endPod()
                .endTemplate()
            .endSpec()
            .build();
    KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(resource, VERSIONS);

    Deployment dep = kc.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));
}
 
Example #14
Source File: ZookeeperClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecrets() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas,
            image, healthDelay, healthTimeout, metricsCmJson, configurationJson, emptyMap()))
            .editSpec()
                .editZookeeper()
                    .withNewTemplate()
                        .withNewPod()
                            .withImagePullSecrets(secret1, secret2)
                        .endPod()
                    .endTemplate()
                .endZookeeper()
            .endSpec()
            .build();
    ZookeeperCluster zc = ZookeeperCluster.fromCrd(kafkaAssembly, VERSIONS);

    StatefulSet sts = zc.generateStatefulSet(true, null, null);
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().size(), is(2));
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret1), is(true));
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret2), is(true));
}
 
Example #15
Source File: ZookeeperClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsFromCO() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    List<LocalObjectReference> secrets = new ArrayList<>(2);
    secrets.add(secret1);
    secrets.add(secret2);

    Kafka kafkaAssembly = ResourceUtils.createKafkaCluster(namespace, cluster, replicas,
            image, healthDelay, healthTimeout, metricsCmJson, configurationJson, emptyMap());
    ZookeeperCluster zc = ZookeeperCluster.fromCrd(kafkaAssembly, VERSIONS);

    StatefulSet sts = zc.generateStatefulSet(true, null, secrets);
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().size(), is(2));
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret1), is(true));
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret2), is(true));
}
 
Example #16
Source File: ZookeeperClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsFromBoth() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas,
            image, healthDelay, healthTimeout, metricsCmJson, configurationJson, emptyMap()))
            .editSpec()
                .editZookeeper()
                    .withNewTemplate()
                        .withNewPod()
                            .withImagePullSecrets(secret2)
                        .endPod()
                    .endTemplate()
                .endZookeeper()
            .endSpec()
            .build();
    ZookeeperCluster zc = ZookeeperCluster.fromCrd(kafkaAssembly, VERSIONS);

    StatefulSet sts = zc.generateStatefulSet(true, null, singletonList(secret1));
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().size(), is(1));
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret1), is(false));
    assertThat(sts.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret2), is(true));
}
 
Example #17
Source File: KafkaMirrorMaker2ClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecrets() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret1, secret2)
                    .endPod()
                .endTemplate()
            .endSpec()
            .build();
    KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(resource, VERSIONS);

    Deployment dep = kmm2.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));
}
 
Example #18
Source File: KafkaMirrorMaker2ClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsCO() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    List<LocalObjectReference> secrets = new ArrayList<>(2);
    secrets.add(secret1);
    secrets.add(secret2);

    KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(this.resource, VERSIONS);

    Deployment dep = kmm2.generateDeployment(emptyMap(), true, null, secrets);
    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));
}
 
Example #19
Source File: KafkaMirrorMaker2ClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsBoth() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret2)
                    .endPod()
                .endTemplate()
            .endSpec()
            .build();
    KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(resource, VERSIONS);

    Deployment dep = kmm2.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));
}
 
Example #20
Source File: KafkaConnectS2IClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecrets() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    KafkaConnectS2I resource = new KafkaConnectS2IBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPod()
                        .withImagePullSecrets(secret1, secret2)
                    .endPod()
                .endTemplate()
            .endSpec()
            .build();
    KafkaConnectS2ICluster kc = KafkaConnectS2ICluster.fromCrd(resource, VERSIONS);

    DeploymentConfig dep = kc.generateDeploymentConfig(Collections.EMPTY_MAP, 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));
}
 
Example #21
Source File: KafkaConnectS2IClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretsCO() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");

    List<LocalObjectReference> secrets = new ArrayList<>(2);
    secrets.add(secret1);
    secrets.add(secret2);

    KafkaConnectS2ICluster kc = KafkaConnectS2ICluster.fromCrd(this.resource, VERSIONS);

    Deployment dep = kc.generateDeployment(emptyMap(), true, null, secrets);
    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));
}
 
Example #22
Source File: KafkaConnectCluster.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public Deployment generateDeployment(Map<String, String> annotations, boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets) {
    DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder()
            .withType("RollingUpdate")
            .withRollingUpdate(new RollingUpdateDeploymentBuilder()
                    .withMaxSurge(new IntOrString(1))
                    .withMaxUnavailable(new IntOrString(0))
                    .build())
            .build();

    return createDeployment(
            updateStrategy,
            Collections.emptyMap(),
            annotations,
            getMergedAffinity(),
            getInitContainers(imagePullPolicy),
            getContainers(imagePullPolicy),
            getVolumes(isOpenShift),
            imagePullSecrets);
}
 
Example #23
Source File: KubernetesSchedulerTests.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 6 votes vote down vote up
@Test
public void testImagePullSecretDefault() {
	KubernetesSchedulerProperties kubernetesSchedulerProperties = new KubernetesSchedulerProperties();
	if (kubernetesSchedulerProperties.getNamespace() == null) {
		kubernetesSchedulerProperties.setNamespace("default");
	}
	KubernetesClient kubernetesClient = new DefaultKubernetesClient()
			.inNamespace(kubernetesSchedulerProperties.getNamespace());

	KubernetesScheduler kubernetesScheduler = new KubernetesScheduler(kubernetesClient,
			kubernetesSchedulerProperties);

	AppDefinition appDefinition = new AppDefinition(randomName(), getAppProperties());
	ScheduleRequest scheduleRequest = new ScheduleRequest(appDefinition, getSchedulerProperties(),
			getDeploymentProperties(), getCommandLineArgs(), randomName(), testApplication());

	CronJob cronJob = kubernetesScheduler.createCronJob(scheduleRequest);
	CronJobSpec cronJobSpec = cronJob.getSpec();

	List<LocalObjectReference> secrets = cronJobSpec.getJobTemplate().getSpec().getTemplate().getSpec()
			.getImagePullSecrets();
	assertTrue("There should be no secrets", secrets.isEmpty());

	kubernetesScheduler.unschedule(cronJob.getMetadata().getName());
}
 
Example #24
Source File: PodMergerTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void shouldNotAddImagePullPolicyTwice() throws Exception {
  // given
  PodSpec podSpec1 =
      new PodSpecBuilder()
          .withImagePullSecrets(new LocalObjectReferenceBuilder().withName("secret").build())
          .build();
  podSpec1.setAdditionalProperty("add1", 1L);
  PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build());

  PodSpec podSpec2 =
      new PodSpecBuilder()
          .withImagePullSecrets(new LocalObjectReferenceBuilder().withName("secret").build())
          .build();
  podSpec2.setAdditionalProperty("add2", 2L);
  PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build());

  // when
  Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2));

  // then
  PodTemplateSpec podTemplate = merged.getSpec().getTemplate();
  List<LocalObjectReference> imagePullSecrets = podTemplate.getSpec().getImagePullSecrets();
  assertEquals(imagePullSecrets.size(), 1);
  assertEquals(imagePullSecrets.get(0).getName(), "secret");
}
 
Example #25
Source File: KafkaCluster.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
/**
 * Generates a StatefulSet according to configured defaults
 *
 * @param isOpenShift      True iff this operator is operating within OpenShift.
 * @param imagePullPolicy  The image pull policy.
 * @param imagePullSecrets The image pull secrets.
 * @return The generated StatefulSet.
 */
public StatefulSet generateStatefulSet(boolean isOpenShift,
                                       ImagePullPolicy imagePullPolicy,
                                       List<LocalObjectReference> imagePullSecrets) {
    Map<String, String> stsAnnotations = new HashMap<>(2);
    stsAnnotations.put(ANNO_STRIMZI_IO_KAFKA_VERSION, kafkaVersion.version());
    stsAnnotations.put(ANNO_STRIMZI_IO_STORAGE, ModelUtils.encodeStorageToJson(storage));

    return createStatefulSet(
            stsAnnotations,
            emptyMap(),
            getVolumes(isOpenShift),
            getVolumeClaims(),
            getMergedAffinity(),
            getInitContainers(imagePullPolicy),
            getContainers(imagePullPolicy),
            imagePullSecrets,
            isOpenShift);
}
 
Example #26
Source File: KafkaBridgeCluster.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public Deployment generateDeployment(Map<String, String> annotations, boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets) {
    DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder()
            .withType("RollingUpdate")
            .withRollingUpdate(new RollingUpdateDeploymentBuilder()
                    .withMaxSurge(new IntOrString(1))
                    .withMaxUnavailable(new IntOrString(0))
                    .build())
            .build();

    return createDeployment(
            updateStrategy,
            Collections.emptyMap(),
            annotations,
            getMergedAffinity(),
            getInitContainers(imagePullPolicy),
            getContainers(imagePullPolicy),
            getVolumes(isOpenShift),
            imagePullSecrets);
}
 
Example #27
Source File: KafkaExporter.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public Deployment generateDeployment(boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets) {
    if (!isDeployed()) {
        return null;
    }

    DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder()
            .withType("RollingUpdate")
            .build();

    return createDeployment(
            updateStrategy,
            Collections.emptyMap(),
            Collections.emptyMap(),
            getMergedAffinity(),
            getInitContainers(imagePullPolicy),
            getContainers(imagePullPolicy),
            getVolumes(isOpenShift),
            imagePullSecrets
    );
}
 
Example #28
Source File: CruiseControl.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public Deployment generateDeployment(boolean isOpenShift, Map<String, String> annotations, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets) {
    if (!isDeployed()) {
        return null;
    }

    DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder()
            .withType("RollingUpdate")
            .withRollingUpdate(new RollingUpdateDeploymentBuilder()
                    .withMaxSurge(new IntOrString(1))
                    .withMaxUnavailable(new IntOrString(0))
                    .build())
            .build();

    return createDeployment(
            updateStrategy,
            Collections.emptyMap(),
            Collections.emptyMap(),
            getMergedAffinity(),
            getInitContainers(imagePullPolicy),
            getContainers(imagePullPolicy),
            getVolumes(isOpenShift),
            imagePullSecrets);
}
 
Example #29
Source File: JmxTrans.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public Deployment generateDeployment(ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets) {
    if (!isDeployed()) {
        return null;
    }

    DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder()
            .withType("RollingUpdate")
            .withRollingUpdate(new RollingUpdateDeploymentBuilder()
                    .withMaxSurge(new IntOrString(1))
                    .withMaxUnavailable(new IntOrString(0))
                    .build())
            .build();

    return createDeployment(
            updateStrategy,
            Collections.emptyMap(),
            Collections.emptyMap(),
            getMergedAffinity(),
            getInitContainers(imagePullPolicy),
            getContainers(imagePullPolicy),
            getVolumes(),
            imagePullSecrets
    );
}
 
Example #30
Source File: EntityOperator.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
public Deployment generateDeployment(boolean isOpenShift, Map<String, String> annotations, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets) {

        if (!isDeployed()) {
            log.warn("Topic and/or User Operators not declared: Entity Operator will not be deployed");
            return null;
        }

        DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder()
                .withType("Recreate")
                .build();

        return createDeployment(
                updateStrategy,
                Collections.emptyMap(),
                annotations,
                getMergedAffinity(),
                getInitContainers(imagePullPolicy),
                getContainers(imagePullPolicy),
                getVolumes(isOpenShift),
                imagePullSecrets
        );
    }