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());
}
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);
}
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);
}
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());
}
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);
}
Aggregations