feat: GoCache | deploy go package cache
This commit is contained in:
41
cache-infrastructure/go/index.ts
Normal file
41
cache-infrastructure/go/index.ts
Normal 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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
20
cache-infrastructure/go/values.yaml
Normal file
20
cache-infrastructure/go/values.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
replicaCount: 3
|
||||||
|
image:
|
||||||
|
runAsNonRoot: true
|
||||||
|
nodeSelector:
|
||||||
|
nodepool: worker
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
storage:
|
||||||
|
disk:
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
accessMode: ReadWriteMany
|
||||||
|
size: 64Gi
|
||||||
|
storageClass: longhorn
|
||||||
|
configEnvVars:
|
||||||
|
- name: ATHENS_DOWNLOAD_MODE
|
||||||
|
value: "sync"
|
||||||
|
upstreamProxy:
|
||||||
|
enabled: true
|
||||||
|
url: "https://proxy.golang.org"
|
||||||
@@ -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",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user