Skip to content
Open
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
57 changes: 57 additions & 0 deletions apps/labrinth/k8s/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: labrinth
labels:
app.kubernetes.io/component: main
spec:
replicas: 1
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, should be adjusted at the overlay level
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
5 changes: 5 additions & 0 deletions apps/labrinth/k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
10 changes: 10 additions & 0 deletions apps/labrinth/k8s/base/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: labrinth
spec:
selector:
app: labrinth
ports:
- port: 80
targetPort: 8000
2 changes: 2 additions & 0 deletions apps/labrinth/k8s/overlays/local/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
image-config/kustomization.yaml
config.env
159 changes: 159 additions & 0 deletions apps/labrinth/k8s/overlays/local/config.env.local
Original file line number Diff line number Diff line change
@@ -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
[email protected]
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
13 changes: 13 additions & 0 deletions apps/labrinth/k8s/overlays/local/envfrom-patch.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions apps/labrinth/k8s/overlays/local/gateway-namespace-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: placeholder
spec:
parentRefs:
- name: main-gateway
namespace: nginx-gateway
17 changes: 17 additions & 0 deletions apps/labrinth/k8s/overlays/local/gateway.yaml
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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)
newTag: latest
30 changes: 30 additions & 0 deletions apps/labrinth/k8s/overlays/local/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../scopes/apis
- ../../scopes/auth
- ../../scopes/billing
- ../../scopes/friends
- ../../scopes/teams
- ../../scopes/version_files
- ../../scopes/webhooks
- ../../scopes/websocket
- ./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
17 changes: 17 additions & 0 deletions apps/labrinth/k8s/overlays/local/resources-patch.yaml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions apps/labrinth/k8s/overlays/local/setup-local.sh
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions apps/labrinth/k8s/scopes/apis/httproute.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading