Compare commits
2 Commits
69bdd52df6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
43f15c7957
|
|||
|
8dc22ff13b
|
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",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ type RateLimitMiddlewareOptions = {
|
|||||||
namespace: string;
|
namespace: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
average?: number; // default 10
|
average?: number; // default 60
|
||||||
burst?: number; // default 50
|
burst?: number; // default 120
|
||||||
period?: string; // default "1s"
|
period?: string; // default "1s"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,8 +18,8 @@ export class RateLimitMiddleware extends Construct {
|
|||||||
constructor(scope: Construct, id: string, opts: RateLimitMiddlewareOptions) {
|
constructor(scope: Construct, id: string, opts: RateLimitMiddlewareOptions) {
|
||||||
super(scope, id);
|
super(scope, id);
|
||||||
|
|
||||||
const average = opts.average ?? 10;
|
const average = opts.average ?? 60;
|
||||||
const burst = opts.burst ?? 50;
|
const burst = opts.burst ?? 120;
|
||||||
const period = opts.period ?? "1s";
|
const period = opts.period ?? "1s";
|
||||||
|
|
||||||
this.ref = `${opts.namespace}/${opts.name}`;
|
this.ref = `${opts.namespace}/${opts.name}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user