1import { Stage } from "alchemy";
2import * as Kubernetes from "alchemy/Kubernetes";
3import * as Effect from "effect/Effect";
4
5export const Cluster = Effect.gen(function* () {
6 const stage = yield* Stage;
7 if (stage === "prod") {
8 return Kubernetes.KubeConfig({
9 context: "prod",
10 registry: { server: "ghcr.io/you" },
11 });
12 }
13 return yield* Kubernetes.LocalCluster("Cluster", { name: "alchemy" });
14});
15
16export const Namespace = Effect.gen(function* () {
17 const cluster = yield* Cluster;
18 return yield* Kubernetes.Manifest("Namespace", {
19 cluster,
20 manifest: {
21 apiVersion: "v1",
22 kind: "Namespace",
23 metadata: { name: "my-app" },
24 },
25 });
26});
27
28export const Web = Effect.gen(function* () {
29 const cluster = yield* Cluster;
30 const namespace = yield* Namespace;
31 return yield* Kubernetes.Deployment("Web", {
32 cluster,
33 name: "web",
34 namespace: namespace.name,
35 image: "ghcr.io/stefanprodan/podinfo:6.15.0",
36 port: 9898,
37 replicas: 2,
38 serviceType: "ClusterIP",
39 env: {
40 PODINFO_UI_MESSAGE: "hello from alchemy",
41 },
42 resources: {
43 requests: { cpu: "10m", memory: "32Mi" },
44 limits: { memory: "64Mi" },
45 },
46 });
47});