UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

69 lines (68 loc) 4.1 kB
import { type CoreV1Api, type KubeConfig, V1Pod } from '@kubernetes/client-node'; import { type Pods } from '../../../resources/pod/pods.js'; import { NamespaceName } from '../../../../../types/namespace/namespace-name.js'; import { PodReference } from '../../../resources/pod/pod-reference.js'; import { type Pod } from '../../../resources/pod/pod.js'; import { K8ClientBase } from '../../k8-client-base.js'; import { type ContainerName } from '../../../resources/container/container-name.js'; import { type PodMetricsItem } from '../../../resources/pod/pod-metrics-item.js'; /** * Inspect a V1Pod's container statuses for non-recoverable error states and return a descriptive * error message if one is detected, or undefined if no fatal error is present. * * Covered states: * - Waiting: ImagePullBackOff, ErrImagePull, InvalidImageName, ImageInspectError, * RegistryUnavailable (image unavailable in registry) * - Terminated: OOMKilled (container killed due to out-of-memory) */ export declare function detectFatalContainerError(pod: V1Pod): string | undefined; export declare class K8ClientPods extends K8ClientBase implements Pods { private readonly kubeClient; private readonly kubeConfig; private readonly kubectlInstallationDirectory; private readonly logger; constructor(kubeClient: CoreV1Api, kubeConfig: KubeConfig, kubectlInstallationDirectory: string); readByReference(podReference: PodReference | null): Pod; read(podReference: PodReference): Promise<Pod>; list(namespace: NamespaceName, labels: string[]): Promise<Pod[]>; waitForReadyStatus(namespace: NamespaceName, labels: string[], maxAttempts?: number, delay?: number, createdAfter?: Date, excludeMarkedForDeletion?: boolean): Promise<Pod[]>; /** * Wait until the pod identified by `podReference` appears in the Kubernetes API. * * Use this when the exact pod name is known. If the pod must be discovered by labels, * use {@link waitForReadyStatus} with an appropriate label selector instead. * * @param podReference - exact reference of the pod to wait for * @param maxAttempts - maximum polling attempts before throwing (default 20 × 3 s = 60 s) * @param delay - milliseconds between attempts (default 3000) */ waitForPodByReference(podReference: PodReference, maxAttempts?: number, delay?: number): Promise<void>; /** * Check pods for conditions * @param namespace - namespace * @param conditionsMap - a map of conditions and values * @param [labels] - pod labels * @param [maxAttempts] - maximum attempts to check * @param [delay] - delay between checks in milliseconds * @param [createdAfter] - if provided, only pods created strictly after this date are considered * @param [excludeMarkedForDeletion] - if true, pods with deletionTimestamp are ignored */ private waitForPodConditions; waitForRunningPhase(namespace: NamespaceName, labels: string[], maxAttempts: number, delay: number, podItemPredicate?: (items: Pod) => boolean, createdAfter?: Date, excludeMarkedForDeletion?: boolean): Promise<Pod[]>; listForAllNamespaces(labels: string[]): Promise<Pod[]>; create(podReference: PodReference, labels: Record<string, string>, containerName: ContainerName, containerImage: string, containerCommand: string[], startupProbeCommand: string[]): Promise<Pod>; delete(podReference: PodReference): Promise<void>; readLogs(podReference: PodReference, timestamps?: boolean): Promise<string>; readDescribe(podReference: PodReference): Promise<string>; topPods(namespace?: NamespaceName, labelSelector?: string): Promise<PodMetricsItem[]>; /** * Parse a Kubernetes CPU quantity string into millicores. * Examples: "100m" -> 100, "1" -> 1000, "0.5" -> 500, "100000n" -> 0 (rounded) */ private static parseMillicores; /** * Parse a Kubernetes memory quantity string into mebibytes (MiB). * Examples: "50Mi" -> 50, "1Gi" -> 1024, "52428800" -> 50, "512Ki" -> 0 (rounded) */ private static parseMebibytes; }