How to use the @kubernetes/client-node.V1DeleteOptions function in @kubernetes/client-node

To help you get started, we’ve selected a few @kubernetes/client-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sandstorm / metacontroller-framework / src / index.ts View on Github external
validateKubernetesResources(singleOperatorName) {
            // 1) Delete/Create Namespace. NOTE: for some reason, we need to do this using the Kubectl Command Line;
            //    as I was not able to wait on the deleted namespace using the Kubernetes JS client.
            execSync("kubectl delete namespace metacontroller-dev || echo 'Namespace does not exist'", { stdio: 'inherit' });
            execSync("kubectl create namespace metacontroller-dev", { stdio: 'inherit' });

            const kc = new k8s.KubeConfig();
            kc.loadFromDefault();
            const k8sApi_apiExtensions = kc.makeApiClient(k8s.Apiextensions_v1beta1Api);
            const k8sApi_customObjects = kc.makeApiClient(k8s.Custom_objectsApi);
            const d = new k8s.V1DeleteOptions();
            d.propagationPolicy = 'Foreground';
            d.gracePeriodSeconds = 0;

            let nextPromise = Promise.resolve();
            args.operators.forEach(operatorDefinition => {
                if (singleOperatorName !== true && operatorDefinition.key !== singleOperatorName) {
                    console.log(`\n\nOPERATOR ${operatorDefinition.key}\n  - skipping`);
                    return;
                }
                const crd = YAML.parse(loadCustomResourceDefinition(operatorDefinition));
                crd.metadata.name += ".dev";
                crd.spec.group += ".dev";

                nextPromise = nextPromise
                    .then(() => console.log(`\n\nOPERATOR ${operatorDefinition.key}`))
                    // 2) Delete/Create "DEV" CRDs
github brigadecore / brigade / brigade-worker / src / k8s.ts View on Github external
clearTimers();
          reject(new Error(`Pod ${name} failed to run to completion`));
        } else if (phase == "Pending") {
          // Trap image pull errors and consider them fatal.
          let cs = this.pod.status.containerStatuses;
          if (
            cs &&
            cs.length > 0 &&
            cs[0].state.waiting &&
            cs[0].state.waiting.reason == "ErrImagePull"
          ) {
            k.deleteNamespacedPod(
              name,
              ns,
              "true",
              new kubernetes.V1DeleteOptions()
            ).catch(e => this.logger.error(e.body.message));
            clearTimers();
            reject(new Error(cs[0].state.waiting.message));
          }
        }
        if (!this.job.streamLogs || (this.job.streamLogs && this.pod.status.phase != "Running")) {
          // don't display "Running" when we're asked to display job Pod logs
          this.logger.log(`${this.pod.metadata.namespace}/${this.pod.metadata.name} phase ${this.pod.status.phase}`);
        }
        // In all other cases we fall through and let the fn be run again.
      };
      let interval = setInterval(() => {
github brigadecore / brigade / brigade-worker / src / k8s.ts View on Github external
public destroy(): Promise {
    if (!this.proj && !this.name) {
      this.logger.log("Build storage not exists");
      return Promise.resolve(false);
    }

    this.logger.log(`Destroying PVC named ${this.name}`);
    let opts = new kubernetes.V1DeleteOptions();
    return Promise.resolve(
      defaultClient
        .deleteNamespacedPersistentVolumeClaim(
          this.name,
          this.proj.kubernetes.namespace,
          "true",
          opts
        )
        .then(() => {
          return true;
        })
    );
  }
  /**
github che-incubator / chectl / src / api / kube.ts View on Github external
async deleteAllServices(namespace = '') {
    const k8sApi = this.kc.makeApiClient(CoreV1Api)
    try {
      const res = await k8sApi.listNamespacedService(namespace, true)
      if (res && res.response && res.response.statusCode === 200) {
        const serviceList = res.body
        const options = new V1DeleteOptions()
        await serviceList.items.forEach(async service => {
          await k8sApi.deleteNamespacedService(service.metadata!.name!, namespace, undefined, options)
        })
      }
    } catch (e) {
      throw this.wrapK8sClientError(e)
    }
  }
github kubeflow / pipelines / frontend / server / k8s-helper.ts View on Github external
export async function deleteTensorboardInstance(logdir: string): Promise {
  if (!k8sV1CustomObjectClient) {
    throw new Error('Cannot access kubernetes Custom Object API');
  }
  const currentPod = await getTensorboardInstance(logdir);
  if (!currentPod.podAddress) {
    return;
  }

  const viewerName = getNameOfViewerResource(logdir);
  const deleteOption = new V1DeleteOptions();

  await k8sV1CustomObjectClient.deleteNamespacedCustomObject(
    viewerGroup,
    viewerVersion,
    namespace,
    viewerPlural,
    viewerName,
    deleteOption,
  );
}
github che-incubator / chectl / src / api / kube.ts View on Github external
async deleteClusterRole(name = '') {
    const k8sCoreApi = this.kc.makeApiClient(RbacAuthorizationV1Api)
    try {
      const options = new V1DeleteOptions()
      await k8sCoreApi.deleteClusterRole(name, undefined, options)
    } catch (e) {
      throw this.wrapK8sClientError(e)
    }
  }
github che-incubator / chectl / src / api / kube.ts View on Github external
async deleteClusterRoleBinding(name = '') {
    const k8sRbacAuthApi = this.kc.makeApiClient(RbacAuthorizationV1Api)
    try {
      const options = new V1DeleteOptions()
      return await k8sRbacAuthApi.deleteClusterRoleBinding(name, undefined, options)
    } catch (e) {
      throw this.wrapK8sClientError(e)
    }
  }
github che-incubator / chectl / src / api / kube.ts View on Github external
async deletePod(name: string, namespace = '') {
    this.kc.loadFromDefault()
    const k8sCoreApi = this.kc.makeApiClient(CoreV1Api)
    const options = new V1DeleteOptions()
    try {
      return await k8sCoreApi.deleteNamespacedPod(name, namespace, undefined, options)
    } catch (e) {
      throw this.wrapK8sClientError(e)
    }
  }
github che-incubator / chectl / src / api / kube.ts View on Github external
async deleteRole(name = '', namespace = '') {
    const k8sCoreApi = this.kc.makeApiClient(RbacAuthorizationV1Api)
    try {
      const options = new V1DeleteOptions()
      await k8sCoreApi.deleteNamespacedRole(name, namespace, undefined, options)
    } catch (e) {
      throw this.wrapK8sClientError(e)
    }
  }
github che-incubator / chectl / src / api / kube.ts View on Github external
async deleteCheCluster(name = '', namespace = '') {
    const customObjectsApi = this.kc.makeApiClient(CustomObjectsApi)
    try {
      const options = new V1DeleteOptions()
      await customObjectsApi.deleteNamespacedCustomObject('org.eclipse.che', 'v1', namespace, 'checlusters', name, options)
    } catch (e) {
      throw this.wrapK8sClientError(e)
    }
  }