io.fabric8.kubernetes.api.model.DeletionPropagation Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.DeletionPropagation.
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: NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl(OkHttpClient client, Config config, String namespace, String explicitNamespace, Boolean fromServer, Boolean deletingExisting, List<Visitor> visitors, Object item, InputStream inputStream, Map<String, String> parameters, long gracePeriodSeconds, DeletionPropagation propagationPolicy, Boolean cascading, long watchRetryInitialBackoffMillis, double watchRetryBackoffMultiplier) { super(client, config); this.fallbackNamespace = namespace; this.explicitNamespace = explicitNamespace; this.fromServer = fromServer; this.deletingExisting = deletingExisting; this.visitors = visitors != null ? new ArrayList<>(visitors) : new ArrayList<>(); this.watchRetryInitialBackoffMillis = watchRetryInitialBackoffMillis; this.watchRetryBackoffMultiplier = watchRetryBackoffMultiplier; if (item != null) { this.item = item; } else if (inputStream != null) { this.item = Serialization.unmarshal(inputStream, parameters); } else { throw new IllegalArgumentException("Need to either specify an Object or an InputStream."); } this.inputStream = inputStream; this.cascading = cascading; this.gracePeriodSeconds = gracePeriodSeconds; this.propagationPolicy = propagationPolicy; this.visitors.add(new ChangeNamespace(explicitNamespace, fallbackNamespace)); }
Example #2
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Service with PropagationPolicy=Background") void testDeleteSecret() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/secrets/mysecret") .andReturn(HttpURLConnection.HTTP_OK, new SecretBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.secrets().inNamespace("ns1").withName("mysecret").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #3
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Service with specified PropagationPolicy") void testDeleteServiceWithPropagationPolicy() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/services/myservice") .andReturn(HttpURLConnection.HTTP_OK, new ServiceBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.services().inNamespace("ns1").withName("myservice").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #4
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Secret with specified PropagationPolicy") void testDeleteSecretWithExplicitPropagationPolicy() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/secrets/mysecret") .andReturn(HttpURLConnection.HTTP_OK, new SecretBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.secrets().inNamespace("ns1").withName("mysecret").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest()); }
Example #5
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Deployment with PropagationPolicy=Background") void testDeleteDeployment() throws InterruptedException { // Given server.expect().delete().withPath("/apis/apps/v1/namespaces/ns1/deployments/mydeployment") .andReturn(HttpURLConnection.HTTP_OK, new DeploymentBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.apps().deployments().inNamespace("ns1").withName("mydeployment").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #6
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Service with PropagationPolicy=Background") void testDeleteService() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/services/myservice") .andReturn(HttpURLConnection.HTTP_OK, new ServiceBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.services().inNamespace("ns1").withName("myservice").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #7
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a ConfigMap with specified PropagationPolicy") void testDeleteConfigMapWithExplicitPropagationPolicy() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/configmaps/myconfigMap") .andReturn(HttpURLConnection.HTTP_OK, new ConfigMapBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.configMaps().inNamespace("ns1").withName("myconfigMap").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest()); }
Example #8
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a ConfigMap with PropagationPolicy=Background") void testDeleteConfigMap() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/configmaps/myconfigMap") .andReturn(HttpURLConnection.HTTP_OK, new ConfigMapBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.configMaps().inNamespace("ns1").withName("myconfigMap").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #9
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@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(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.apps().statefulSets().inNamespace("ns1").withName("mystatefulset").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #10
Source File: BuildOperationContext.java From kubernetes-client with Apache License 2.0 | 6 votes |
public BuildOperationContext(OkHttpClient client, Config config, String plural, String namespace, String name, String apiGroupName, String apiGroupVersion, Boolean cascading, Object item, Map<String, String> labels, Map<String, String[]> labelsNot, Map<String, String[]> labelsIn, Map<String, String[]> labelsNotIn, Map<String, String> fields, Map<String, String[]> fieldsNot,String resourceVersion, Boolean reloadingFromServer, long gracePeriodSeconds, DeletionPropagation propagationPolicy, long watchRetryInitialBackoffMillis, double watchRetryBackoffMultiplier, InputStream in, OutputStream out, OutputStream err, PipedOutputStream inPipe, PipedInputStream outPipe, PipedInputStream errPipe, Boolean tty, Boolean terminatedStatus, Boolean timestamps, String sinceTimestamp, Integer sinceSeconds, Integer tailingLines, Boolean prettyOutput, Integer limitBytes, String version) { super(client, config, plural, namespace, name, apiGroupName, apiGroupVersion, cascading, item, labels, labelsNot, labelsIn, labelsNotIn, fields, fieldsNot,resourceVersion, reloadingFromServer, gracePeriodSeconds, propagationPolicy, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier); this.in = in; this.out = out; this.err = err; this.inPipe = inPipe; this.outPipe = outPipe; this.errPipe = errPipe; this.tty = tty; this.terminatedStatus = terminatedStatus; this.timestamps = timestamps; this.sinceTimestamp = sinceTimestamp; this.sinceSeconds = sinceSeconds; this.tailingLines = tailingLines; this.prettyOutput = prettyOutput; this.limitBytes = limitBytes; this.version = version; }
Example #11
Source File: GroupTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testDeleteWithPropagationPolicy() { server.expect().withPath("/apis/user.openshift.io/v1/groups/group1").andReturn(200, new GroupBuilder().build()).once(); server.expect().withPath("/apis/user.openshift.io/v1/groups/Group2").andReturn( 200, new GroupBuilder().build()).once(); OpenShiftClient client = server.getOpenshiftClient(); Boolean deleted = client.groups().withName("group1").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); assertNotNull(deleted); deleted = client.groups().withName("Group2").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); assertTrue(deleted); deleted = client.groups().withName("Group3").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); assertFalse(deleted); }
Example #12
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Deployment with explicitly set PropagationPolicy") void testDeleteDeploymentWithExplicitPropagationPolicy() throws InterruptedException { // Given server.expect().delete().withPath("/apis/apps/v1/namespaces/ns1/deployments/mydeployment") .andReturn(HttpURLConnection.HTTP_OK, new DeploymentBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.apps().deployments().inNamespace("ns1").withName("mydeployment").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest()); }
Example #13
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a StatefulSet with explicitly set PropagationPolicy") void testDeleteStatefulSetWithExplicitPropagationPolicy() throws InterruptedException { // Given server.expect().delete().withPath("/apis/apps/v1/namespaces/ns1/statefulsets/mystatefulset") .andReturn(HttpURLConnection.HTTP_OK, new StatefulSetBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.apps().statefulSets().inNamespace("ns1").withName("mystatefulset").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest()); }
Example #14
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a ReplicationController with PropagationPolicy=Background") void testDeleteReplicationController() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/replicationcontrollers/myreplicationcontroller") .andReturn(HttpURLConnection.HTTP_OK, new ReplicationControllerBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.replicationControllers().inNamespace("ns1").withName("myreplicationcontroller").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #15
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a ReplicationController with explicitly specified PropagationPolicy") void testDeleteReplicationControllerWithExplicitPropagationPolicy() throws InterruptedException { // Given server.expect().delete().withPath("/api/v1/namespaces/ns1/replicationcontrollers/myreplicationcontroller") .andReturn(HttpURLConnection.HTTP_OK, new ReplicationControllerBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.replicationControllers().inNamespace("ns1").withName("myreplicationcontroller").withPropagationPolicy(DeletionPropagation.ORPHAN).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.ORPHAN.toString(), server.getLastRequest()); }
Example #16
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Job with PropagationPolicy=Background") void testDeleteJob() throws InterruptedException { // Given server.expect().delete().withPath("/apis/batch/v1/namespaces/ns1/jobs/myjob") .andReturn(HttpURLConnection.HTTP_OK, new JobBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.batch().jobs().inNamespace("ns1").withName("myjob").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #17
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Job with explicitly set PropagationPolicy") void testDeleteJobWithExplicitPropagationPolicy() throws InterruptedException { // Given server.expect().delete().withPath("/apis/batch/v1/namespaces/ns1/jobs/myjob") .andReturn(HttpURLConnection.HTTP_OK, new JobBuilder().build()) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.batch().jobs().inNamespace("ns1").withName("myjob").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest()); }
Example #18
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a resource with PropagationPolicy=Background") void testDeleteResource() throws InterruptedException { // Given Pod testPod = new PodBuilder().withNewMetadata().withName("testpod").endMetadata().build(); server.expect().delete().withPath("/api/v1/namespaces/foo/pods/testpod") .andReturn(HttpURLConnection.HTTP_OK, testPod) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.resource(testPod).inNamespace("foo").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #19
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a resource with specified PropagationPolicy") void testDeleteResourceWithSpecifiedPropagationPolicy() throws InterruptedException { // Given Pod testPod = new PodBuilder().withNewMetadata().withName("testpod").endMetadata().build(); server.expect().delete().withPath("/api/v1/namespaces/foo/pods/testpod") .andReturn(HttpURLConnection.HTTP_OK, testPod) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.resource(testPod).inNamespace("foo").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest()); }
Example #20
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a resource list with PropagationPolicy=Background") void testDeleteResourceList() throws InterruptedException { // Given Pod testPod = new PodBuilder().withNewMetadata().withName("testpod").endMetadata().build(); server.expect().delete().withPath("/api/v1/namespaces/foo/pods/testpod") .andReturn(HttpURLConnection.HTTP_OK, testPod) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.resourceList(new KubernetesListBuilder().withItems(testPod).build()).inNamespace("foo").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #21
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a resource list with specified PropagationPolicy") void testDeleteResourceListWithSpecifiedPropagationPolicy() throws InterruptedException { // Given Pod testPod = new PodBuilder().withNewMetadata().withName("testpod").endMetadata().build(); server.expect().delete().withPath("/api/v1/namespaces/foo/pods/testpod") .andReturn(HttpURLConnection.HTTP_OK, testPod) .once(); KubernetesClient client = server.getClient(); // When Boolean isDeleted = client.resourceList(new KubernetesListBuilder().withItems(testPod).build()).inNamespace("foo").withPropagationPolicy(DeletionPropagation.FOREGROUND).delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.FOREGROUND.toString(), server.getLastRequest()); }
Example #22
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Custom Resource with PropagationPolicy=Background") void testDeleteCustomResource() throws InterruptedException { // Given server.expect().delete().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets/example-podset").andReturn(HttpURLConnection.HTTP_OK, new PodSet()).once(); MixedOperation<PodSet, PodSetList, DoneablePodSet, Resource<PodSet, DoneablePodSet>> podSetClient = server.getClient().customResources(new CustomResourceDefinitionBuilder() .withNewMetadata().withName("podsets.demo.k8s.io").endMetadata() .withNewSpec() .withGroup("demo.k8s.io") .withVersion("v1alpha1") .withNewNames().withKind("PodSet").withPlural("podsets").endNames() .withScope("Namespaced") .endSpec() .build(), PodSet.class, PodSetList.class, DoneablePodSet.class); // When boolean isDeleted = podSetClient.inNamespace("test").withName("example-podset").delete(); // Then assertTrue(isDeleted); assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #23
Source File: OperationContext.java From kubernetes-client with Apache License 2.0 | 6 votes |
public OperationContext(OkHttpClient client, Config config, String plural, String namespace, String name, String apiGroupName, String apiGroupVersion, boolean cascading, Object item, Map<String, String> labels, Map<String, String[]> labelsNot, Map<String, String[]> labelsIn, Map<String, String[]> labelsNotIn, Map<String, String> fields, Map<String, String[]> fieldsNot, String resourceVersion, boolean reloadingFromServer, long gracePeriodSeconds, DeletionPropagation propagationPolicy, long watchRetryInitialBackoffMillis, double watchRetryBackoffMultiplier) { this.client = client; this.config = config; this.plural = plural; this.namespace = Utils.isNotNullOrEmpty(namespace) ? namespace : (config != null ? config.getNamespace() : null); this.name = name; this.cascading = cascading; this.labels = labels != null ? labels : new HashMap<>(); this.labelsNot = labelsNot != null ? labelsNot : new HashMap<>(); this.labelsIn = labelsIn != null ? labelsIn : new HashMap<>(); this.labelsNotIn = labelsNotIn != null ? labelsNotIn : new HashMap<>(); this.fields = fields != null ? fields : new HashMap<>(); this.fieldsNot = fieldsNot != null ? fieldsNot : new HashMap<>(); this.resourceVersion = resourceVersion; this.reloadingFromServer = reloadingFromServer; this.gracePeriodSeconds = gracePeriodSeconds; this.propagationPolicy = propagationPolicy; this.watchRetryInitialBackoffMillis = watchRetryInitialBackoffMillis; this.watchRetryBackoffMultiplier = watchRetryBackoffMultiplier; this.item = item; this.apiGroupName = ApiVersionUtil.apiGroup(item, apiGroupName); this.apiGroupVersion = ApiVersionUtil.apiVersion(item, apiGroupVersion); }
Example #24
Source File: ResourceIT.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testDeletionWithoutOrphanDeletion() throws InterruptedException { // Create Deployment client.resource(deployment).inNamespace(currentNamespace).createOrReplace(); await().atMost(30, TimeUnit.SECONDS).until(resourceIsReady(deployment)); // Check whether child resources are also created assertEquals(1, client.apps().replicaSets().inNamespace(currentNamespace).withLabel("run", "deploy1").list().getItems().size()); // Delete deployment Boolean deleted = client.resource(deployment).inNamespace(currentNamespace).withPropagationPolicy(DeletionPropagation.ORPHAN).delete(); assertTrue(deleted); // wait till deployment is deleted await().atMost(30, TimeUnit.SECONDS) .until(() -> client.apps().deployments().inNamespace(currentNamespace).withLabel("run", "deploy1").list().getItems().size() == 0); // Check whether child resources are not deleted, they should be alive assertEquals(1, client.apps().replicaSets().inNamespace(currentNamespace).withLabel("run", "deploy1").list().getItems().size()); // cleanup resources which are not cleaned up during cascade deletion client.apps().replicaSets().inNamespace(currentNamespace).withLabel("run", "deploy1").delete(); }
Example #25
Source File: OperationSupport.java From kubernetes-client with Apache License 2.0 | 6 votes |
protected void handleDelete(URL requestUrl, long gracePeriodSeconds, DeletionPropagation propagationPolicy, boolean cascading) throws ExecutionException, InterruptedException, IOException { RequestBody requestBody = null; DeleteOptions deleteOptions = new DeleteOptions(); if (gracePeriodSeconds >= 0) { deleteOptions.setGracePeriodSeconds(gracePeriodSeconds); } /* * Either the propagation policy or the orphan dependent (deprecated) property must be set, but not both. */ if (propagationPolicy != null) { deleteOptions.setPropagationPolicy(propagationPolicy.toString()); } else { deleteOptions.setOrphanDependents(!cascading); } requestBody = RequestBody.create(JSON, JSON_MAPPER.writeValueAsString(deleteOptions)); Request.Builder requestBuilder = new Request.Builder().delete(requestBody).url(requestUrl); handleResponse(requestBuilder, null, Collections.<String, String>emptyMap()); }
Example #26
Source File: PodOperationContext.java From kubernetes-client with Apache License 2.0 | 6 votes |
public PodOperationContext(OkHttpClient client, Config config, String plural, String namespace, String name, String apiGroupName, String apiGroupVersion, boolean cascading, Object item, Map<String, String> labels, Map<String, String[]> labelsNot, Map<String, String[]> labelsIn, Map<String, String[]> labelsNotIn, Map<String, String> fields, Map<String, String[]> fieldsNot, String resourceVersion, boolean reloadingFromServer, long gracePeriodSeconds, DeletionPropagation propagationPolicy, long watchRetryInitialBackoffMillis, double watchRetryBackoffMultiplier, String containerId, InputStream in, OutputStream out, OutputStream err, OutputStream errChannel, PipedOutputStream inPipe, PipedInputStream outPipe, PipedInputStream errPipe, PipedInputStream errChannelPipe, Boolean tty, Boolean terminatedStatus, Boolean timestampes, String sinceTimestamp, Integer sinceSeconds, Integer tailingLines, Boolean prettyOutput, Integer limitBytes, Integer bufferSize, ExecListener execListener, String file, String dir) { super(client, config, plural, namespace, name, apiGroupName, apiGroupVersion, cascading, item, labels, labelsNot, labelsIn, labelsNotIn, fields, fieldsNot, resourceVersion, reloadingFromServer, gracePeriodSeconds, propagationPolicy, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier); this.containerId = containerId; this.in = in; this.out = out; this.err = err; this.errChannel = errChannel; this.inPipe = inPipe; this.outPipe = outPipe; this.errPipe = errPipe; this.errChannelPipe = errChannelPipe; this.tty = tty; this.terminatedStatus = terminatedStatus; this.timestamps = timestampes; this.sinceTimestamp = sinceTimestamp; this.sinceSeconds = sinceSeconds; this.tailingLines = tailingLines; this.prettyOutput = prettyOutput; this.execListener = execListener; this.limitBytes = limitBytes; this.bufferSize = bufferSize; this.file = file; this.dir = dir; }
Example #27
Source File: ResourceIT.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testDeletionWithOrphanDeletion() throws InterruptedException { // Create Deployment client.resource(deployment).inNamespace(currentNamespace).createOrReplace(); await().atMost(30, TimeUnit.SECONDS).until(resourceIsReady(deployment)); // Check whether child resources are also created assertEquals(1, client.apps().replicaSets().inNamespace(currentNamespace).withLabel("run", "deploy1").list().getItems().size()); // Delete deployment Boolean deleted = client.resource(deployment).inNamespace(currentNamespace).withPropagationPolicy(DeletionPropagation.BACKGROUND).delete(); assertTrue(deleted); // Check whether child resources are also deleted await().atMost(30, TimeUnit.SECONDS) .until(() -> client.apps().replicaSets().inNamespace(currentNamespace).withLabel("run", "deploy1").list().getItems().size() == 0); }
Example #28
Source File: NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl.java From kubernetes-client with Apache License 2.0 | 6 votes |
public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl(OkHttpClient client, Config config, String namespace, String explicitNamespace, Boolean fromServer, Boolean deletingExisting, List<Visitor> visitors, Object item, long gracePeriodSeconds, DeletionPropagation propagationPolicy, Boolean cascading, long watchRetryInitialBackoffMillis, double watchRetryBackoffMultiplier) { super(client, config); this.fallbackNamespace = namespace; this.explicitNamespace = explicitNamespace; this.fromServer = fromServer; this.deletingExisting = deletingExisting; this.visitors = visitors != null ? new ArrayList<>(visitors) : new ArrayList<Visitor>(); this.item = item; this.handler = handlerOf(item); this.cascading = cascading; this.watchRetryInitialBackoffMillis = watchRetryInitialBackoffMillis; this.watchRetryBackoffMultiplier = watchRetryBackoffMultiplier; if (handler == null) { throw new KubernetesClientException("No handler found for object:" + item); } this.gracePeriodSeconds = gracePeriodSeconds; this.propagationPolicy = propagationPolicy; this.visitors.add(new ChangeNamespace(explicitNamespace, fallbackNamespace)); }
Example #29
Source File: PropagationPolicyTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test @DisplayName("Should delete a Raw Custom Resource with PropagationPolicy=Background") void testDeleteRawCustomResource() throws InterruptedException, IOException { // Given server.expect().delete().withPath("/apis/test.fabric8.io/v1alpha1/namespaces/ns1/hellos/example-hello") .andReturn(HttpURLConnection.HTTP_OK, "{\"metadata\":{},\"apiVersion\":\"v1\",\"kind\":\"Status\",\"details\":{\"name\":\"prometheus-example-rules\",\"group\":\"monitoring.coreos.com\",\"kind\":\"prometheusrules\",\"uid\":\"b3d085bd-6a5c-11e9-8787-525400b18c1d\"},\"status\":\"Success\"}").once(); KubernetesClient client = server.getClient(); // When Map<String, Object> result = client.customResource(new CustomResourceDefinitionContext.Builder() .withGroup("test.fabric8.io") .withName("hellos.test.fabric8.io") .withPlural("hellos") .withScope("Namespaced") .withVersion("v1alpha1") .build()) .delete("ns1", "example-hello"); // Then assertDeleteOptionsInLastRecordedRequest(DeletionPropagation.BACKGROUND.toString(), server.getLastRequest()); }
Example #30
Source File: ServiceTest.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Test @DisplayName("Should delete with PropagationPolicy=Orphan") void testDeleteOrphan() throws InterruptedException { server.expect().delete().withPath("/apis/serving.knative.dev/v1/namespaces/ns3/services/service3") .andReturn(HttpURLConnection.HTTP_OK, new ServiceBuilder().build()) .once(); KnativeClient client = server.getKnativeClient(); Boolean deleted = client.services().inNamespace("ns3").withName("service3").withPropagationPolicy(DeletionPropagation.ORPHAN).delete(); assertTrue(deleted); RecordedRequest recordedRequest = server.getMockServer().takeRequest(); assertEquals("{\"apiVersion\":\"v1\",\"kind\":\"DeleteOptions\",\"propagationPolicy\":\"Orphan\"}", recordedRequest.getBody().readUtf8()); }