feat: GoCache | deploy go package cache

This commit is contained in:
2025-12-01 22:47:01 +05:00
parent 8dc22ff13b
commit 959920c3eb
3 changed files with 82 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
import * as fs from "fs";
import * as path from "path";
import { Release } from "@cdktf/provider-helm/lib/release";
import { Construct } from "constructs";
import { PublicIngressRoute } from "../../utils";
import { Providers } from "../../types";
type GoCacheOptions = {
providers: Providers;
namespace: string;
name: string;
host: string;
};
export class GoCache extends Construct {
constructor(scope: Construct, id: string, opts: GoCacheOptions) {
super(scope, id);
const { namespace, name, host } = opts;
const { helm, kubernetes } = opts.providers;
new Release(this, "helm-release", {
provider: helm,
name,
namespace,
repository: "https://gomods.github.io/athens-charts",
chart: "athens-proxy",
values: [fs.readFileSync(path.join(__dirname, "values.yaml"), "utf8")],
});
new PublicIngressRoute(this, "ingress", {
provider: kubernetes,
namespace,
name,
host,
serviceName: `${name}-athens-proxy`,
servicePort: 80,
});
}
}

View File

@@ -0,0 +1,19 @@
replicaCount: 3
image:
runAsNonRoot: true
nodeSelector:
nodepool: worker
strategy:
type: Recreate
storage:
disk:
persistence:
enabled: true
accessMode: ReadWriteMany
size: 64Gi
storageClass: longhorn
configEnvVars:
ATHENS_DOWNLOAD_MODE: "sync"
upstreamProxy:
enabled: true
url: "https://proxy.golang.org"

View File

@@ -5,15 +5,23 @@ import { NamespaceV1 } from "@cdktf/provider-kubernetes/lib/namespace-v1";
import { NixCache } from "./nix"; import { NixCache } from "./nix";
import { NpmCache } from "./npm"; import { NpmCache } from "./npm";
import { PipCache } from "./pip"; import { PipCache } from "./pip";
import { GoCache } from "./go";
import { HelmProvider } from "@cdktf/provider-helm/lib/provider";
export class CacheInfrastructure extends TerraformStack { export class CacheInfrastructure extends TerraformStack {
constructor(scope: Construct, id: string) { constructor(scope: Construct, id: string) {
super(scope, id); super(scope, id);
const provider = new KubernetesProvider(this, "kubernetes", { const kubernetes = new KubernetesProvider(this, "kubernetes", {
configPath: "~/.kube/config", configPath: "~/.kube/config",
}); });
const helm = new HelmProvider(this, "helm", {
kubernetes: {
configPath: "~/.kube/config",
},
});
const namespace = "package-cache"; const namespace = "package-cache";
new NamespaceV1(this, "package-cache-namespace", { new NamespaceV1(this, "package-cache-namespace", {
@@ -24,24 +32,34 @@ export class CacheInfrastructure extends TerraformStack {
// Add cache-related infrastructure components here // Add cache-related infrastructure components here
new NixCache(this, "nix-cache", { new NixCache(this, "nix-cache", {
provider, provider: kubernetes,
namespace, namespace,
name: "nix-cache", name: "nix-cache",
host: "nix.dogar.dev", host: "nix.dogar.dev",
}); });
new NpmCache(this, "npm-cache", { new NpmCache(this, "npm-cache", {
provider, provider: kubernetes,
namespace, namespace,
name: "npm-cache", name: "npm-cache",
host: "npm.dogar.dev", host: "npm.dogar.dev",
}); });
new PipCache(this, "pip-cache", { new PipCache(this, "pip-cache", {
provider, provider: kubernetes,
namespace, namespace,
name: "pip-cache", name: "pip-cache",
host: "pip.dogar.dev", host: "pip.dogar.dev",
}); });
new GoCache(this, "go-cache", {
providers: {
kubernetes,
helm,
},
namespace,
name: "go-cache",
host: "go.dogar.dev",
});
} }
} }