io.fabric8.kubernetes.api.model.apps.ReplicaSet Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.apps.ReplicaSet.
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: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Override public Deployment undo() { List<ReplicaSet> replicaSets = getReplicaSetListForDeployment(get()).getItems(); // Sort list of replicaSets based on revision annotation replicaSets.sort((o1, o2) -> { String revisionO1 = o1.getMetadata().getAnnotations().get(DEPLOYMENT_KUBERNETES_IO_REVISION); String revisionO2 = o2.getMetadata().getAnnotations().get(DEPLOYMENT_KUBERNETES_IO_REVISION); return Integer.parseInt(revisionO2) - Integer.parseInt(revisionO1); }); ReplicaSet latestReplicaSet = replicaSets.get(0); ReplicaSet previousRevisionReplicaSet = replicaSets.get(1); Deployment deployment = get(); deployment.getMetadata().getAnnotations().put(DEPLOYMENT_KUBERNETES_IO_REVISION, latestReplicaSet.getMetadata().getAnnotations().get(DEPLOYMENT_KUBERNETES_IO_REVISION)); deployment.getSpec().setTemplate(previousRevisionReplicaSet.getSpec().getTemplate()); return sendPatchedObject(get(), deployment); }
Example #2
Source File: ReplicaSetTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should update image based in map based argument") void testRolloutUpdateImage() throws InterruptedException { // Given Map<String, String> containerToImageMap = Collections.singletonMap("nginx", "nginx:latest"); server.expect().get().withPath("/apis/apps/v1/namespaces/ns1/replicasets/replicaset1") .andReturn(HttpURLConnection.HTTP_OK, getReplicaSetBuilder().build()).times(3); server.expect().patch().withPath("/apis/apps/v1/namespaces/ns1/replicasets/replicaset1") .andReturn(HttpURLConnection.HTTP_OK, getReplicaSetBuilder() .editSpec().editTemplate().editSpec().editContainer(0) .withImage(containerToImageMap.get("nginx")) .endContainer().endSpec().endTemplate().endSpec() .build()).once(); KubernetesClient client = server.getClient(); // When ReplicaSet replicationController = client.apps().replicaSets().inNamespace("ns1").withName("replicaset1") .rolling().updateImage(containerToImageMap); // Then assertNotNull(replicationController); assertEquals(containerToImageMap.get("nginx"), replicationController.getSpec().getTemplate().getSpec().getContainers().get(0).getImage()); RecordedRequest recordedRequest = server.getLastRequest(); assertEquals("PATCH", recordedRequest.getMethod()); assertTrue(recordedRequest.getBody().readUtf8().contains(containerToImageMap.get("nginx"))); }
Example #3
Source File: ReplicaSetTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should update image based in single argument") void testRolloutUpdateSingleImage() throws InterruptedException { // Given String imageToUpdate = "nginx:latest"; server.expect().get().withPath("/apis/apps/v1/namespaces/ns1/replicasets/replicaset1") .andReturn(HttpURLConnection.HTTP_OK, getReplicaSetBuilder().build()).times(3); server.expect().patch().withPath("/apis/apps/v1/namespaces/ns1/replicasets/replicaset1") .andReturn(HttpURLConnection.HTTP_OK, getReplicaSetBuilder() .editSpec().editTemplate().editSpec().editContainer(0) .withImage(imageToUpdate) .endContainer().endSpec().endTemplate().endSpec() .build()).times(2); KubernetesClient client = server.getClient(); // When ReplicaSet replicationController = client.apps().replicaSets().inNamespace("ns1").withName("replicaset1") .rolling().updateImage(imageToUpdate); // Then assertNotNull(replicationController); assertEquals(imageToUpdate, replicationController.getSpec().getTemplate().getSpec().getContainers().get(0).getImage()); RecordedRequest recordedRequest = server.getLastRequest(); assertEquals("PATCH", recordedRequest.getMethod()); assertTrue(recordedRequest.getBody().readUtf8().contains(imageToUpdate)); }
Example #4
Source File: ReplicaSetOperationsImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
private List<PodResource<Pod, DoneablePod>> doGetLog(boolean isPretty) { List<PodResource<Pod, DoneablePod>> pods = new ArrayList<>(); ReplicaSet replicaSet = fromServer().get(); String rcUid = replicaSet.getMetadata().getUid(); PodOperationsImpl podOperations = new PodOperationsImpl(new PodOperationContext(context.getClient(), context.getConfig(), context.getPlural(), context.getNamespace(), context.getName(), null, "v1", context.getCascading(), context.getItem(), context.getLabels(), context.getLabelsNot(), context.getLabelsIn(), context.getLabelsNotIn(), context.getFields(), context.getFieldsNot(), context.getResourceVersion(), context.getReloadingFromServer(), context.getGracePeriodSeconds(), context.getPropagationPolicy(), context.getWatchRetryInitialBackoffMillis(), context.getWatchRetryBackoffMultiplier(), null, null, null, null, null, null, null, null, null, false, false, false, null, null, null, isPretty, null, null, null, null, null)); PodList jobPodList = podOperations.withLabels(replicaSet.getMetadata().getLabels()).list(); for (Pod pod : jobPodList.getItems()) { OwnerReference ownerReference = KubernetesResourceUtil.getControllerUid(pod); if (ownerReference != null && ownerReference.getUid().equals(rcUid)) { pods.add(podOperations.withName(pod.getMetadata().getName())); } } return pods; }
Example #5
Source File: ReplicaSetOperationsImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Override public ReplicaSet updateImage(Map<String, String> containerToImageMap) { ReplicaSet replicationController = get(); if (replicationController == null) { throw new KubernetesClientException("Existing replica set doesn't exist"); } if (replicationController.getSpec().getTemplate().getSpec().getContainers().isEmpty()) { throw new KubernetesClientException("Pod has no containers!"); } List<Container> containers = replicationController.getSpec().getTemplate().getSpec().getContainers(); for (Container container : containers) { if (containerToImageMap.containsKey(container.getName())) { container.setImage(containerToImageMap.get(container.getName())); } } replicationController.getSpec().getTemplate().getSpec().setContainers(containers); return sendPatchedObject(get(), replicationController); }
Example #6
Source File: ReplicaSetRollingUpdater.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Override protected PodList listSelectedPods(ReplicaSet obj) { FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> podLister = pods().inNamespace(namespace); if (obj.getSpec().getSelector().getMatchLabels() != null) { podLister.withLabels(obj.getSpec().getSelector().getMatchLabels()); } if (obj.getSpec().getSelector().getMatchExpressions() != null) { for (LabelSelectorRequirement req : obj.getSpec().getSelector().getMatchExpressions()) { switch (req.getOperator()) { case "In": podLister.withLabelIn(req.getKey(), req.getValues().toArray(new String[]{})); break; case "NotIn": podLister.withLabelNotIn(req.getKey(), req.getValues().toArray(new String[]{})); break; case "DoesNotExist": podLister.withoutLabel(req.getKey()); break; case "Exists": podLister.withLabel(req.getKey()); break; } } } return podLister.list(); }
Example #7
Source File: ReplicaSetTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testScale() { server.expect().withPath("/apis/apps/v1/namespaces/test/replicasets/repl1").andReturn(200, new ReplicaSetBuilder() .withNewMetadata() .withName("repl1") .withResourceVersion("1") .endMetadata() .withNewSpec() .withReplicas(5) .endSpec() .withNewStatus() .withReplicas(1) .endStatus() .build()).always(); KubernetesClient client = server.getClient(); ReplicaSet repl = client.apps().replicaSets().withName("repl1").scale(5); assertNotNull(repl); assertNotNull(repl.getSpec()); assertEquals(5, repl.getSpec().getReplicas().intValue()); assertEquals(1, repl.getStatus().getReplicas().intValue()); }
Example #8
Source File: ReplicaSetTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testGet() { server.expect().withPath("/apis/apps/v1/namespaces/test/replicasets/repl1").andReturn(200, new ReplicaSetBuilder().build()).once(); server.expect().withPath("/apis/apps/v1/namespaces/ns1/replicasets/repl2").andReturn(200, new ReplicaSetBuilder().build()).once(); KubernetesClient client = server.getClient(); ReplicaSet repl1 = client.apps().replicaSets().withName("repl1").get(); assertNotNull(repl1); repl1 = client.apps().replicaSets().withName("repl2").get(); assertNull(repl1); repl1 = client.apps().replicaSets().inNamespace("ns1").withName("repl2").get(); assertNotNull(repl1); }
Example #9
Source File: ReplicaSetOperationsImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Override public ReplicaSet updateImage(String image) { ReplicaSet oldRC = get(); if (oldRC == null) { throw new KubernetesClientException("Existing replication controller doesn't exist"); } if (oldRC.getSpec().getTemplate().getSpec().getContainers().size() > 1) { throw new KubernetesClientException("Image update is not supported for multicontainer pods"); } if (oldRC.getSpec().getTemplate().getSpec().getContainers().isEmpty()) { throw new KubernetesClientException("Pod has no containers!"); } Container container = oldRC.getSpec().getTemplate().getSpec().getContainers().iterator().next(); return updateImage(Collections.singletonMap(container.getName(), image)); }
Example #10
Source File: Readiness.java From kubernetes-client with Apache License 2.0 | 6 votes |
public static boolean isReady(HasMetadata item) { if (item instanceof Deployment) { return isDeploymentReady((Deployment) item); } else if (item instanceof ReplicaSet) { return isReplicaSetReady((ReplicaSet) item); } else if (item instanceof Pod) { return isPodReady((Pod) item); } else if (item instanceof DeploymentConfig) { return isDeploymentConfigReady((DeploymentConfig) item); } else if (item instanceof ReplicationController) { return isReplicationControllerReady((ReplicationController) item); } else if (item instanceof Endpoints) { return isEndpointsReady((Endpoints) item); } else if (item instanceof Node) { return isNodeReady((Node) item); } else if (item instanceof StatefulSet) { return isStatefulSetReady((StatefulSet) item); } else { throw new IllegalArgumentException("Item needs to be one of [Node, Deployment, ReplicaSet, StatefulSet, Pod, DeploymentConfig, ReplicationController], but was: [" + (item != null ? item.getKind() : "Unknown (null)") + "]"); } }
Example #11
Source File: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
private List<RollableScalableResource<ReplicaSet, DoneableReplicaSet>> doGetLog() { List<RollableScalableResource<ReplicaSet, DoneableReplicaSet>> rcs = new ArrayList<>(); Deployment deployment = fromServer().get(); String rcUid = deployment.getMetadata().getUid(); ReplicaSetOperationsImpl rsOperations = new ReplicaSetOperationsImpl((RollingOperationContext) context); ReplicaSetList rcList = rsOperations.withLabels(deployment.getSpec().getTemplate().getMetadata().getLabels()).list(); for (ReplicaSet rs : rcList.getItems()) { OwnerReference ownerReference = KubernetesResourceUtil.getControllerUid(rs); if (ownerReference != null && ownerReference.getUid().equals(rcUid)) { rcs.add(rsOperations.withName(rs.getMetadata().getName())); } } return rcs; }
Example #12
Source File: KubernetesClientUtil.java From jkube with Eclipse Public License 2.0 | 6 votes |
public static void resizeApp(KubernetesClient kubernetes, String namespace, Set<HasMetadata> entities, int replicas, KitLogger log) { for (HasMetadata entity : entities) { String name = KubernetesHelper.getName(entity); Scaleable<?> scalable = null; if (entity instanceof Deployment) { scalable = kubernetes.apps().deployments().inNamespace(namespace).withName(name); } else if (entity instanceof ReplicaSet) { scalable = kubernetes.apps().replicaSets().inNamespace(namespace).withName(name); } else if (entity instanceof ReplicationController) { scalable = kubernetes.replicationControllers().inNamespace(namespace).withName(name); } else if (entity instanceof DeploymentConfig) { OpenShiftClient openshiftClient = OpenshiftHelper.asOpenShiftClient(kubernetes); if (openshiftClient == null) { log.warn("Ignoring DeploymentConfig %s as not connected to an OpenShift cluster", name); continue; } scalable = openshiftClient.deploymentConfigs().inNamespace(namespace).withName(name); } if (scalable != null) { log.info("Scaling " + KubernetesHelper.getKind(entity) + " " + namespace + "/" + name + " to replicas: " + replicas); scalable.scale(replicas, true); } } }
Example #13
Source File: DeploymentConfigOperationsImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
private List<RollableScalableResource<ReplicaSet, DoneableReplicaSet>> doGetLog() { List<RollableScalableResource<ReplicaSet, DoneableReplicaSet>> rcs = new ArrayList<>(); DeploymentConfig deploymentConfig = fromServer().get(); String rcUid = deploymentConfig.getMetadata().getUid(); ReplicaSetOperationsImpl rsOperations = new ReplicaSetOperationsImpl((RollingOperationContext) context); ReplicaSetList rcList = rsOperations.withLabels(deploymentConfig.getMetadata().getLabels()).list(); for (ReplicaSet rs : rcList.getItems()) { OwnerReference ownerReference = KubernetesResourceUtil.getControllerUid(rs); if (ownerReference != null && ownerReference.getUid().equals(rcUid)) { rcs.add(rsOperations.withName(rs.getMetadata().getName())); } } return rcs; }
Example #14
Source File: ReplicaSetTest.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Test public void testDeprecatedApiVersion() { io.fabric8.kubernetes.api.model.extensions.ReplicaSet repl1 = new io.fabric8.kubernetes.api.model.extensions.ReplicaSetBuilder() .withApiVersion("extensions/v1beta1") .withNewMetadata() .withName("repl1") .withNamespace("test") .endMetadata() .withNewSpec() .withReplicas(1) .withNewTemplate() .withNewMetadata().withLabels(new HashMap<String, String>()).endMetadata() .withNewSpec() .addNewContainer() .withImage("img1") .endContainer() .endSpec() .endTemplate() .endSpec() .withNewStatus().withReplicas(1).endStatus() .build(); server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/replicasets").andReturn(200, repl1).once(); KubernetesClient client = server.getClient(); client.resource(repl1).inNamespace("test").createOrReplace(); }
Example #15
Source File: ReplicaSetOperationsImpl.java From kubernetes-client with Apache License 2.0 | 5 votes |
public ReplicaSetOperationsImpl(RollingOperationContext context) { super(context.withApiGroupName("apps") .withApiGroupVersion("v1") .withPlural("replicasets")); this.type = ReplicaSet.class; this.listType = ReplicaSetList.class; this.doneableType = DoneableReplicaSet.class; }
Example #16
Source File: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Override public LogWatch watchLog(OutputStream out) { List<RollableScalableResource<ReplicaSet, DoneableReplicaSet>> podResources = doGetLog(); if (podResources.size() > 1) { throw new KubernetesClientException("Watching logs is not supported for multicontainer jobs"); } else if (podResources.size() == 1) { return podResources.get(0).watchLog(out); } return null; }
Example #17
Source File: ReplicaSetTest.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Disabled @Test public void testUpdate() { ReplicaSet repl1 = new ReplicaSetBuilder() .withNewMetadata() .withName("repl1") .withNamespace("test") .endMetadata() .withNewSpec() .withReplicas(1) .withNewTemplate() .withNewMetadata().withLabels(new HashMap<String, String>()).endMetadata() .withNewSpec() .addNewContainer() .withImage("img1") .endContainer() .endSpec() .endTemplate() .endSpec() .withNewStatus().withReplicas(1).endStatus() .build(); server.expect().withPath("/apis/apps/v1/namespaces/test/replicasets/repl1").andReturn(200, repl1).once(); server.expect().put().withPath("/apis/apps/v1/namespaces/test/replicasets/repl1").andReturn(200, repl1).once(); server.expect().get().withPath("/apis/apps/v1/namespaces/test/replicasets").andReturn(200, new ReplicaSetListBuilder().withItems(repl1).build()).once(); server.expect().post().withPath("/apis/apps/v1/namespaces/test/replicasets").andReturn(201, repl1).once(); server.expect().withPath("/apis/apps/v1/namespaces/test/pods").andReturn(200, new KubernetesListBuilder().build()).once(); KubernetesClient client = server.getClient(); repl1 = client.apps().replicaSets().withName("repl1") .rolling() .withTimeout(5, TimeUnit.MINUTES) .updateImage(""); assertNotNull(repl1); }
Example #18
Source File: ReplicaSetTest.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Test public void testScaleAndWait() { server.expect().withPath("/apis/apps/v1/namespaces/test/replicasets/repl1").andReturn(200, new ReplicaSetBuilder() .withNewMetadata() .withName("repl1") .withResourceVersion("1") .endMetadata() .withNewSpec() .withReplicas(5) .endSpec() .withNewStatus() .withReplicas(1) .endStatus() .build()).once(); server.expect().withPath("/apis/apps/v1/namespaces/test/replicasets/repl1").andReturn(200, new ReplicaSetBuilder() .withNewMetadata() .withName("repl1") .withResourceVersion("1") .endMetadata() .withNewSpec() .withReplicas(5) .endSpec() .withNewStatus() .withReplicas(5) .endStatus() .build()).always(); KubernetesClient client = server.getClient(); ReplicaSet repl = client.apps().replicaSets().withName("repl1").scale(5, true); assertNotNull(repl); assertNotNull(repl.getSpec()); assertEquals(5, repl.getSpec().getReplicas().intValue()); assertEquals(5, repl.getStatus().getReplicas().intValue()); }
Example #19
Source File: ContainerSearch.java From che with Eclipse Public License 2.0 | 5 votes |
private Stream<Container> findContainers(HasMetadata o) { // hopefully, this covers all types of objects that can contain a container if (o instanceof Pod) { return ((Pod) o).getSpec().getContainers().stream(); } else if (o instanceof PodTemplate) { return ((PodTemplate) o).getTemplate().getSpec().getContainers().stream(); } else if (o instanceof DaemonSet) { return ((DaemonSet) o).getSpec().getTemplate().getSpec().getContainers().stream(); } else if (o instanceof Deployment) { return ((Deployment) o).getSpec().getTemplate().getSpec().getContainers().stream(); } else if (o instanceof Job) { return ((Job) o).getSpec().getTemplate().getSpec().getContainers().stream(); } else if (o instanceof ReplicaSet) { return ((ReplicaSet) o).getSpec().getTemplate().getSpec().getContainers().stream(); } else if (o instanceof ReplicationController) { return ((ReplicationController) o).getSpec().getTemplate().getSpec().getContainers().stream(); } else if (o instanceof StatefulSet) { return ((StatefulSet) o).getSpec().getTemplate().getSpec().getContainers().stream(); } else if (o instanceof CronJob) { return ((CronJob) o) .getSpec() .getJobTemplate() .getSpec() .getTemplate() .getSpec() .getContainers() .stream(); } else if (o instanceof DeploymentConfig) { return ((DeploymentConfig) o).getSpec().getTemplate().getSpec().getContainers().stream(); } else if (o instanceof Template) { return ((Template) o).getObjects().stream().flatMap(this::findContainers); } else { return Stream.empty(); } }
Example #20
Source File: ReplicaSetHandlerTest.java From jkube with Eclipse Public License 2.0 | 5 votes |
@Test public void replicaSetHandlerTest() { ContainerHandler containerHandler = getContainerHandler(); PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler); ReplicaSetHandler replicaSetHandler = new ReplicaSetHandler(podTemplateHandler); ResourceConfig config = ResourceConfig.builder() .imagePullPolicy("IfNotPresent") .controllerName("testing") .serviceAccount("test-account") .replicas(5) .volumes(volumes1) .build(); ReplicaSet replicaSet = replicaSetHandler.getReplicaSet(config,images); //Assertion assertNotNull(replicaSet.getSpec()); assertNotNull(replicaSet.getMetadata()); assertEquals(5,replicaSet.getSpec().getReplicas().intValue()); assertNotNull(replicaSet.getSpec().getTemplate()); assertEquals("testing",replicaSet.getMetadata().getName()); assertEquals("test-account",replicaSet.getSpec().getTemplate() .getSpec().getServiceAccountName()); assertFalse(replicaSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty()); assertEquals("test",replicaSet.getSpec().getTemplate().getSpec(). getVolumes().get(0).getName()); assertEquals("/test/path",replicaSet.getSpec().getTemplate() .getSpec().getVolumes().get(0).getHostPath().getPath()); assertNotNull(replicaSet.getSpec().getTemplate().getSpec().getContainers()); }
Example #21
Source File: ReplicaSetRollingUpdater.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Override protected ReplicaSet createClone(ReplicaSet obj, String newName, String newDeploymentHash) { return new ReplicaSetBuilder(obj) .editMetadata() .withResourceVersion(null) .withName(newName) .endMetadata() .editSpec() .withReplicas(0) .editSelector().addToMatchLabels(DEPLOYMENT_KEY, newDeploymentHash).endSelector() .editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, newDeploymentHash).endMetadata().endTemplate() .endSpec() .build(); }
Example #22
Source File: Readiness.java From kubernetes-client with Apache License 2.0 | 5 votes |
public static boolean isReadinessApplicable(Class<? extends HasMetadata> itemClass) { return Deployment.class.isAssignableFrom(itemClass) || ReplicaSet.class.isAssignableFrom(itemClass) || Pod.class.isAssignableFrom(itemClass) || DeploymentConfig.class.isAssignableFrom(itemClass) || ReplicationController.class.isAssignableFrom(itemClass) || Endpoints.class.isAssignableFrom(itemClass) || Node.class.isAssignableFrom(itemClass) || StatefulSet.class.isAssignableFrom(itemClass) ; }
Example #23
Source File: Readiness.java From kubernetes-client with Apache License 2.0 | 5 votes |
public static boolean isReplicaSetReady(ReplicaSet r) { Utils.checkNotNull(r, "ReplicationController can't be null."); ReplicaSetSpec spec = r.getSpec(); ReplicaSetStatus status = r.getStatus(); if (status == null || status.getReadyReplicas() == null) { return false; } //Can be true in testing, so handle it to make test writing easier. if (spec == null || spec.getReplicas() == null) { return false; } return spec.getReplicas().intValue() == status.getReadyReplicas(); }
Example #24
Source File: ReplicaSetIT.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Test public void load() { String currentNamespace = session.getNamespace(); ReplicaSet replicaSet = client.apps().replicaSets().inNamespace(currentNamespace) .load(getClass().getResourceAsStream("/test-replicaset.yml")).get(); assertThat(replicaSet).isNotNull(); assertEquals("frontend", replicaSet.getMetadata().getName()); }
Example #25
Source File: ReplicaSetIT.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Test public void update() { ReadyEntity<ReplicaSet> replicaSetReady = new ReadyEntity<>(ReplicaSet.class, client, "replicaset1", currentNamespace); await().atMost(30, TimeUnit.SECONDS).until(replicaSetReady); replicaset1 = client.apps().replicaSets().inNamespace(currentNamespace).withName("replicaset1").edit() .editSpec().withReplicas(2).endSpec().done(); assertThat(replicaset1).isNotNull(); assertEquals(2, replicaset1.getSpec().getReplicas().intValue()); }
Example #26
Source File: ReplicaSetIT.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Test public void delete() { ReadyEntity<ReplicaSet> replicaSetReady = new ReadyEntity<>(ReplicaSet.class, client, "replicaset1", currentNamespace); await().atMost(30, TimeUnit.SECONDS).until(replicaSetReady); boolean bDeleted = client.apps().replicaSets().inNamespace(currentNamespace).withName("replicaset1").delete(); assertTrue(bDeleted); }
Example #27
Source File: ReplicaSetIT.java From kubernetes-client with Apache License 2.0 | 5 votes |
@After public void cleanup() throws InterruptedException { if (client.apps().replicaSets().inNamespace(currentNamespace).list().getItems().size()!= 0) { client.apps().replicaSets().inNamespace(currentNamespace).delete(); } // Wait for resources to get destroyed DeleteEntity<ReplicaSet> replicaSetDelete = new DeleteEntity<>(ReplicaSet.class, client, "replicaset1", currentNamespace); await().atMost(30, TimeUnit.SECONDS).until(replicaSetDelete); }
Example #28
Source File: DeploymentConfigOperationsImpl.java From kubernetes-client with Apache License 2.0 | 5 votes |
public String getLog(Boolean isPretty) { StringBuilder stringBuilder = new StringBuilder(); List<RollableScalableResource<ReplicaSet, DoneableReplicaSet>> rcList = doGetLog(); for (RollableScalableResource<ReplicaSet, DoneableReplicaSet> rcOperation : rcList) { stringBuilder.append(rcOperation.getLog(isPretty)); } return stringBuilder.toString(); }
Example #29
Source File: DeploymentConfigOperationsImpl.java From kubernetes-client with Apache License 2.0 | 5 votes |
/** * Returns an unclosed Reader. It's the caller responsibility to close it. * @return Reader */ @Override public Reader getLogReader() { List<RollableScalableResource<ReplicaSet, DoneableReplicaSet>> podResources = doGetLog(); if (podResources.size() > 1) { throw new KubernetesClientException("Reading logs is not supported for multicontainer jobs"); } else if (podResources.size() == 1) { return podResources.get(0).getLogReader(); } return null; }
Example #30
Source File: DeploymentConfigOperationsImpl.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Override public LogWatch watchLog(OutputStream out) { List<RollableScalableResource<ReplicaSet, DoneableReplicaSet>> podResources = doGetLog(); if (podResources.size() > 1) { throw new KubernetesClientException("Watching logs is not supported for multicontainer jobs"); } else if (podResources.size() == 1) { return podResources.get(0).watchLog(out); } return null; }