@alchemy.run/kubernetes 0.0.0 → 2.0.0-beta.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +41 -4
- package/lib/BuiltinAdapters.d.ts +23 -0
- package/lib/BuiltinAdapters.d.ts.map +1 -0
- package/lib/BuiltinAdapters.js +124 -0
- package/lib/BuiltinAdapters.js.map +1 -0
- package/lib/Client.d.ts +80 -0
- package/lib/Client.d.ts.map +1 -0
- package/lib/Client.js +296 -0
- package/lib/Client.js.map +1 -0
- package/lib/ClusterAdapter.d.ts +322 -0
- package/lib/ClusterAdapter.d.ts.map +1 -0
- package/lib/ClusterAdapter.js +65 -0
- package/lib/ClusterAdapter.js.map +1 -0
- package/lib/Connection.d.ts +210 -0
- package/lib/Connection.d.ts.map +1 -0
- package/lib/Connection.js +58 -0
- package/lib/Connection.js.map +1 -0
- package/lib/Deployment.d.ts +382 -0
- package/lib/Deployment.d.ts.map +1 -0
- package/lib/Deployment.js +533 -0
- package/lib/Deployment.js.map +1 -0
- package/lib/HelmChart.d.ts +147 -0
- package/lib/HelmChart.d.ts.map +1 -0
- package/lib/HelmChart.js +248 -0
- package/lib/HelmChart.js.map +1 -0
- package/lib/Job.d.ts +314 -0
- package/lib/Job.d.ts.map +1 -0
- package/lib/Job.js +426 -0
- package/lib/Job.js.map +1 -0
- package/lib/LocalCluster.d.ts +243 -0
- package/lib/LocalCluster.d.ts.map +1 -0
- package/lib/LocalCluster.js +359 -0
- package/lib/LocalCluster.js.map +1 -0
- package/lib/Manifest.d.ts +148 -0
- package/lib/Manifest.d.ts.map +1 -0
- package/lib/Manifest.js +200 -0
- package/lib/Manifest.js.map +1 -0
- package/lib/Objects.d.ts +60 -0
- package/lib/Objects.d.ts.map +1 -0
- package/lib/Objects.js +132 -0
- package/lib/Objects.js.map +1 -0
- package/lib/Providers.d.ts +24 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +36 -0
- package/lib/Providers.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/declared.d.ts +19 -0
- package/lib/internal/declared.d.ts.map +1 -0
- package/lib/internal/declared.js +435 -0
- package/lib/internal/declared.js.map +1 -0
- package/lib/internal/helm.d.ts +65 -0
- package/lib/internal/helm.d.ts.map +1 -0
- package/lib/internal/helm.js +173 -0
- package/lib/internal/helm.js.map +1 -0
- package/lib/internal/kind.d.ts +17 -0
- package/lib/internal/kind.d.ts.map +1 -0
- package/lib/internal/kind.js +31 -0
- package/lib/internal/kind.js.map +1 -0
- package/lib/internal/kubeconfig.d.ts +79 -0
- package/lib/internal/kubeconfig.d.ts.map +1 -0
- package/lib/internal/kubeconfig.js +222 -0
- package/lib/internal/kubeconfig.js.map +1 -0
- package/lib/internal/registry.d.ts +44 -0
- package/lib/internal/registry.d.ts.map +1 -0
- package/lib/internal/registry.js +72 -0
- package/lib/internal/registry.js.map +1 -0
- package/lib/internal/workload.d.ts +127 -0
- package/lib/internal/workload.d.ts.map +1 -0
- package/lib/internal/workload.js +411 -0
- package/lib/internal/workload.js.map +1 -0
- package/package.json +55 -3
- package/src/BuiltinAdapters.ts +194 -0
- package/src/Client.ts +465 -0
- package/src/ClusterAdapter.ts +370 -0
- package/src/Connection.ts +234 -0
- package/src/Deployment.ts +851 -0
- package/src/HelmChart.ts +388 -0
- package/src/Job.ts +689 -0
- package/src/LocalCluster.ts +631 -0
- package/src/Manifest.ts +295 -0
- package/src/Objects.ts +213 -0
- package/src/Providers.ts +52 -0
- package/src/globals.d.ts +2 -0
- package/src/index.ts +9 -0
- package/src/internal/declared.ts +471 -0
- package/src/internal/helm.ts +245 -0
- package/src/internal/kind.ts +43 -0
- package/src/internal/kubeconfig.ts +364 -0
- package/src/internal/registry.ts +108 -0
- package/src/internal/workload.ts +503 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The extension seam between the cluster-agnostic `Kubernetes.*` workloads
|
|
3
|
+
* and the platform a cluster runs on.
|
|
4
|
+
*
|
|
5
|
+
* A {@link ClusterAdapterService} is registered under a keyed Context tag —
|
|
6
|
+
* `Kubernetes.ClusterAdapter/<auth kind>` — and resolved dynamically from
|
|
7
|
+
* the ambient provider context by {@link findClusterAdapter}, mirroring how
|
|
8
|
+
* resource providers are resolved by type. `Kubernetes.providers()` ships
|
|
9
|
+
* the built-in adapters (`kubeconfig`, `token`, `client-cert`, `exec`);
|
|
10
|
+
* cloud provider layers contribute theirs (`AWS.providers()` registers
|
|
11
|
+
* `aws-eks`).
|
|
12
|
+
*
|
|
13
|
+
* An adapter owns everything platform-specific:
|
|
14
|
+
*
|
|
15
|
+
* - **connect** (required) — resolve the API server endpoint/CA and mint
|
|
16
|
+
* per-request auth headers.
|
|
17
|
+
* - **identity** (optional) — provision workload identity for a namespace +
|
|
18
|
+
* service account and translate host bindings into cloud credentials
|
|
19
|
+
* (EKS Pod Identity, GKE Workload Identity Federation).
|
|
20
|
+
* - **registry** (optional) — build/mirror container images into a managed
|
|
21
|
+
* registry the cluster can pull from (ECR on EKS, Artifact Registry on GKE).
|
|
22
|
+
* - **bootstrap** (optional) — platform-specific generated container
|
|
23
|
+
* entries for Effect-native workloads (e.g. wiring the AWS credential
|
|
24
|
+
* chain for Pod Identity).
|
|
25
|
+
* - **loadBalancerDefaults** (optional) — platform defaults for
|
|
26
|
+
* `LoadBalancer` Services (EKS Auto Mode's `loadBalancerClass` +
|
|
27
|
+
* internet-facing scheme).
|
|
28
|
+
*/
|
|
29
|
+
import * as Context from "effect/Context";
|
|
30
|
+
import * as Data from "effect/Data";
|
|
31
|
+
import * as Effect from "effect/Effect";
|
|
32
|
+
import * as Option from "effect/Option";
|
|
33
|
+
/**
|
|
34
|
+
* The target cluster no longer exists (definitively — e.g. the managed
|
|
35
|
+
* control plane is deleted or deleting). Distinct from transient
|
|
36
|
+
* unreachability: `read`/`delete` treat this as "everything in-cluster is
|
|
37
|
+
* already gone".
|
|
38
|
+
*/
|
|
39
|
+
export class ClusterNotFoundError extends Data.TaggedError("Kubernetes.ClusterNotFoundError") {
|
|
40
|
+
}
|
|
41
|
+
const adapterKey = (authKind) => `Kubernetes.ClusterAdapter/${authKind}`;
|
|
42
|
+
/**
|
|
43
|
+
* The keyed Context tag for an adapter. Same auth kind → same tag, so a
|
|
44
|
+
* layer built with `ClusterAdapter("aws-eks")` is found by any dynamic
|
|
45
|
+
* lookup for that kind.
|
|
46
|
+
*/
|
|
47
|
+
export const ClusterAdapter = (authKind) => Context.Service()(adapterKey(authKind));
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the {@link ClusterAdapterService} for a connection's auth kind
|
|
50
|
+
* from the ambient context (the stack's composed provider layers). Dies
|
|
51
|
+
* with setup guidance when no adapter is registered — that means the
|
|
52
|
+
* provider layer contributing it (e.g. `AWS.providers()` for `aws-eks`)
|
|
53
|
+
* is missing from the stack.
|
|
54
|
+
*/
|
|
55
|
+
export const findClusterAdapter = (authKind) => Effect.serviceOption(ClusterAdapter(authKind)).pipe(Effect.flatMap(Option.match({
|
|
56
|
+
onSome: (adapter) => Effect.succeed(adapter),
|
|
57
|
+
onNone: () => Effect.die(new Error(`No Kubernetes cluster adapter is registered for auth kind ` +
|
|
58
|
+
`'${authKind}'. Add the provider layer that contributes it ` +
|
|
59
|
+
`to the stack's providers — e.g. 'aws-eks' ships with ` +
|
|
60
|
+
"`AWS.providers()`; the built-in kinds (kubeconfig, token, " +
|
|
61
|
+
"client-cert, exec) ship with `Kubernetes.providers()`. " +
|
|
62
|
+
"Compose multiple provider layers with " +
|
|
63
|
+
"`Layer.mergeAll(AWS.providers(), Kubernetes.providers())`.")),
|
|
64
|
+
})));
|
|
65
|
+
//# sourceMappingURL=ClusterAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClusterAdapter.js","sourceRoot":"","sources":["../src/ClusterAdapter.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
* Every `Kubernetes.*` workload (`Deployment`, `Job`, `Manifest`,
|
|
6
|
+
* `HelmChart`) targets a cluster through a serializable {@link Connection}:
|
|
7
|
+
* the API server endpoint (or enough information to discover it) plus an
|
|
8
|
+
* {@link ConnectionAuth} descriptor whose `kind` selects the
|
|
9
|
+
* {@link ClusterAdapter} that knows how to authenticate requests — and,
|
|
10
|
+
* for managed clouds, how to provision workload identity and container
|
|
11
|
+
* images.
|
|
12
|
+
*
|
|
13
|
+
* A `Connection` is plain data on purpose: it is resolved from resource
|
|
14
|
+
* attributes at reconcile time and persisted on workload attributes so
|
|
15
|
+
* `delete` can reconnect without the original resource graph.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The auth descriptor registry, keyed by adapter kind. Cloud providers
|
|
19
|
+
* extend it via module augmentation — e.g. AWS registers:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* declare module "@alchemy.run/kubernetes/Connection" {
|
|
23
|
+
* interface AuthRegistry {
|
|
24
|
+
* "aws-eks": { clusterName: string; region?: string };
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* The built-in kinds cover anything `kubectl` can reach: a kubeconfig
|
|
30
|
+
* context (including `exec` credential plugins — `aws eks get-token`,
|
|
31
|
+
* `kubelogin`, `gke-gcloud-auth-plugin`), a static bearer token, a client
|
|
32
|
+
* certificate, or a raw exec credential plugin invocation.
|
|
33
|
+
*/
|
|
34
|
+
export interface AuthRegistry {
|
|
35
|
+
/**
|
|
36
|
+
* Resolve the cluster, user, and credentials from a kubeconfig file —
|
|
37
|
+
* the "anything kubectl can reach" adapter. Honors client certificates,
|
|
38
|
+
* static tokens, and `exec` credential plugins declared in the file.
|
|
39
|
+
*/
|
|
40
|
+
kubeconfig: {
|
|
41
|
+
/**
|
|
42
|
+
* Path to the kubeconfig file.
|
|
43
|
+
* @default `$KUBECONFIG` or `~/.kube/config`
|
|
44
|
+
*/
|
|
45
|
+
path?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The context to use.
|
|
48
|
+
* @default the file's `current-context`
|
|
49
|
+
*/
|
|
50
|
+
context?: string;
|
|
51
|
+
};
|
|
52
|
+
/** Authenticate with a static bearer token. */
|
|
53
|
+
token: {
|
|
54
|
+
/** The bearer token sent as `Authorization: Bearer <token>`. */
|
|
55
|
+
token: string;
|
|
56
|
+
};
|
|
57
|
+
/** Authenticate with a client certificate (mutual TLS). */
|
|
58
|
+
"client-cert": {
|
|
59
|
+
/** PEM-encoded client certificate. */
|
|
60
|
+
certificate: string;
|
|
61
|
+
/** PEM-encoded client private key. */
|
|
62
|
+
key: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Mint credentials with a kubeconfig-style exec credential plugin
|
|
66
|
+
* (`client.authentication.k8s.io` ExecCredential protocol).
|
|
67
|
+
*/
|
|
68
|
+
exec: {
|
|
69
|
+
/** The command to run (e.g. `aws`). */
|
|
70
|
+
command: string;
|
|
71
|
+
/** Arguments (e.g. `["eks", "get-token", "--cluster-name", "x"]`). */
|
|
72
|
+
args?: string[];
|
|
73
|
+
/** Extra environment variables for the plugin process. */
|
|
74
|
+
env?: Record<string, string>;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The discriminated auth union — one member per {@link AuthRegistry} entry,
|
|
79
|
+
* each tagged with its registry key as `kind`.
|
|
80
|
+
*/
|
|
81
|
+
export type ConnectionAuth = {
|
|
82
|
+
[K in keyof AuthRegistry]: {
|
|
83
|
+
readonly kind: K;
|
|
84
|
+
} & AuthRegistry[K];
|
|
85
|
+
}[keyof AuthRegistry];
|
|
86
|
+
/**
|
|
87
|
+
* A container registry the cluster's nodes can pull from. `Deployment` and
|
|
88
|
+
* `Job` workloads with a `main` program or a `context` Dockerfile are built
|
|
89
|
+
* on the deploying machine and pushed here as `<server>/<name>:<hash>`.
|
|
90
|
+
*
|
|
91
|
+
* Clusters whose platform adapter provides its own registry (EKS pushes to
|
|
92
|
+
* ECR) ignore this setting.
|
|
93
|
+
*/
|
|
94
|
+
export interface ContainerRegistry {
|
|
95
|
+
/**
|
|
96
|
+
* Registry host, optionally followed by the namespace images are pushed
|
|
97
|
+
* under — e.g. `localhost:5001`, `ghcr.io/acme`, or
|
|
98
|
+
* `us-docker.pkg.dev/my-project/apps`.
|
|
99
|
+
*/
|
|
100
|
+
server: string;
|
|
101
|
+
/**
|
|
102
|
+
* Username for pushing. Omit `username` and `password` to push with the
|
|
103
|
+
* deploying machine's own Docker login (`docker login`, credential
|
|
104
|
+
* helpers).
|
|
105
|
+
*/
|
|
106
|
+
username?: string;
|
|
107
|
+
/** Password or access token for pushing. */
|
|
108
|
+
password?: string | Redacted.Redacted<string>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A serializable description of how to reach and authenticate against a
|
|
112
|
+
* Kubernetes API server.
|
|
113
|
+
*/
|
|
114
|
+
export interface Connection {
|
|
115
|
+
/**
|
|
116
|
+
* The API server endpoint URL. Optional when the auth adapter can
|
|
117
|
+
* discover it (a kubeconfig file carries the server; the EKS adapter
|
|
118
|
+
* re-describes the cluster).
|
|
119
|
+
*/
|
|
120
|
+
endpoint?: string;
|
|
121
|
+
/** Base64-encoded PEM certificate authority bundle for the endpoint. */
|
|
122
|
+
certificateAuthorityData?: string;
|
|
123
|
+
/** Skip TLS verification (self-signed local clusters). */
|
|
124
|
+
insecureSkipTlsVerify?: boolean;
|
|
125
|
+
/** How to authenticate — selects the {@link ClusterAdapter} by `kind`. */
|
|
126
|
+
auth: ConnectionAuth;
|
|
127
|
+
/**
|
|
128
|
+
* Where `main` and `context` workloads push their images. Required for
|
|
129
|
+
* those sources unless the cluster's platform adapter provides a
|
|
130
|
+
* registry (EKS → ECR).
|
|
131
|
+
*/
|
|
132
|
+
registry?: ContainerRegistry;
|
|
133
|
+
/**
|
|
134
|
+
* CPU architecture of the cluster's nodes — the default target of
|
|
135
|
+
* workload image builds when a workload doesn't set `architecture`.
|
|
136
|
+
* @default "amd64"
|
|
137
|
+
*/
|
|
138
|
+
architecture?: "amd64" | "arm64";
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Anything a `Kubernetes.*` workload accepts as its `cluster` prop: a raw
|
|
142
|
+
* {@link Connection}, or any value exposing one as a `connection` field —
|
|
143
|
+
* which is how managed cluster resources (`AWS.EKS.Cluster`) participate:
|
|
144
|
+
* their attributes carry a `connection`, so the whole resource can be
|
|
145
|
+
* passed directly.
|
|
146
|
+
*/
|
|
147
|
+
export type ClusterLike = Connection | {
|
|
148
|
+
connection: Connection;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Normalize a {@link ClusterLike} to its {@link Connection}. Throws when
|
|
152
|
+
* the value carries neither shape — e.g. a managed cluster resource whose
|
|
153
|
+
* attributes predate the `connection` field.
|
|
154
|
+
*/
|
|
155
|
+
export declare const toConnection: (cluster: ClusterLike) => Connection;
|
|
156
|
+
/**
|
|
157
|
+
* Connect `Kubernetes.*` workloads to any cluster your local kubeconfig can
|
|
158
|
+
* reach — k3s, kind, on-prem, AKS, GKE, anything `kubectl` works against.
|
|
159
|
+
* Exec credential plugins declared in the file (`aws eks get-token`,
|
|
160
|
+
* `kubelogin`, `gke-gcloud-auth-plugin`) are honored, so cloud-CLI-managed
|
|
161
|
+
* contexts work as-is.
|
|
162
|
+
*
|
|
163
|
+
* This is a plain helper, not a resource: nothing is provisioned and the
|
|
164
|
+
* cluster appears in no plan — it only describes how to reach the API
|
|
165
|
+
* server.
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* const cluster = Kubernetes.KubeConfig({ context: "prod-east" });
|
|
169
|
+
*
|
|
170
|
+
* const api = yield* Kubernetes.Deployment("Api", {
|
|
171
|
+
* cluster,
|
|
172
|
+
* image: "ghcr.io/acme/api:v3",
|
|
173
|
+
* port: 8080,
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* Add a `registry` to build `main` programs and `context` Dockerfiles for
|
|
178
|
+
* the cluster:
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* const cluster = Kubernetes.KubeConfig({
|
|
182
|
+
* context: "prod-east",
|
|
183
|
+
* registry: { server: "ghcr.io/acme" },
|
|
184
|
+
* });
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export declare const KubeConfig: (options?: {
|
|
188
|
+
/**
|
|
189
|
+
* Path to the kubeconfig file.
|
|
190
|
+
* @default `$KUBECONFIG` or `~/.kube/config`
|
|
191
|
+
*/
|
|
192
|
+
path?: string;
|
|
193
|
+
/**
|
|
194
|
+
* The context to use.
|
|
195
|
+
* @default the file's `current-context`
|
|
196
|
+
*/
|
|
197
|
+
context?: string;
|
|
198
|
+
/**
|
|
199
|
+
* Where `main` and `context` workloads push their images. The cluster's
|
|
200
|
+
* nodes must be able to pull from it.
|
|
201
|
+
*/
|
|
202
|
+
registry?: ContainerRegistry;
|
|
203
|
+
/**
|
|
204
|
+
* CPU architecture of the cluster's nodes, used as the default image
|
|
205
|
+
* build target.
|
|
206
|
+
* @default "amd64"
|
|
207
|
+
*/
|
|
208
|
+
architecture?: "amd64" | "arm64";
|
|
209
|
+
}) => Connection;
|
|
210
|
+
//# sourceMappingURL=Connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connection.d.ts","sourceRoot":"","sources":["../src/Connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,UAAU,EAAE;QACV;;;WAGG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,+CAA+C;IAC/C,KAAK,EAAE;QACL,g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AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC;AAKlE;;;;GAIG;AACH,eAAO,MAAM,YAAY,YAAa,WAAW,KAAG,UAUnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,UAAU,aAAc;IACnC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAClC,KAAG,UAQF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const isConnection = (value) => "auth" in value && value.auth !== undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a {@link ClusterLike} to its {@link Connection}. Throws when
|
|
4
|
+
* the value carries neither shape — e.g. a managed cluster resource whose
|
|
5
|
+
* attributes predate the `connection` field.
|
|
6
|
+
*/
|
|
7
|
+
export const toConnection = (cluster) => {
|
|
8
|
+
if (isConnection(cluster))
|
|
9
|
+
return cluster;
|
|
10
|
+
if (cluster.connection !== undefined)
|
|
11
|
+
return cluster.connection;
|
|
12
|
+
throw new Error("The `cluster` value carries no Kubernetes connection. Pass a cluster " +
|
|
13
|
+
"resource whose attributes expose `connection` (e.g. `AWS.EKS.Cluster`" +
|
|
14
|
+
" — redeploy the cluster if it was created before the `connection` " +
|
|
15
|
+
"attribute existed), a `Kubernetes.KubeConfig(...)`, or a raw " +
|
|
16
|
+
"`Kubernetes.Connection`.");
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Connect `Kubernetes.*` workloads to any cluster your local kubeconfig can
|
|
20
|
+
* reach — k3s, kind, on-prem, AKS, GKE, anything `kubectl` works against.
|
|
21
|
+
* Exec credential plugins declared in the file (`aws eks get-token`,
|
|
22
|
+
* `kubelogin`, `gke-gcloud-auth-plugin`) are honored, so cloud-CLI-managed
|
|
23
|
+
* contexts work as-is.
|
|
24
|
+
*
|
|
25
|
+
* This is a plain helper, not a resource: nothing is provisioned and the
|
|
26
|
+
* cluster appears in no plan — it only describes how to reach the API
|
|
27
|
+
* server.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const cluster = Kubernetes.KubeConfig({ context: "prod-east" });
|
|
31
|
+
*
|
|
32
|
+
* const api = yield* Kubernetes.Deployment("Api", {
|
|
33
|
+
* cluster,
|
|
34
|
+
* image: "ghcr.io/acme/api:v3",
|
|
35
|
+
* port: 8080,
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Add a `registry` to build `main` programs and `context` Dockerfiles for
|
|
40
|
+
* the cluster:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* const cluster = Kubernetes.KubeConfig({
|
|
44
|
+
* context: "prod-east",
|
|
45
|
+
* registry: { server: "ghcr.io/acme" },
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export const KubeConfig = (options) => ({
|
|
50
|
+
auth: {
|
|
51
|
+
kind: "kubeconfig",
|
|
52
|
+
path: options?.path,
|
|
53
|
+
context: options?.context,
|
|
54
|
+
},
|
|
55
|
+
...(options?.registry !== undefined ? { registry: options.registry } : {}),
|
|
56
|
+
...(options?.architecture !== undefined ? { architecture: options.architecture } : {}),
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=Connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connection.js","sourceRoot":"","sources":["../src/Connection.ts"],"names":[],"mappings":"AAwJA,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAuB,EAAE,CAC/D,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAoB,EAAc,EAAE;IAC/D,IAAI,YAAY,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAC1C,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,UAAU,CAAC;IAChE,MAAM,IAAI,KAAK,CACb,uEAAuE;QACrE,uEAAuE;QACvE,oEAAoE;QACpE,+DAA+D;QAC/D,0BAA0B,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAsB1B,EAAc,EAAE,CAAC,CAAC;IACjB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,OAAO,EAAE,IAAI;QACnB,OAAO,EAAE,OAAO,EAAE,OAAO;KAC1B;IACD,GAAG,CAAC,OAAO,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CACvF,CAAC,CAAC"}
|