use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class PatchIT method testJsonPatchWithPositionalArrays.
@Test
public void testJsonPatchWithPositionalArrays() {
// Given
String name = "patchit-testjsonpatchpositionalarray";
PatchContext patchContext = new PatchContext.Builder().withPatchType(PatchType.JSON).build();
// When
ReplicaSet patchedReplicaSet = client.apps().replicaSets().inNamespace(currentNamespace).withName(name).patch(patchContext, "[{\"op\": \"replace\", \"path\":\"/spec/template/spec/containers/0/image\", \"value\":\"foo/gb-frontend:v4\"}]");
// Then
assertThat(patchedReplicaSet).isNotNull();
assertThat(patchedReplicaSet.getSpec().getTemplate().getSpec().getContainers().get(0).getImage()).isEqualTo("foo/gb-frontend:v4");
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ReplicaSetIT method load.
@Test
public void load() {
ReplicaSet replicaSet = client.apps().replicaSets().inNamespace(session.getNamespace()).load(getClass().getResourceAsStream("/test-replicaset.yml")).get();
assertThat(replicaSet).isNotNull();
assertEquals("frontend", replicaSet.getMetadata().getName());
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ReplicaSetIT method get.
@Test
public void get() {
ReplicaSet replicaset1 = client.apps().replicaSets().inNamespace(session.getNamespace()).withName("replicaset-get").get();
assertNotNull(replicaset1);
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ReplicaSetIT method update.
@Test
public void update() {
ReadyEntity<ReplicaSet> replicaSetReady = new ReadyEntity<>(ReplicaSet.class, client, "replicaset-update", session.getNamespace());
await().atMost(30, TimeUnit.SECONDS).until(replicaSetReady);
ReplicaSet replicaset1 = client.apps().replicaSets().inNamespace(session.getNamespace()).withName("replicaset-update").edit(r -> new ReplicaSetBuilder(r).editSpec().withReplicas(2).endSpec().build());
assertThat(replicaset1).isNotNull();
assertEquals(2, replicaset1.getSpec().getReplicas().intValue());
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ResourceIT method testDeleteExistingWithoutOrphanDeletion.
@Test
public void testDeleteExistingWithoutOrphanDeletion() {
// Create Deployment
Resource<Deployment> resource = client.resource(deployment).inNamespace(session.getNamespace());
resource.createOrReplace();
await().atMost(30, TimeUnit.SECONDS).until(resourceIsReady(deployment));
// get uid of underlying replicaset. we expect this to match later, meaning the orphan was not deleted.
ReplicaSetList replicaSetList = client.apps().replicaSets().inNamespace(session.getNamespace()).withLabel("run", deploymentName).list();
assertEquals(1, replicaSetList.getItems().size());
String replicaSetUid = replicaSetList.getItems().get(0).getMetadata().getUid();
// Recreate deployment
resource.withPropagationPolicy(DeletionPropagation.ORPHAN).delete();
resource.waitUntilCondition(Objects::isNull, 30, TimeUnit.SECONDS);
resource.create();
await().atMost(30, TimeUnit.SECONDS).until(resourceIsReady(deployment));
// check that uid matches original, meaning the orphan was not deleted
replicaSetList = client.apps().replicaSets().inNamespace(session.getNamespace()).withLabel("run", deploymentName).list();
assertEquals(1, replicaSetList.getItems().size());
assertEquals(replicaSetUid, replicaSetList.getItems().get(0).getMetadata().getUid());
// cleanup
assertEquals(true, resource.delete());
// Check whether child resources are also deleted
await().atMost(30, TimeUnit.SECONDS).until(() -> client.apps().replicaSets().inNamespace(session.getNamespace()).withLabel("run", deploymentName).list().getItems().size() == 0);
}
Aggregations