Search in sources :

Example 61 with ReplicaSet

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");
}
Also used : PatchContext(io.fabric8.kubernetes.client.dsl.base.PatchContext) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) ReplicaSet(io.fabric8.kubernetes.api.model.apps.ReplicaSet) Test(org.junit.Test)

Example 62 with ReplicaSet

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());
}
Also used : ReplicaSet(io.fabric8.kubernetes.api.model.apps.ReplicaSet) Test(org.junit.Test)

Example 63 with ReplicaSet

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);
}
Also used : ReplicaSet(io.fabric8.kubernetes.api.model.apps.ReplicaSet) Test(org.junit.Test)

Example 64 with ReplicaSet

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());
}
Also used : ReplicaSetBuilder(io.fabric8.kubernetes.api.model.apps.ReplicaSetBuilder) ReadyEntity(io.fabric8.commons.ReadyEntity) ReplicaSet(io.fabric8.kubernetes.api.model.apps.ReplicaSet) Test(org.junit.Test)

Example 65 with ReplicaSet

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);
}
Also used : ReplicaSetList(io.fabric8.kubernetes.api.model.apps.ReplicaSetList) Objects(java.util.Objects) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Test(org.junit.Test)

Aggregations

ReplicaSet (io.fabric8.kubernetes.api.model.apps.ReplicaSet)50 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)26 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)22 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)22 Test (org.junit.Test)19 ReplicaSetBuilder (io.fabric8.kubernetes.api.model.apps.ReplicaSetBuilder)18 ReplicaSet (io.fabric8.kubernetes.api.model.extensions.ReplicaSet)17 Test (org.junit.jupiter.api.Test)15 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)14 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)14 Pod (io.fabric8.kubernetes.api.model.Pod)13 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)10 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)9 ReplicationControllerSpec (io.fabric8.kubernetes.api.model.ReplicationControllerSpec)9 ReplicaSetSpec (io.fabric8.kubernetes.api.model.apps.ReplicaSetSpec)9 DeploymentConfigSpec (io.fabric8.openshift.api.model.DeploymentConfigSpec)9 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)8 Container (io.fabric8.kubernetes.api.model.Container)7 DaemonSet (io.fabric8.kubernetes.api.model.apps.DaemonSet)7 DeploymentSpec (io.fabric8.kubernetes.api.model.apps.DeploymentSpec)7