Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

K8sHttpClient unstable

HTTP client support for talking to the Kubernetes API from code running inside a cluster. The module builds a K8sHttpClient service on top of the shared HTTP client, points requests at the in-cluster API endpoint, and uses the mounted service-account token when one is available.

6 exports Since v4.0.0 Source

Constructors

Since v4.0.0

Creates a scoped function that ensures a Kubernetes pod exists and waits until it is ready.

Details

The pod defaults to the default namespace and is deleted when the surrounding scope closes.

Signature

declare const makeCreatePod: Effect<(...args: [spec: Pod]) => Effect, never, K8sHttpClient>

makeGetPods

unstable
Since v4.0.0

Creates a cached effect that fetches running Kubernetes pods.

Details

The request can be limited by namespace and label selector, and the result is a map keyed by pod IP address.

Signature

declare const makeGetPods: (options?: {
readonly labelSelector?: string;
readonly namespace?: string;
}) => Effect.Effect<Effect.Effect<Map<string, Pod>, HttpClientError.HttpClientError | Schema.SchemaError, never>, never, K8sHttpClient>

Layers

layer

unstable
Since v4.0.0

Layer that configures K8sHttpClient for the in-cluster Kubernetes API.

Details

It targets https://kubernetes.default.svc/api, adds the service-account bearer token when available, requires successful HTTP statuses, and retries transient failures.

Signature

declare const layer: Layer.Layer<K8sHttpClient, never, HttpClient.HttpClient | FileSystem.FileSystem>

Schemas

Pod

unstable
Since v4.0.0

Schema for Kubernetes Pod values used by cluster helpers.

Details

The model exposes readiness helpers derived from the pod status conditions.

Signature

declare class Pod extends {
readonly status: PodStatus;
} {
constructor(...args: [props: {
readonly status: PodStatus;
}, options?: MakeOptions]);
isReady: boolean;
isReadyOrInitializing: boolean;
}

PodStatus

unstable
Since v4.0.0

Schema for the subset of Kubernetes Pod status used by cluster helpers.

Signature

declare class PodStatus extends {
readonly conditions: readonly Array<{
readonly lastTransitionTime: string | null;
readonly status: string;
readonly type: string;
}>;
readonly hostIP: string;
readonly phase: string;
readonly podIP: string;
} {
constructor(...args: [props: {
readonly conditions: readonly Array<{
readonly lastTransitionTime: string | null;
readonly status: string;
readonly type: string;
}>;
readonly hostIP: string;
readonly phase: string;
readonly podIP: string;
}, options?: MakeOptions]);
}

Services

Since v4.0.0

Service tag for the HTTP client used to call the Kubernetes API.

Signature

declare class K8sHttpClient extends Shape<"effect/cluster/K8sHttpClient", HttpClient, this> {
constructor(_: never);
}