use of io.kubernetes.client.openapi.models.V1DeleteOptions in project pravega by pravega.
the class K8sClient method deleteCustomObject.
/**
* Delete Custom Object for a given resource group.
* @param customResourceGroup Custom resource group.
* @param version Version.
* @param namespace Namespace.
* @param plural Plural of the CRD.
* @param name Name of the object.
* @return Future which completes once the delete request is accepted.
*/
@SneakyThrows(ApiException.class)
public CompletableFuture<Object> deleteCustomObject(String customResourceGroup, String version, String namespace, String plural, String name) {
CustomObjectsApi api = new CustomObjectsApi();
V1DeleteOptions options = new V1DeleteOptions();
options.setOrphanDependents(false);
K8AsyncCallback<Object> callback = new K8AsyncCallback<>("getCustomObject-" + customResourceGroup);
api.deleteNamespacedCustomObjectAsync(customResourceGroup, version, namespace, plural, name, 0, false, null, options, callback);
return callback.getFuture();
}
use of io.kubernetes.client.openapi.models.V1DeleteOptions in project java by kubernetes-client.
the class YamlExample method main.
public static void main(String[] args) throws IOException, ApiException, ClassNotFoundException {
V1Pod pod = new V1PodBuilder().withNewMetadata().withName("apod").endMetadata().withNewSpec().addNewContainer().withName("www").withImage("nginx").withNewResources().withLimits(new HashMap<>()).endResources().endContainer().endSpec().build();
System.out.println(Yaml.dump(pod));
V1Service svc = new V1ServiceBuilder().withNewMetadata().withName("aservice").endMetadata().withNewSpec().withSessionAffinity(V1ServiceSpec.SessionAffinityEnum.CLIENTIP).withType(V1ServiceSpec.TypeEnum.NODEPORT).addNewPort().withProtocol(V1ServicePort.ProtocolEnum.TCP).withName("client").withPort(8008).withNodePort(8080).withTargetPort(new IntOrString(8080)).endPort().endSpec().build();
System.out.println(Yaml.dump(svc));
// Read yaml configuration file, and deploy it
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
// See issue #474. Not needed at most cases, but it is needed if you are using war
// packging or running this on JUnit.
Yaml.addModelMap("v1", "Service", V1Service.class);
// Example yaml file can be found in $REPO_DIR/test-svc.yaml
File file = new File("test-svc.yaml");
V1Service yamlSvc = (V1Service) Yaml.load(file);
// Deployment and StatefulSet is defined in apps/v1, so you should use AppsV1Api instead of
// CoreV1API
CoreV1Api api = new CoreV1Api();
V1Service createResult = api.createNamespacedService("default", yamlSvc, null, null, null, null);
System.out.println(createResult);
V1Service deleteResult = api.deleteNamespacedService(yamlSvc.getMetadata().getName(), "default", null, null, null, null, null, new V1DeleteOptions());
System.out.println(deleteResult);
}
Aggregations