From 40371a7eff62beebaa246760ecce18d1bd8484dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-X=2E=20T=2E?= Date: Tue, 13 Jan 2026 16:12:54 -0500 Subject: [PATCH 1/6] Init --- apps/labrinth/k8s/base/deployment.yaml | 57 +++++++ apps/labrinth/k8s/base/kustomization.yaml | 5 + apps/labrinth/k8s/base/service.yaml | 10 ++ apps/labrinth/k8s/overlays/local/.gitignore | 2 + .../k8s/overlays/local/config.env.local | 159 ++++++++++++++++++ .../k8s/overlays/local/envfrom-patch.yaml | 13 ++ .../local/gateway-namespace-patch.yaml | 8 + apps/labrinth/k8s/overlays/local/gateway.yaml | 17 ++ .../image-config/kustomization.example.yaml | 6 + .../local/image-config/kustomization.yaml | 8 + .../k8s/overlays/local/kustomization.yaml | 24 +++ .../k8s/overlays/local/resources-patch.yaml | 17 ++ .../k8s/overlays/local/setup-local.sh | 17 ++ .../k8s/scopes/api-v3/deployment-patch.yaml | 23 +++ .../labrinth/k8s/scopes/api-v3/httproute.yaml | 16 ++ .../k8s/scopes/api-v3/kustomization.yaml | 10 ++ .../k8s/scopes/auth/deployment-patch.yaml | 23 +++ apps/labrinth/k8s/scopes/auth/httproute.yaml | 25 +++ .../k8s/scopes/auth/kustomization.yaml | 10 ++ 19 files changed, 450 insertions(+) create mode 100644 apps/labrinth/k8s/base/deployment.yaml create mode 100644 apps/labrinth/k8s/base/kustomization.yaml create mode 100644 apps/labrinth/k8s/base/service.yaml create mode 100644 apps/labrinth/k8s/overlays/local/.gitignore create mode 100644 apps/labrinth/k8s/overlays/local/config.env.local create mode 100644 apps/labrinth/k8s/overlays/local/envfrom-patch.yaml create mode 100644 apps/labrinth/k8s/overlays/local/gateway-namespace-patch.yaml create mode 100644 apps/labrinth/k8s/overlays/local/gateway.yaml create mode 100644 apps/labrinth/k8s/overlays/local/image-config/kustomization.example.yaml create mode 100644 apps/labrinth/k8s/overlays/local/image-config/kustomization.yaml create mode 100644 apps/labrinth/k8s/overlays/local/kustomization.yaml create mode 100644 apps/labrinth/k8s/overlays/local/resources-patch.yaml create mode 100755 apps/labrinth/k8s/overlays/local/setup-local.sh create mode 100644 apps/labrinth/k8s/scopes/api-v3/deployment-patch.yaml create mode 100644 apps/labrinth/k8s/scopes/api-v3/httproute.yaml create mode 100644 apps/labrinth/k8s/scopes/api-v3/kustomization.yaml create mode 100644 apps/labrinth/k8s/scopes/auth/deployment-patch.yaml create mode 100644 apps/labrinth/k8s/scopes/auth/httproute.yaml create mode 100644 apps/labrinth/k8s/scopes/auth/kustomization.yaml diff --git a/apps/labrinth/k8s/base/deployment.yaml b/apps/labrinth/k8s/base/deployment.yaml new file mode 100644 index 0000000000..7a9781df34 --- /dev/null +++ b/apps/labrinth/k8s/base/deployment.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: labrinth + labels: + app.kubernetes.io/component: main +spec: + replicas: 2 + selector: + matchLabels: + app: labrinth + template: + metadata: + labels: + app: labrinth + spec: + containers: + - name: labrinth + image: labrinth + imagePullPolicy: IfNotPresent + args: + ["/labrinth/labrinth", "--no-background-tasks", "--no-migrations"] + env: + - name: GOTENBERG_TIMEOUT + value: "30000" + ports: + - containerPort: 8000 + name: http + resources: # Base resources for an API service, can be tweaked per scope + requests: + cpu: "2" + memory: 24Gi + limits: + cpu: "16" + memory: 32Gi + livenessProbe: + httpGet: + path: / + port: http + periodSeconds: 10 + failureThreshold: 5 + initialDelaySeconds: 20 + readinessProbe: + httpGet: + path: / + port: http + periodSeconds: 5 + initialDelaySeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + startupProbe: + httpGet: + path: / + port: http + periodSeconds: 3 + initialDelaySeconds: 1 + failureThreshold: 15 \ No newline at end of file diff --git a/apps/labrinth/k8s/base/kustomization.yaml b/apps/labrinth/k8s/base/kustomization.yaml new file mode 100644 index 0000000000..ca1d88ef8a --- /dev/null +++ b/apps/labrinth/k8s/base/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - deployment.yaml + - service.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/base/service.yaml b/apps/labrinth/k8s/base/service.yaml new file mode 100644 index 0000000000..4a34d8bef7 --- /dev/null +++ b/apps/labrinth/k8s/base/service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: labrinth +spec: + selector: + app: labrinth + ports: + - port: 80 + targetPort: 8000 \ No newline at end of file diff --git a/apps/labrinth/k8s/overlays/local/.gitignore b/apps/labrinth/k8s/overlays/local/.gitignore new file mode 100644 index 0000000000..ec8074277b --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/.gitignore @@ -0,0 +1,2 @@ +image-config.yaml +config.env \ No newline at end of file diff --git a/apps/labrinth/k8s/overlays/local/config.env.local b/apps/labrinth/k8s/overlays/local/config.env.local new file mode 100644 index 0000000000..465a07559e --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/config.env.local @@ -0,0 +1,159 @@ +DEBUG=true +RUST_LOG=debug,actix_web_prom=error,sqlx::query=warn +SENTRY_DSN=none + +SITE_URL=http://localhost:3000 +# This CDN URL matches the local storage backend set below, which uses MOCK_FILE_PATH +CDN_URL=file:///tmp/modrinth +LABRINTH_ADMIN_KEY=feedbeef +LABRINTH_EXTERNAL_NOTIFICATION_KEY=beeffeed +RATE_LIMIT_IGNORE_KEY=feedbeef + +DATABASE_URL=postgresql://labrinth:labrinth@localhost/labrinth +DATABASE_MIN_CONNECTIONS=0 +DATABASE_MAX_CONNECTIONS=16 + +#MEILISEARCH_READ_ADDR=http://labrinth-meilisearch0:7700 +MEILISEARCH_ADDR=http://localhost:7700 +#MEILISEARCH_WRITE_ADDRS=http://localhost:7700,http://localhost:7701 +MEILISEARCH_KEY=modrinth + +REDIS_URL=redis://localhost +REDIS_MAX_CONNECTIONS=10000 + +# Must bind to broadcast, not localhost, because some +# Docker services (Gotenberg) must be able to reach the backend +# from a different network interface +BIND_ADDR=0.0.0.0:8000 +SELF_ADDR=http://127.0.0.1:8000 + +MODERATION_SLACK_WEBHOOK= +PUBLIC_DISCORD_WEBHOOK= +CLOUDFLARE_INTEGRATION=false + +PAYOUT_ALERT_SLACK_WEBHOOK=none +TREMENDOUS_BALANCE_ALERT_THRESHOLD=0 +PAYPAL_BALANCE_ALERT_THRESHOLD=0 +BREX_BALANCE_ALERT_THRESHOLD=0 + +STORAGE_BACKEND=local +MOCK_FILE_PATH=/tmp/modrinth + +S3_PUBLIC_BUCKET_NAME=none +S3_PUBLIC_USES_PATH_STYLE_BUCKET=false +S3_PUBLIC_REGION=none +S3_PUBLIC_URL=none +S3_PUBLIC_ACCESS_TOKEN=none +S3_PUBLIC_SECRET=none + +S3_PRIVATE_BUCKET_NAME=none +S3_PRIVATE_USES_PATH_STYLE_BUCKET=false +S3_PRIVATE_REGION=none +S3_PRIVATE_URL=none +S3_PRIVATE_ACCESS_TOKEN=none +S3_PRIVATE_SECRET=none + +# 1 hour +LOCAL_INDEX_INTERVAL=3600 +# 30 minutes +VERSION_INDEX_INTERVAL=1800 + +RATE_LIMIT_IGNORE_IPS='["127.0.0.1"]' + +WHITELISTED_MODPACK_DOMAINS='["cdn.modrinth.com", "github.com", "raw.githubusercontent.com"]' + +ALLOWED_CALLBACK_URLS='["localhost", ".modrinth.com", "127.0.0.1", "[::1]"]' + +GITHUB_CLIENT_ID=none +GITHUB_CLIENT_SECRET=none + +GITLAB_CLIENT_ID=none +GITLAB_CLIENT_SECRET=none + +DISCORD_CLIENT_ID=none +DISCORD_CLIENT_SECRET=none + +MICROSOFT_CLIENT_ID=none +MICROSOFT_CLIENT_SECRET=none + +GOOGLE_CLIENT_ID=none +GOOGLE_CLIENT_SECRET=none + +PAYPAL_API_URL=https://api-m.sandbox.paypal.com/v1/ +PAYPAL_WEBHOOK_ID=none +PAYPAL_CLIENT_ID=none +PAYPAL_CLIENT_SECRET=none +PAYPAL_NVP_USERNAME=none +PAYPAL_NVP_PASSWORD=none +PAYPAL_NVP_SIGNATURE=none + +STEAM_API_KEY=none + +TREMENDOUS_API_URL=https://testflight.tremendous.com/api/v2/ +TREMENDOUS_API_KEY=none +TREMENDOUS_PRIVATE_KEY=none +TREMENDOUS_CAMPAIGN_ID=none + +HCAPTCHA_SECRET=none + +SMTP_FROM_NAME=Modrinth +SMTP_FROM_ADDRESS=no-reply@mail.modrinth.com +SMTP_USERNAME= +SMTP_PASSWORD= +SMTP_HOST=localhost +SMTP_PORT=1025 +SMTP_TLS=none + +SITE_VERIFY_EMAIL_PATH=auth/verify-email +SITE_RESET_PASSWORD_PATH=auth/reset-password +SITE_BILLING_PATH=none + +SENDY_URL=none +SENDY_LIST_ID=none +SENDY_API_KEY=none + +ANALYTICS_ALLOWED_ORIGINS='["http://127.0.0.1:3000", "http://localhost:3000", "https://modrinth.com", "https://www.modrinth.com", "*"]' + +CLICKHOUSE_REPLICATED=false +CLICKHOUSE_URL=http://localhost:8123 +CLICKHOUSE_USER=default +CLICKHOUSE_PASSWORD=default +CLICKHOUSE_DATABASE=staging_ariadne + +FLAME_ANVIL_URL=none + +STRIPE_API_KEY=none +STRIPE_WEBHOOK_SECRET=none + +ADITUDE_API_KEY=none + +PYRO_API_KEY=none + +BREX_API_URL=https://platform.brexapis.com/v2/ +BREX_API_KEY=none + +DELPHI_URL=http://localhost:59999 +DELPHI_SLACK_WEBHOOK=none + +AVALARA_1099_API_URL=https://www.track1099.com/api +AVALARA_1099_API_KEY=none +AVALARA_1099_API_TEAM_ID=none +AVALARA_1099_COMPANY_ID=207337084 + +COMPLIANCE_PAYOUT_THRESHOLD=disabled + +ANROK_API_KEY=none +ANROK_API_URL=none + +GOTENBERG_URL=http://localhost:13000 +GOTENBERG_CALLBACK_BASE=http://host.docker.internal:8000/_internal/gotenberg +GOTENBERG_TIMEOUT=30000 + +ARCHON_URL=none + +MURALPAY_API_URL=https://api-staging.muralpay.com +MURALPAY_API_KEY=none +MURALPAY_TRANSFER_API_KEY=none +MURALPAY_SOURCE_ACCOUNT_ID=none + +DEFAULT_AFFILIATE_REVENUE_SPLIT=0.1 \ No newline at end of file diff --git a/apps/labrinth/k8s/overlays/local/envfrom-patch.yaml b/apps/labrinth/k8s/overlays/local/envfrom-patch.yaml new file mode 100644 index 0000000000..78b06a798a --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/envfrom-patch.yaml @@ -0,0 +1,13 @@ +# vscode-kubernetes-tools: exclude +apiVersion: apps/v1 +kind: Deployment +metadata: + name: labrinth +spec: + template: + spec: + containers: + - name: labrinth + envFrom: + - configMapRef: + name: local-config \ No newline at end of file diff --git a/apps/labrinth/k8s/overlays/local/gateway-namespace-patch.yaml b/apps/labrinth/k8s/overlays/local/gateway-namespace-patch.yaml new file mode 100644 index 0000000000..42bdff1649 --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/gateway-namespace-patch.yaml @@ -0,0 +1,8 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: placeholder +spec: + parentRefs: + - name: main-gateway + namespace: nginx-gateway diff --git a/apps/labrinth/k8s/overlays/local/gateway.yaml b/apps/labrinth/k8s/overlays/local/gateway.yaml new file mode 100644 index 0000000000..7f6982c20e --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/gateway.yaml @@ -0,0 +1,17 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: main-gateway + namespace: nginx-gateway +spec: + gatewayClassName: nginx + listeners: + - name: http + port: 80 + protocol: HTTP + allowedRoutes: + namespaces: + from: Selector + selector: + matchLabels: + gateway-access: 'true' diff --git a/apps/labrinth/k8s/overlays/local/image-config/kustomization.example.yaml b/apps/labrinth/k8s/overlays/local/image-config/kustomization.example.yaml new file mode 100644 index 0000000000..69c0b2a1d0 --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/image-config/kustomization.example.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Component +images: + - name: labrinth + newName: modrinth.local/labrinth # Change with your local build of labrinth or a remote image build (like ghcr.io/modrinth/labrinth:main) + newTag: latest \ No newline at end of file diff --git a/apps/labrinth/k8s/overlays/local/image-config/kustomization.yaml b/apps/labrinth/k8s/overlays/local/image-config/kustomization.yaml new file mode 100644 index 0000000000..24882dfe2a --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/image-config/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +metadata: + name: image-config +images: + - name: labrinth + newName: modrinth.local/labrinth # Change with your local build of labrinth or a remote image build (like ghcr.io/modrinth/labrinth:main) + newTag: latest \ No newline at end of file diff --git a/apps/labrinth/k8s/overlays/local/kustomization.yaml b/apps/labrinth/k8s/overlays/local/kustomization.yaml new file mode 100644 index 0000000000..f2b1b443b5 --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/kustomization.yaml @@ -0,0 +1,24 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../scopes/auth + - ../../scopes/api-v3 + - ./gateway.yaml +components: + - ./image-config +configMapGenerator: + - name: local-config + envs: + - config.env +generatorOptions: + disableNameSuffixHash: true +patches: + - path: resources-patch.yaml + target: + kind: Deployment + - path: envfrom-patch.yaml + target: + kind: Deployment + - path: gateway-namespace-patch.yaml + target: + kind: HTTPRoute diff --git a/apps/labrinth/k8s/overlays/local/resources-patch.yaml b/apps/labrinth/k8s/overlays/local/resources-patch.yaml new file mode 100644 index 0000000000..51c821edf6 --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/resources-patch.yaml @@ -0,0 +1,17 @@ +# vscode-kubernetes-tools: exclude +apiVersion: apps/v1 +kind: Deployment +metadata: + name: labrinth +spec: + template: + spec: + containers: + - name: labrinth + resources: + requests: + cpu: "0.25" + memory: 64Mi + limits: + cpu: "1" + memory: 256Mi \ No newline at end of file diff --git a/apps/labrinth/k8s/overlays/local/setup-local.sh b/apps/labrinth/k8s/overlays/local/setup-local.sh new file mode 100755 index 0000000000..e562680988 --- /dev/null +++ b/apps/labrinth/k8s/overlays/local/setup-local.sh @@ -0,0 +1,17 @@ +NGINX_GATEWAY_FABRIC_TAG="v2.3.0" +GATEWAY_API_TAG="v1.4.1" + +kubectl config use-context orbstack + +# Gateway api +kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/${GATEWAY_API_TAG}/standard-install.yaml +kubectl kustomize "https://github.com/nginx/nginx-gateway-fabric/config/crd/gateway-api/standard?ref=${NGINX_GATEWAY_FABRIC_TAG}" | kubectl apply -f - +kubectl apply --server-side -f https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/${NGINX_GATEWAY_FABRIC_TAG}/deploy/crds.yaml +kubectl apply -f https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/${NGINX_GATEWAY_FABRIC_TAG}/deploy/default/deploy.yaml + +# Local overlay + +kubectl apply -k k8s/overlays/local + +# Check +kubectl get pods \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/api-v3/deployment-patch.yaml b/apps/labrinth/k8s/scopes/api-v3/deployment-patch.yaml new file mode 100644 index 0000000000..9a5a170acb --- /dev/null +++ b/apps/labrinth/k8s/scopes/api-v3/deployment-patch.yaml @@ -0,0 +1,23 @@ +# vscode-kubernetes-tools: exclude +apiVersion: apps/v1 +kind: Deployment +metadata: + name: labrinth +spec: + replicas: 3 + template: + spec: + containers: + - name: labrinth + env: + - name: REDIS_MAX_CONNECTIONS + value: "10240" + - name: DATABASE_MAX_CONNECTIONS + value: "64" + resources: + requests: + cpu: "2" + memory: 24Gi + limits: + cpu: "15" + memory: 32Gi \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/api-v3/httproute.yaml b/apps/labrinth/k8s/scopes/api-v3/httproute.yaml new file mode 100644 index 0000000000..816237ac8b --- /dev/null +++ b/apps/labrinth/k8s/scopes/api-v3/httproute.yaml @@ -0,0 +1,16 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: routes +spec: + parentRefs: + - name: main-gateway + namespace: ${GATEWAY_NAMESPACE} + rules: + - matches: + - path: + type: PathPrefix + value: /v3 + backendRefs: + - name: apiv3base-labrinth + port: 80 diff --git a/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml b/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml new file mode 100644 index 0000000000..960c9db931 --- /dev/null +++ b/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: apiv3base- +commonLabels: + scope: apiv3base +resources: + - ../../base + - httproute.yaml +patches: + - path: deployment-patch.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/auth/deployment-patch.yaml b/apps/labrinth/k8s/scopes/auth/deployment-patch.yaml new file mode 100644 index 0000000000..175fd7165c --- /dev/null +++ b/apps/labrinth/k8s/scopes/auth/deployment-patch.yaml @@ -0,0 +1,23 @@ +# vscode-kubernetes-tools: exclude +apiVersion: apps/v1 +kind: Deployment +metadata: + name: labrinth +spec: + replicas: 2 + template: + spec: + containers: + - name: labrinth + env: + - name: REDIS_MAX_CONNECTIONS + value: "1024" + - name: DATABASE_MAX_CONNECTIONS + value: "32" + resources: + requests: + cpu: "2" + memory: "4Gi" + limits: + cpu: "4" + memory: "12Gi" \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/auth/httproute.yaml b/apps/labrinth/k8s/scopes/auth/httproute.yaml new file mode 100644 index 0000000000..87a5d956b1 --- /dev/null +++ b/apps/labrinth/k8s/scopes/auth/httproute.yaml @@ -0,0 +1,25 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: routes +spec: + parentRefs: + - name: main-gateway + namespace: ${GATEWAY_NAMESPACE} + rules: + - matches: + - path: + type: Exact + value: /v3/user + - path: + type: Exact + value: /v2/user + - path: + type: PathPrefix + value: /_internal/auth + - path: + type: PathPrefix + value: /_internal/oauth + backendRefs: + - name: auth-labrinth + port: 80 \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/auth/kustomization.yaml b/apps/labrinth/k8s/scopes/auth/kustomization.yaml new file mode 100644 index 0000000000..c703b6ee24 --- /dev/null +++ b/apps/labrinth/k8s/scopes/auth/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: auth- +commonLabels: + scope: auth +resources: + - ../../base + - httproute.yaml +patches: + - path: deployment-patch.yaml \ No newline at end of file From f15139cfe1b56922cee7485a434e5385086671a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-X=2E=20T=2E?= Date: Tue, 13 Jan 2026 16:20:09 -0500 Subject: [PATCH 2/6] Fix gitignore --- apps/labrinth/k8s/overlays/local/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/labrinth/k8s/overlays/local/.gitignore b/apps/labrinth/k8s/overlays/local/.gitignore index ec8074277b..a796e43b2e 100644 --- a/apps/labrinth/k8s/overlays/local/.gitignore +++ b/apps/labrinth/k8s/overlays/local/.gitignore @@ -1,2 +1,2 @@ -image-config.yaml +image-config/kustomization.yaml config.env \ No newline at end of file From 00a67c5b2347d94bb3af7ae73d7a1ea10072df6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-X=2E=20T=2E?= Date: Tue, 13 Jan 2026 16:20:29 -0500 Subject: [PATCH 3/6] Rm --- .../k8s/overlays/local/image-config/kustomization.yaml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 apps/labrinth/k8s/overlays/local/image-config/kustomization.yaml diff --git a/apps/labrinth/k8s/overlays/local/image-config/kustomization.yaml b/apps/labrinth/k8s/overlays/local/image-config/kustomization.yaml deleted file mode 100644 index 24882dfe2a..0000000000 --- a/apps/labrinth/k8s/overlays/local/image-config/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1alpha1 -kind: Component -metadata: - name: image-config -images: - - name: labrinth - newName: modrinth.local/labrinth # Change with your local build of labrinth or a remote image build (like ghcr.io/modrinth/labrinth:main) - newTag: latest \ No newline at end of file From e9d55ed4bf3390ad2e276ed030fdb5cf80093333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-X=2E=20T=2E?= Date: Thu, 15 Jan 2026 17:19:24 -0500 Subject: [PATCH 4/6] Remove deployment patches, fix config.env example, fix image-config kustomization example --- apps/labrinth/k8s/base/deployment.yaml | 4 ++-- .../k8s/overlays/local/config.env.local | 8 +++---- .../k8s/scopes/api-v3/deployment-patch.yaml | 23 ------------------- .../k8s/scopes/api-v3/kustomization.yaml | 4 +--- .../k8s/scopes/auth/deployment-patch.yaml | 23 ------------------- .../k8s/scopes/auth/kustomization.yaml | 4 +--- 6 files changed, 8 insertions(+), 58 deletions(-) delete mode 100644 apps/labrinth/k8s/scopes/api-v3/deployment-patch.yaml delete mode 100644 apps/labrinth/k8s/scopes/auth/deployment-patch.yaml diff --git a/apps/labrinth/k8s/base/deployment.yaml b/apps/labrinth/k8s/base/deployment.yaml index 7a9781df34..37cd4c8132 100644 --- a/apps/labrinth/k8s/base/deployment.yaml +++ b/apps/labrinth/k8s/base/deployment.yaml @@ -5,7 +5,7 @@ metadata: labels: app.kubernetes.io/component: main spec: - replicas: 2 + replicas: 1 selector: matchLabels: app: labrinth @@ -26,7 +26,7 @@ spec: ports: - containerPort: 8000 name: http - resources: # Base resources for an API service, can be tweaked per scope + resources: # Base resources for an API service, should be adjusted at the overlay level requests: cpu: "2" memory: 24Gi diff --git a/apps/labrinth/k8s/overlays/local/config.env.local b/apps/labrinth/k8s/overlays/local/config.env.local index 465a07559e..26b11fee27 100644 --- a/apps/labrinth/k8s/overlays/local/config.env.local +++ b/apps/labrinth/k8s/overlays/local/config.env.local @@ -58,11 +58,11 @@ LOCAL_INDEX_INTERVAL=3600 # 30 minutes VERSION_INDEX_INTERVAL=1800 -RATE_LIMIT_IGNORE_IPS='["127.0.0.1"]' +RATE_LIMIT_IGNORE_IPS=["127.0.0.1"] -WHITELISTED_MODPACK_DOMAINS='["cdn.modrinth.com", "github.com", "raw.githubusercontent.com"]' +WHITELISTED_MODPACK_DOMAINS=["cdn.modrinth.com", "github.com", "raw.githubusercontent.com"] -ALLOWED_CALLBACK_URLS='["localhost", ".modrinth.com", "127.0.0.1", "[::1]"]' +ALLOWED_CALLBACK_URLS=["localhost", ".modrinth.com", "127.0.0.1", "[::1]"] GITHUB_CLIENT_ID=none GITHUB_CLIENT_SECRET=none @@ -112,7 +112,7 @@ SENDY_URL=none SENDY_LIST_ID=none SENDY_API_KEY=none -ANALYTICS_ALLOWED_ORIGINS='["http://127.0.0.1:3000", "http://localhost:3000", "https://modrinth.com", "https://www.modrinth.com", "*"]' +ANALYTICS_ALLOWED_ORIGINS=["http://127.0.0.1:3000", "http://localhost:3000", "https://modrinth.com", "https://www.modrinth.com", "*"] CLICKHOUSE_REPLICATED=false CLICKHOUSE_URL=http://localhost:8123 diff --git a/apps/labrinth/k8s/scopes/api-v3/deployment-patch.yaml b/apps/labrinth/k8s/scopes/api-v3/deployment-patch.yaml deleted file mode 100644 index 9a5a170acb..0000000000 --- a/apps/labrinth/k8s/scopes/api-v3/deployment-patch.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# vscode-kubernetes-tools: exclude -apiVersion: apps/v1 -kind: Deployment -metadata: - name: labrinth -spec: - replicas: 3 - template: - spec: - containers: - - name: labrinth - env: - - name: REDIS_MAX_CONNECTIONS - value: "10240" - - name: DATABASE_MAX_CONNECTIONS - value: "64" - resources: - requests: - cpu: "2" - memory: 24Gi - limits: - cpu: "15" - memory: 32Gi \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml b/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml index 960c9db931..6186bf15bd 100644 --- a/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml +++ b/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml @@ -5,6 +5,4 @@ commonLabels: scope: apiv3base resources: - ../../base - - httproute.yaml -patches: - - path: deployment-patch.yaml \ No newline at end of file + - httproute.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/auth/deployment-patch.yaml b/apps/labrinth/k8s/scopes/auth/deployment-patch.yaml deleted file mode 100644 index 175fd7165c..0000000000 --- a/apps/labrinth/k8s/scopes/auth/deployment-patch.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# vscode-kubernetes-tools: exclude -apiVersion: apps/v1 -kind: Deployment -metadata: - name: labrinth -spec: - replicas: 2 - template: - spec: - containers: - - name: labrinth - env: - - name: REDIS_MAX_CONNECTIONS - value: "1024" - - name: DATABASE_MAX_CONNECTIONS - value: "32" - resources: - requests: - cpu: "2" - memory: "4Gi" - limits: - cpu: "4" - memory: "12Gi" \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/auth/kustomization.yaml b/apps/labrinth/k8s/scopes/auth/kustomization.yaml index c703b6ee24..ae51e818c2 100644 --- a/apps/labrinth/k8s/scopes/auth/kustomization.yaml +++ b/apps/labrinth/k8s/scopes/auth/kustomization.yaml @@ -5,6 +5,4 @@ commonLabels: scope: auth resources: - ../../base - - httproute.yaml -patches: - - path: deployment-patch.yaml \ No newline at end of file + - httproute.yaml \ No newline at end of file From f93527078ba0919de328701d3b794982a77b4a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-X=2E=20T=2E?= Date: Thu, 15 Jan 2026 17:26:30 -0500 Subject: [PATCH 5/6] Fix kustomization --- .../overlays/local/image-config/kustomization.example.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/labrinth/k8s/overlays/local/image-config/kustomization.example.yaml b/apps/labrinth/k8s/overlays/local/image-config/kustomization.example.yaml index 69c0b2a1d0..9803b87f06 100644 --- a/apps/labrinth/k8s/overlays/local/image-config/kustomization.example.yaml +++ b/apps/labrinth/k8s/overlays/local/image-config/kustomization.example.yaml @@ -1,5 +1,5 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Component +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Componen images: - name: labrinth newName: modrinth.local/labrinth # Change with your local build of labrinth or a remote image build (like ghcr.io/modrinth/labrinth:main) From 28a938dcc57099339d4c3adc46134c2e788b8af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-X=2E=20T=2E?= Date: Thu, 15 Jan 2026 17:54:34 -0500 Subject: [PATCH 6/6] Rest of the scopes --- .../k8s/overlays/local/kustomization.yaml | 8 ++++- apps/labrinth/k8s/scopes/apis/httproute.yaml | 29 +++++++++++++++++++ .../{api-v3 => apis}/kustomization.yaml | 4 +-- .../k8s/scopes/billing/httproute.yaml | 19 ++++++++++++ .../k8s/scopes/billing/kustomization.yaml | 8 +++++ .../k8s/scopes/friends/httproute.yaml | 19 ++++++++++++ .../k8s/scopes/friends/kustomization.yaml | 8 +++++ apps/labrinth/k8s/scopes/teams/httproute.yaml | 19 ++++++++++++ .../k8s/scopes/teams/kustomization.yaml | 8 +++++ .../k8s/scopes/version_files/httproute.yaml | 19 ++++++++++++ .../scopes/version_files/kustomization.yaml | 8 +++++ .../k8s/scopes/webhooks/httproute.yaml | 26 +++++++++++++++++ .../k8s/scopes/webhooks/kustomization.yaml | 8 +++++ .../{api-v3 => websocket}/httproute.yaml | 6 ++-- .../k8s/scopes/websocket/kustomization.yaml | 8 +++++ 15 files changed, 191 insertions(+), 6 deletions(-) create mode 100644 apps/labrinth/k8s/scopes/apis/httproute.yaml rename apps/labrinth/k8s/scopes/{api-v3 => apis}/kustomization.yaml (74%) create mode 100644 apps/labrinth/k8s/scopes/billing/httproute.yaml create mode 100644 apps/labrinth/k8s/scopes/billing/kustomization.yaml create mode 100644 apps/labrinth/k8s/scopes/friends/httproute.yaml create mode 100644 apps/labrinth/k8s/scopes/friends/kustomization.yaml create mode 100644 apps/labrinth/k8s/scopes/teams/httproute.yaml create mode 100644 apps/labrinth/k8s/scopes/teams/kustomization.yaml create mode 100644 apps/labrinth/k8s/scopes/version_files/httproute.yaml create mode 100644 apps/labrinth/k8s/scopes/version_files/kustomization.yaml create mode 100644 apps/labrinth/k8s/scopes/webhooks/httproute.yaml create mode 100644 apps/labrinth/k8s/scopes/webhooks/kustomization.yaml rename apps/labrinth/k8s/scopes/{api-v3 => websocket}/httproute.yaml (69%) create mode 100644 apps/labrinth/k8s/scopes/websocket/kustomization.yaml diff --git a/apps/labrinth/k8s/overlays/local/kustomization.yaml b/apps/labrinth/k8s/overlays/local/kustomization.yaml index f2b1b443b5..1de2ead1af 100644 --- a/apps/labrinth/k8s/overlays/local/kustomization.yaml +++ b/apps/labrinth/k8s/overlays/local/kustomization.yaml @@ -1,8 +1,14 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - ../../scopes/apis - ../../scopes/auth - - ../../scopes/api-v3 + - ../../scopes/billing + - ../../scopes/friends + - ../../scopes/teams + - ../../scopes/version_files + - ../../scopes/webhooks + - ../../scopes/websocket - ./gateway.yaml components: - ./image-config diff --git a/apps/labrinth/k8s/scopes/apis/httproute.yaml b/apps/labrinth/k8s/scopes/apis/httproute.yaml new file mode 100644 index 0000000000..b1c80da07c --- /dev/null +++ b/apps/labrinth/k8s/scopes/apis/httproute.yaml @@ -0,0 +1,29 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: routes +spec: + parentRefs: + - name: main-gateway + namespace: ${GATEWAY_NAMESPACE} + rules: + - matches: + - path: + type: PathPrefix + value: /v3 + - path: + type: PathPrefix + value: /v2 + - path: + type: PathPrefix + value: /api/v1 + - path: + type: PathPrefix + value: /_internal + # Use this service as a fallback for all other routes + - path: + type: PathPrefix + value: / + backendRefs: + - name: api-labrinth + port: 80 diff --git a/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml b/apps/labrinth/k8s/scopes/apis/kustomization.yaml similarity index 74% rename from apps/labrinth/k8s/scopes/api-v3/kustomization.yaml rename to apps/labrinth/k8s/scopes/apis/kustomization.yaml index 6186bf15bd..d3fe8062a0 100644 --- a/apps/labrinth/k8s/scopes/api-v3/kustomization.yaml +++ b/apps/labrinth/k8s/scopes/apis/kustomization.yaml @@ -1,8 +1,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -namePrefix: apiv3base- +namePrefix: api- commonLabels: - scope: apiv3base + scope: api resources: - ../../base - httproute.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/billing/httproute.yaml b/apps/labrinth/k8s/scopes/billing/httproute.yaml new file mode 100644 index 0000000000..b11fa848d8 --- /dev/null +++ b/apps/labrinth/k8s/scopes/billing/httproute.yaml @@ -0,0 +1,19 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: routes +spec: + parentRefs: + - name: main-gateway + namespace: ${GATEWAY_NAMESPACE} + rules: + - matches: + - path: + type: PathPrefix + value: /_internal/billing + - path: + type: Exact + value: /_internal/_stripe + backendRefs: + - name: billing-labrinth + port: 80 diff --git a/apps/labrinth/k8s/scopes/billing/kustomization.yaml b/apps/labrinth/k8s/scopes/billing/kustomization.yaml new file mode 100644 index 0000000000..a47c329732 --- /dev/null +++ b/apps/labrinth/k8s/scopes/billing/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: billing- +commonLabels: + scope: billing +resources: + - ../../base + - httproute.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/friends/httproute.yaml b/apps/labrinth/k8s/scopes/friends/httproute.yaml new file mode 100644 index 0000000000..f90bc37e92 --- /dev/null +++ b/apps/labrinth/k8s/scopes/friends/httproute.yaml @@ -0,0 +1,19 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: routes +spec: + parentRefs: + - name: main-gateway + namespace: ${GATEWAY_NAMESPACE} + rules: + - matches: + - path: + type: PathPrefix + value: /v3/friends + - path: + type: PathPrefix + value: /v3/friend + backendRefs: + - name: friends-labrinth + port: 80 diff --git a/apps/labrinth/k8s/scopes/friends/kustomization.yaml b/apps/labrinth/k8s/scopes/friends/kustomization.yaml new file mode 100644 index 0000000000..e2c0bc9b00 --- /dev/null +++ b/apps/labrinth/k8s/scopes/friends/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: friends- +commonLabels: + scope: friends +resources: + - ../../base + - httproute.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/teams/httproute.yaml b/apps/labrinth/k8s/scopes/teams/httproute.yaml new file mode 100644 index 0000000000..52596eb66b --- /dev/null +++ b/apps/labrinth/k8s/scopes/teams/httproute.yaml @@ -0,0 +1,19 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: routes +spec: + parentRefs: + - name: main-gateway + namespace: ${GATEWAY_NAMESPACE} + rules: + - matches: + - path: + type: Exact + value: /v3/teams + - path: + type: Exact + value: /v2/teams + backendRefs: + - name: teams-labrinth + port: 80 diff --git a/apps/labrinth/k8s/scopes/teams/kustomization.yaml b/apps/labrinth/k8s/scopes/teams/kustomization.yaml new file mode 100644 index 0000000000..ccf10f7f40 --- /dev/null +++ b/apps/labrinth/k8s/scopes/teams/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: teams- +commonLabels: + scope: teams +resources: + - ../../base + - httproute.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/version_files/httproute.yaml b/apps/labrinth/k8s/scopes/version_files/httproute.yaml new file mode 100644 index 0000000000..6758f126f0 --- /dev/null +++ b/apps/labrinth/k8s/scopes/version_files/httproute.yaml @@ -0,0 +1,19 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: routes +spec: + parentRefs: + - name: main-gateway + namespace: ${GATEWAY_NAMESPACE} + rules: + - matches: + - path: + type: Exact + value: /v3/version_files + - path: + type: Exact + value: /v2/version_files + backendRefs: + - name: version-files-labrinth + port: 80 diff --git a/apps/labrinth/k8s/scopes/version_files/kustomization.yaml b/apps/labrinth/k8s/scopes/version_files/kustomization.yaml new file mode 100644 index 0000000000..83525a855d --- /dev/null +++ b/apps/labrinth/k8s/scopes/version_files/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: version-files- +commonLabels: + scope: version-files +resources: + - ../../base + - httproute.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/webhooks/httproute.yaml b/apps/labrinth/k8s/scopes/webhooks/httproute.yaml new file mode 100644 index 0000000000..8c19c6ea8e --- /dev/null +++ b/apps/labrinth/k8s/scopes/webhooks/httproute.yaml @@ -0,0 +1,26 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: routes +spec: + parentRefs: + - name: main-gateway + namespace: ${GATEWAY_NAMESPACE} + rules: + - matches: + # The _stripe webhook is in the billing scope + - path: + type: Exact + value: /_internal/gotenberg/success + - path: + type: Exact + value: /_internal/gotenberg/error + - path: + type: Exact + value: /v3/payout/_paypal + - path: + type: Exact + value: /v3/payout/_tremendous + backendRefs: + - name: webhooks-labrinth + port: 80 diff --git a/apps/labrinth/k8s/scopes/webhooks/kustomization.yaml b/apps/labrinth/k8s/scopes/webhooks/kustomization.yaml new file mode 100644 index 0000000000..49f3417566 --- /dev/null +++ b/apps/labrinth/k8s/scopes/webhooks/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: webhooks- +commonLabels: + scope: webhooks +resources: + - ../../base + - httproute.yaml \ No newline at end of file diff --git a/apps/labrinth/k8s/scopes/api-v3/httproute.yaml b/apps/labrinth/k8s/scopes/websocket/httproute.yaml similarity index 69% rename from apps/labrinth/k8s/scopes/api-v3/httproute.yaml rename to apps/labrinth/k8s/scopes/websocket/httproute.yaml index 816237ac8b..24da8c336c 100644 --- a/apps/labrinth/k8s/scopes/api-v3/httproute.yaml +++ b/apps/labrinth/k8s/scopes/websocket/httproute.yaml @@ -9,8 +9,8 @@ spec: rules: - matches: - path: - type: PathPrefix - value: /v3 + type: Exact + value: /_internal/launcher_socket backendRefs: - - name: apiv3base-labrinth + - name: websocket-labrinth port: 80 diff --git a/apps/labrinth/k8s/scopes/websocket/kustomization.yaml b/apps/labrinth/k8s/scopes/websocket/kustomization.yaml new file mode 100644 index 0000000000..ab7c7d92a8 --- /dev/null +++ b/apps/labrinth/k8s/scopes/websocket/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namePrefix: websocket- +commonLabels: + scope: websocket +resources: + - ../../base + - httproute.yaml \ No newline at end of file