Search in sources :

Example 16 with StatefulSetBuilder

use of io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder in project kubernetes-client by fabric8io.

the class PropagationPolicyTest method testDeleteStatefulSet.

@Test
@DisplayName("Should delete a StatefulSet with PropagationPolicy=Background")
void testDeleteStatefulSet() throws InterruptedException {
    // Given
    server.expect().delete().withPath("/apis/apps/v1/namespaces/ns1/statefulsets/mystatefulset").andReturn(HttpURLConnection.HTTP_OK, new StatefulSetBuilder().build()).once();
    // When
    Boolean isDeleted = client.apps().statefulSets().inNamespace("ns1").withName("mystatefulset").delete();
    // Then
    assertTrue(isDeleted);
    assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest());
}
Also used : StatefulSetBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 17 with StatefulSetBuilder

use of io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder in project kubernetes-client by fabric8io.

the class StatefulSetRollingUpdater method removeDeploymentKey.

@Override
protected StatefulSet removeDeploymentKey(String name) {
    StatefulSet old = resources().inNamespace(namespace).withName(name).get();
    StatefulSet updated = new StatefulSetBuilder(old).editSpec().editSelector().removeFromMatchLabels(DEPLOYMENT_KEY).endSelector().editTemplate().editMetadata().removeFromLabels(DEPLOYMENT_KEY).endMetadata().endTemplate().endSpec().build();
    return resources().inNamespace(namespace).withName(name).replace(updated);
}
Also used : StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) StatefulSetBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder)

Example 18 with StatefulSetBuilder

use of io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder in project kubernetes-client by fabric8io.

the class StatefulSetRollingUpdater method updateDeploymentKey.

@Override
protected StatefulSet updateDeploymentKey(String name, String hash) {
    StatefulSet old = resources().inNamespace(namespace).withName(name).get();
    StatefulSet updated = new StatefulSetBuilder(old).editSpec().editSelector().addToMatchLabels(DEPLOYMENT_KEY, hash).endSelector().editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, hash).endMetadata().endTemplate().endSpec().build();
    return resources().inNamespace(namespace).withName(name).replace(updated);
}
Also used : StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) StatefulSetBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder)

Example 19 with StatefulSetBuilder

use of io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder in project kubernetes-client by fabric8io.

the class StatefulSetTest method testScaleAndWait.

@Test
public void testScaleAndWait() {
    server.expect().withPath("/apis/apps/v1/namespaces/test/statefulsets/repl1").andReturn(200, new StatefulSetBuilder().withNewMetadata().withName("repl1").withResourceVersion("1").endMetadata().withNewSpec().withReplicas(5).endSpec().withNewStatus().withReplicas(1).endStatus().build()).once();
    StatefulSet scaled = new StatefulSetBuilder().withNewMetadata().withName("repl1").withResourceVersion("1").endMetadata().withNewSpec().withReplicas(5).endSpec().withNewStatus().withReplicas(5).endStatus().build();
    server.expect().withPath("/apis/apps/v1/namespaces/test/statefulsets/repl1").andReturn(200, scaled).once();
    // list for waiting
    server.expect().withPath("/apis/apps/v1/namespaces/test/statefulsets?fieldSelector=metadata.name%3Drepl1").andReturn(200, new StatefulSetListBuilder().withItems(scaled).withMetadata(new ListMetaBuilder().build()).build()).always();
    StatefulSet repl = client.apps().statefulSets().withName("repl1").scale(5, true);
    assertNotNull(repl);
    assertNotNull(repl.getSpec());
    assertEquals(5, repl.getSpec().getReplicas().intValue());
    assertEquals(5, repl.getStatus().getReplicas().intValue());
}
Also used : ListMetaBuilder(io.fabric8.kubernetes.api.model.ListMetaBuilder) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) StatefulSetBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder) StatefulSetListBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetListBuilder) Test(org.junit.jupiter.api.Test)

Example 20 with StatefulSetBuilder

use of io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder in project kubernetes-client by fabric8io.

the class StatefulSetTest method testGet.

@Test
public void testGet() {
    server.expect().withPath("/apis/apps/v1/namespaces/test/statefulsets/repl1").andReturn(200, new StatefulSetBuilder().build()).once();
    server.expect().withPath("/apis/apps/v1/namespaces/ns1/statefulsets/repl2").andReturn(200, new StatefulSetBuilder().build()).once();
    StatefulSet repl1 = client.apps().statefulSets().withName("repl1").get();
    assertNotNull(repl1);
    repl1 = client.apps().statefulSets().withName("repl2").get();
    assertNull(repl1);
    repl1 = client.apps().statefulSets().inNamespace("ns1").withName("repl2").get();
    assertNotNull(repl1);
}
Also used : StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) StatefulSetBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

StatefulSetBuilder (io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder)48 StatefulSet (io.fabric8.kubernetes.api.model.apps.StatefulSet)43 Test (org.junit.jupiter.api.Test)34 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)18 Checkpoint (io.vertx.junit5.Checkpoint)18 Pod (io.fabric8.kubernetes.api.model.Pod)16 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)16 Reconciliation (io.strimzi.operator.common.Reconciliation)16 Future (io.vertx.core.Future)16 Vertx (io.vertx.core.Vertx)16 VertxTestContext (io.vertx.junit5.VertxTestContext)16 Map (java.util.Map)16 CoreMatchers.is (org.hamcrest.CoreMatchers.is)16 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)16 StrimziPodSetList (io.strimzi.api.kafka.StrimziPodSetList)14 Kafka (io.strimzi.api.kafka.model.Kafka)14 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)14 StrimziPodSet (io.strimzi.api.kafka.model.StrimziPodSet)14 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)14 KafkaListenerType (io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType)14