@topgroup/diginext
Version:
A BUILD SERVER & CLI to deploy apps to any Kubernetes clusters.
339 lines • 14.8 kB
TypeScript
import type { V1PersistentVolume, V1PersistentVolumeClaim, V1StorageClass } from "@kubernetes/client-node";
import type { KubeDeployment, KubeIngress, KubeNamespace, KubeSecret, KubeService, KubeStatefulSet } from "../../interfaces";
import type { KubeEnvironmentVariable } from "../../interfaces/EnvironmentVariable";
import type { KubeIngressClass } from "../../interfaces/KubeIngressClass";
import type { KubeNode } from "../../interfaces/KubeNode";
import type { KubePod } from "../../interfaces/KubePod";
interface KubeGenericOptions {
/**
* Output type (JSON or YAML)
* @default "json"
*/
output?: "json" | "yaml";
/**
* A context name in KUBECONFIG
*/
context?: string;
/**
* Should skip when error?
* @default false
*/
skipOnError?: boolean;
/**
* Debug
*/
isDebugging?: boolean;
}
interface KubeCommandOptions extends KubeGenericOptions {
/**
* Filter resources by label
* @example "phase!=prerelease,app=abc-xyz"
*/
filterLabel?: string;
}
/**
* Convert filter object to filter labels string
* - Use ! for different than value
* @example { phase: "!prerelease", app: "abc-xyz" } -> "phase!=prerelease,app=abc-xyz"
*/
export declare function objectToFilterLabels(obj: Record<string, string>): string;
/**
* Similar to `kubectl apply -f deployment.yaml`
* @param filePath - Path to Kubernetes YAML file or URL of Kubernetes YAML file
* @param namespace - Target namespace of the cluster
* @param options - kubectl command options
* @returns
*/
export declare function kubectlApply(filePath: string, options?: KubeGenericOptions): Promise<string>;
export declare function kubectlApplyContent(yamlContent: string, options?: KubeCommandOptions): Promise<string>;
export interface NodeUsage {
name: string;
cpu: string;
cpuPercent: string;
cpuCapacity: string;
memory: string;
memoryPercent: string;
memoryCapacity: string;
}
/**
* Get all nodes of a cluster
*/
export declare function getAllNodes(options?: KubeCommandOptions): Promise<KubeNode[]>;
/**
* Get all namepsaces of a cluster
*/
export declare function getAllNamespaces(options?: KubeCommandOptions): Promise<KubeNamespace[]>;
/**
* Get a namepsace of a cluster
*/
export declare function getNamespace(name: string, options?: KubeCommandOptions): Promise<string | KubeNamespace>;
/**
* Create new namespace of a cluster
*/
export declare function createNamespace(namespace: string, options?: KubeGenericOptions): Promise<{
name: string;
}>;
/**
* Delete a namespace of a cluster
*/
export declare function deleteNamespace(namespace: string, options?: KubeCommandOptions): Promise<{
namespace: string;
}>;
/**
* Delete a namespace of a cluster
*/
export declare function deleteNamespaceByCluster(namespace: string, clusterSlug: string): Promise<{
namespace: string;
}>;
/**
* Check whether this namespace was existed
*/
export declare function isNamespaceExisted(namespace: string, options?: KubeCommandOptions): Promise<boolean>;
/**
* Get all secrets of a namespace
*/
export declare function getSecrets(namespace?: string, options?: KubeCommandOptions): Promise<KubeSecret[]>;
/**
* Get all secrets of a cluster
*/
export declare function getAllSecrets(options?: KubeCommandOptions): Promise<KubeSecret[]>;
/**
* Check whether this secret was existed in the namespace
*/
export declare function isSecretExisted(name: string, namespace?: string, options?: KubeCommandOptions): Promise<boolean>;
/**
* Delete a secret in a namespace
*/
export declare function deleteSecret(name: any, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Delete secrets in a namespace by filter
*/
export declare function deleteSecretsByFilter(namespace?: string, options?: KubeCommandOptions): Promise<any>;
/**
* Get all ingresses of a cluster
*/
export declare function getAllIngresses(options?: KubeGenericOptions): Promise<KubeIngress[]>;
export declare function getIngressClasses(options?: KubeGenericOptions): Promise<KubeIngressClass[]>;
export declare function getIngress(name: any, namespace?: string, options?: KubeGenericOptions): Promise<KubeIngress>;
/**
* Get ingress list of a namespace
* @param namespace
*/
export declare function getIngresses(namespace?: string, options?: KubeCommandOptions): Promise<KubeIngress[]>;
export declare function deleteIngress(name: any, namespace?: string, options?: KubeGenericOptions): Promise<string>;
export declare function deleteIngressByFilter(namespace?: string, options?: KubeCommandOptions): Promise<string>;
export interface GetKubeDeployOptions extends KubeCommandOptions {
/**
* If `TRUE`, it will get metrics of pods and include in the response.
*
* @default true
*/
metrics?: boolean;
}
/**
* Get all deployments of a namespace
* @param namespace @default "default"
*/
export declare function getDeploys(namespace?: string, options?: GetKubeDeployOptions): Promise<KubeDeployment[]>;
/**
* Get all deployments of a cluster
*/
export declare function getAllDeploys(options?: GetKubeDeployOptions): Promise<KubeDeployment[]>;
/**
* Get a deployment in a namespace
*/
export declare function getDeploy(name: string, namespace?: string, options?: KubeGenericOptions): Promise<string | KubeDeployment>;
/**
* Get deployments in a namespace by filter labels
*/
export declare function getDeploysByFilter(namespace?: string, options?: KubeCommandOptions): Promise<KubeDeployment[]>;
/**
* Scale replicas of a deployment in a namespace
*/
export declare function scaleDeploy(name: string, replicas: number, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Scale replicas of multiple deployments in a namespace by label filter
* @param name - Deployment's name
*/
export declare function scaleDeployByFilter(replicas: number, namespace?: string, options?: KubeCommandOptions): Promise<string>;
/**
* Set image to a container of a deployment in a namespace
*/
export declare function setDeployImage(name: string, container: string, imageURL: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Set image to all containers of a deployment in a namespace
* @param name - Deployment's name
*/
export declare function setDeployImageAll(name: string, imageURL: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Set port to all containers of a deployment in a namespace
* @param name - Deployment's name
* @param port - New port
*/
export declare function setDeployPortAll(name: string, port: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Set "imagePullSecrets" name to deployments in a namespace by filter
*/
export declare function setDeployImagePullSecretByFilter(imagePullSecretName: string, namespace?: string, options?: KubeCommandOptions): Promise<string>;
/**
* Delete a deployment in a namespace
*/
export declare function deleteDeploy(name: any, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Delete a deployments in a namespace by label filter
*/
export declare function deleteDeploymentsByFilter(namespace?: string, options?: KubeCommandOptions): Promise<string>;
/**
* Get all StatefulSets of a namespace
* @param namespace @default "default"
*/
export declare function getStatefulSets(namespace?: string, options?: GetKubeDeployOptions): Promise<KubeStatefulSet[]>;
/**
* Get all statefulsets of a cluster
*/
export declare function getAllStatefulSets(options?: GetKubeDeployOptions): Promise<KubeStatefulSet[]>;
/**
* Get a StatefulSet in a namespace
*/
export declare function getStatefulSet(name: string, namespace?: string, options?: KubeGenericOptions): Promise<string | KubeStatefulSet>;
/**
* Get StatefulSets in a namespace by filter labels
*/
export declare function getStatefulSetsByFilter(namespace?: string, options?: KubeCommandOptions): Promise<KubeStatefulSet[]>;
/**
* Scale replicas of a StatefulSet in a namespace
*/
export declare function scaleStatefulSet(name: string, replicas: number, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Delete a StatefulSet in a namespace
*/
export declare function deleteStatefulSet(name: any, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Delete StatefulSets in a namespace by label filter
*/
export declare function deleteStatefulSetsByFilter(namespace?: string, options?: KubeCommandOptions): Promise<string>;
/**
* Create service by name
* @param namespace @default "default"
*/
export declare function createService(name: any, namespace?: string, options?: KubeGenericOptions): Promise<void>;
/**
* Get service by name
* @param namespace @default "default"
*/
export declare function getService(name: any, namespace?: string, options?: KubeGenericOptions): Promise<string | KubeService>;
/**
* Get services in a namespace
* @param namespace @default "default"
* @param labelFilter Filter by labels @example "phase!=prerelease,app=abc-xyz"
*/
export declare function getServices(namespace?: string, options?: KubeCommandOptions): Promise<string | KubeService[]>;
/**
* Get all services in a cluster
* @param labelFilter Filter by labels @example "phase!=prerelease,app=abc-xyz"
*/
export declare function getAllServices(options?: KubeCommandOptions): Promise<KubeService[]>;
/**
* Delete service by name
* @param namespace @default "default"
*/
export declare function deleteService(name: any, namespace?: string, options?: KubeGenericOptions): Promise<string>;
/**
* Delete service by label filter
* @param namespace @default "default"
*/
export declare function deleteServiceByFilter(namespace?: string, options?: KubeCommandOptions): Promise<string>;
export declare function getPod(name: any, namespace?: string, options?: KubeGenericOptions): Promise<KubePod>;
/**
* Get pods in a namespace
* @param namespace @default "default"
*/
export declare function getPods(namespace?: string, options?: GetKubeDeployOptions): Promise<KubePod[]>;
/**
* Get all pods in a cluster
*/
export declare function getAllPods(options?: KubeCommandOptions): Promise<KubePod[]>;
/**
* Alias function of `getPods()`
*/
export declare const getPodsByFilter: typeof getPods;
export declare function deletePod(name: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
export declare function deletePodsByFilter(namespace?: string, options?: KubeCommandOptions): Promise<string>;
export declare function logPod(name: any, namespace?: string, options?: KubeGenericOptions & {
timestamps?: boolean;
prefix?: boolean;
previous?: boolean;
}): Promise<string>;
export declare function logPodByFilter(namespace?: string, options?: KubeCommandOptions & {
timestamps?: boolean;
prefix?: boolean;
previous?: boolean;
}): Promise<string>;
export declare function setEnvVar(envVars: KubeEnvironmentVariable[], deploy: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
export declare function setEnvVarByFilter(envVars: KubeEnvironmentVariable[], namespace?: string, options?: KubeCommandOptions): Promise<string>;
export declare function deleteEnvVar(envVarNames: string[], deploy: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
export declare function deleteEnvVarByFilter(envVarNames: string[], namespace?: string, options?: KubeCommandOptions): Promise<string>;
export declare function rollbackDeploy(name: string, namespace?: string, options?: KubeGenericOptions): Promise<string | any[]>;
export declare function rollbackDeployRevision(name: string, revision: number, namespace?: string, options?: KubeGenericOptions): Promise<string | any[]>;
/**
* Get PersistentVolume by name
*/
export declare function getPersistentVolume(name: any, namespace?: string, options?: KubeGenericOptions): Promise<V1PersistentVolume>;
/**
* Get PersistentVolumes in a namespace
* @param namespace @default "default"
*/
export declare function getPersistentVolumes(namespace?: string, options?: GetKubeDeployOptions): Promise<V1PersistentVolume[]>;
/**
* Get all PersistentVolumes in a cluster
*/
export declare function getAllPersistentVolumes(options?: KubeCommandOptions): Promise<V1PersistentVolume[]>;
/**
* Alias function of `getPods()`
*/
export declare const getPersistentVolumesByFilter: typeof getPersistentVolumes;
export declare function deletePersistentVolume(name: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
export declare function deletePersistentVolumesByFilter(namespace?: string, options?: KubeCommandOptions): Promise<string>;
/**
* Get PersistentVolumeClaim by name
*/
export declare function getPersistentVolumeClaim(name: any, namespace?: string, options?: KubeGenericOptions): Promise<V1PersistentVolumeClaim>;
/**
* Get PersistentVolumeClaims in a namespace
* @param namespace @default "default"
*/
export declare function getPersistentVolumeClaims(namespace?: string, options?: GetKubeDeployOptions): Promise<V1PersistentVolumeClaim[]>;
/**
* Get all PersistentVolumes in a cluster
*/
export declare function getAllPersistentVolumeClaims(options?: KubeCommandOptions): Promise<V1PersistentVolumeClaim[]>;
/**
* Alias function of `getPods()`
*/
export declare const getPersistentVolumeClaimsByFilter: typeof getPersistentVolumeClaims;
export declare function deletePersistentVolumeClaim(name: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
export declare function deletePersistentVolumeClaimsByFilter(namespace?: string, options?: KubeCommandOptions): Promise<string>;
/**
* Get Storage Class by name
*/
export declare function getStorageClass(name: any, namespace?: string, options?: KubeGenericOptions): Promise<V1StorageClass>;
/**
* Get pods in a namespace
* @param namespace @default "default"
*/
export declare function getStorageClasses(namespace?: string, options?: GetKubeDeployOptions): Promise<V1StorageClass[]>;
/**
* Get all pods in a cluster
*/
export declare function getAllStorageClasses(options?: KubeCommandOptions): Promise<V1StorageClass[]>;
/**
* Alias function of `getPods()`
*/
export declare const getStorageClassesByFilter: typeof getPods;
export declare function deleteStorageClass(name: string, namespace?: string, options?: KubeGenericOptions): Promise<string>;
export declare function deleteStorageClassesByFilter(namespace?: string, options?: KubeCommandOptions): Promise<string>;
export declare function kubectlAnnotateDeployment(keyAndValue: string, deploymentName?: string, namespace?: string, options?: KubeCommandOptions & {
overwrite?: boolean;
}): Promise<string>;
export {};
//# sourceMappingURL=kubectl.d.ts.map