Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/homelab/src/cdk8s/src/cdk8s-charts/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ZfsSataVolume } from "@shepherdjerred/homelab/cdk8s/src/misc/zfs-sata-v
import { createBazarrDeployment } from "@shepherdjerred/homelab/cdk8s/src/resources/torrents/bazarr.ts";
import { createTautulliDeployment } from "@shepherdjerred/homelab/cdk8s/src/resources/media/tautulli.ts";
import { createPlexDeployment } from "@shepherdjerred/homelab/cdk8s/src/resources/media/plex.ts";
import { createKometaCronJob } from "@shepherdjerred/homelab/cdk8s/src/resources/media/kometa.ts";
import { createKometaResources } from "@shepherdjerred/homelab/cdk8s/src/resources/media/kometa.ts";
import { createRadarrDeployment } from "@shepherdjerred/homelab/cdk8s/src/resources/torrents/radarr.ts";
import { createSeerrDeployment } from "@shepherdjerred/homelab/cdk8s/src/resources/torrents/seerr.ts";
import { createQBitTorrentDeployment } from "@shepherdjerred/homelab/cdk8s/src/resources/torrents/qbittorrent.ts";
Expand Down Expand Up @@ -50,7 +50,7 @@ export async function createMediaChart(app: App) {
tv: tvVolume.claim,
movies: moviesVolume.claim,
});
createKometaCronJob(chart);
createKometaResources(chart);
createRadarrDeployment(chart, {
movies: moviesVolume.claim,
downloads: downloadsVolume.claim,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import type { Chart } from "cdk8s";
import {
KubeConfigMap,
KubeCronJob,
KubePersistentVolumeClaim,
Quantity,
} from "@shepherdjerred/homelab/cdk8s/generated/imports/k8s.ts";
import { NVME_STORAGE_CLASS_LZ4 } from "@shepherdjerred/homelab/cdk8s/src/misc/storage-classes.ts";
import {
CI_NODE_HOSTNAME,
CI_NODE_TOLERATION,
} from "@shepherdjerred/homelab/cdk8s/src/misc/nodes.ts";

export const BUN_CACHE_MOUNT_PATH = "/buildkite/bun-cache";
export const BUN_CACHE_DATA_PATH = `${BUN_CACHE_MOUNT_PATH}/data`;
export const BUN_CACHE_CONTROL_PATH = "/buildkite/bun-cache-control";
export const BUN_CACHE_LOCK_PATH = `${BUN_CACHE_CONTROL_PATH}/.gc.lock`;
const BUN_CACHE_GC_THRESHOLD_PERCENT = "60";

const CI_BASE_DIGEST_CONTENT = await Bun.file(
new URL("ci-base.DIGEST", import.meta.url),
Expand All @@ -24,6 +15,7 @@ const CI_BASE_DIGEST = CI_BASE_DIGEST_CONTENT.trim();
if (!/^sha256:[\da-f]{64}$/.test(CI_BASE_DIGEST)) {
throw new Error("ci-base.DIGEST must contain a canonical sha256 digest");
}
export const CI_BASE_IMAGE = `ghcr.io/shepherdjerred/ci-base@${CI_BASE_DIGEST}`;

const BUN_CACHE_GC_SCRIPT = await Bun.file(
new URL("buildkite-bun-cache-gc.sh", import.meta.url),
Expand Down Expand Up @@ -77,94 +69,4 @@ export function createBuildkiteBunCache(chart: Chart): void {
"bun-cache-gc.sh": BUN_CACHE_GC_SCRIPT,
},
});

new KubeCronJob(chart, "buildkite-bun-cache-gc", {
metadata: { name: "buildkite-bun-cache-gc", namespace: "buildkite" },
spec: {
schedule: "*/5 * * * *",
timeZone: "America/Los_Angeles",
concurrencyPolicy: "Forbid",
successfulJobsHistoryLimit: 1,
failedJobsHistoryLimit: 3,
jobTemplate: {
spec: {
activeDeadlineSeconds: 900,
backoffLimit: 1,
template: {
spec: {
restartPolicy: "Never",
nodeSelector: { "kubernetes.io/hostname": CI_NODE_HOSTNAME },
tolerations: [CI_NODE_TOLERATION],
containers: [
{
name: "bun-cache-gc",
image: `ghcr.io/shepherdjerred/ci-base@${CI_BASE_DIGEST}`,
imagePullPolicy: "IfNotPresent",
command: ["bash", "/buildkite/maintenance/bun-cache-gc.sh"],
env: [
{
name: "BUN_INSTALL_CACHE_DIR",
value: BUN_CACHE_DATA_PATH,
},
{
name: "BUN_CACHE_LOCK_FILE",
value: BUN_CACHE_LOCK_PATH,
},
{
name: "BUN_CACHE_GC_THRESHOLD_PERCENT",
value: BUN_CACHE_GC_THRESHOLD_PERCENT,
},
],
resources: {
requests: {
cpu: Quantity.fromString("50m"),
memory: Quantity.fromString("128Mi"),
},
limits: {
cpu: Quantity.fromString("500m"),
memory: Quantity.fromString("512Mi"),
},
},
volumeMounts: [
{
name: "bun-cache",
mountPath: BUN_CACHE_MOUNT_PATH,
},
{
name: "bun-cache-control",
mountPath: BUN_CACHE_CONTROL_PATH,
},
{
name: "bun-cache-gc-script",
mountPath: "/buildkite/maintenance",
readOnly: true,
},
],
},
],
volumes: [
{
name: "bun-cache",
persistentVolumeClaim: { claimName: "buildkite-bun-cache" },
},
{
name: "bun-cache-control",
persistentVolumeClaim: {
claimName: "buildkite-bun-cache-control",
},
},
{
name: "bun-cache-gc-script",
configMap: {
name: "buildkite-bun-cache-gc",
defaultMode: 365,
},
},
],
},
},
},
},
},
});
}
Loading