Files
links/k8s/manifest.yaml
T
2025-08-09 21:27:43 +10:00

362 lines
9.6 KiB
YAML

apiVersion: v1
kind: PersistentVolume
metadata:
name: downloads-nfs-apps
spec:
capacity:
storage: 4500Gi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.1.4
path: "/downloads"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: "downloads-nfs-apps"
spec:
storageClassName: ""
accessModes:
- ReadWriteMany
resources:
requests:
storage: 4500Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: links-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: nfs-client
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: links
labels:
tags.datadoghq.com/env: "prod"
tags.datadoghq.com/service: "links"
spec:
selector:
matchLabels:
app: links
replicas: 1
template:
metadata:
labels:
app: links
tags.datadoghq.com/env: "prod"
tags.datadoghq.com/service: "links"
spec:
volumes:
- name: downloads
persistentVolumeClaim:
claimName: downloads-nfs-apps
- name: data
persistentVolumeClaim:
claimName: links-pvc
- name: cache
emptyDir: {}
initContainers:
- name: links-init
image: "ghcr.io/wahyd4/links:main"
command: ["sh", "-c", "uv run manage.py migrate && uv run manage.py collectstatic --noinput"]
volumeMounts:
- name: data
mountPath: /app/data
containers:
- name: links
image: "ghcr.io/wahyd4/links:main"
securityContext:
runAsUser: 1000
imagePullPolicy: Always
volumeMounts:
- name: data
mountPath: /app/data
- name: cache
mountPath: /app/.cache
- name: downloads
subPath: ftp/images
mountPath: /images
env:
- name : DEBUG
value: "false"
- name: R2_CUSTOM_DOMAIN
value: home-links-prod.junv.cc
- name: DB_HOST
value: new-postgres-postgresql.db.svc.cluster.local
- name: DB_NAME
value: badges
- name: DB_USERNAME
value: postgres
# - name: DB_PASSWORD
# valueFrom:
# { secretKeyRef: { name: database-credentials, key: password } }
- name: CSRF_TRUSTED_ORIGINS
value: "https://to.junv.cc,https://go.junv.cc,http://go"
- name: CELERY_BROKER_URL
value: "redis://redis-master.db.svc.cluster.local:6379"
- name: CELERY_RESULT_BACKEND
value: "redis://redis-master.db.svc.cluster.local:6379"
- name: UV_CACHE_DIR
value: "/app/.cache/uv"
- name: R2_BUCKET_NAME
value: "home-links-prod"
- name: R2_ENDPOINT_URL
value: https://d39b5aca439164602c01f7af2a58d4bf.r2.cloudflarestorage.com
- name: IMAGES_FOLDER
value: "/images"
- name: R2_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: r2-credentials
key: access_key
- name: R2_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: r2-credentials
key: key_id
ports:
- containerPort: 8000
name: links-port
protocol: TCP
resources:
requests:
cpu: 200m
memory: 400Mi
limits:
cpu: 1000m
memory: 1000Mi
imagePullSecrets:
- name: github-image-pull-secret
---
apiVersion: v1
kind: Service
metadata:
name: links
labels:
app: links
spec:
type: ClusterIP
ports:
- port: 80
targetPort: links-port
protocol: TCP
name: web
selector:
app: links
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: links-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
kubernetes.io/tls-acme: "true"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/proxy-body-size: 1024m
# nginx.ingress.kubernetes.io/auth-url: "https://id.junv.cc/oauth2/auth"
# nginx.ingress.kubernetes.io/auth-signin: "https://id.junv.cc/oauth2/start?rd=https%3A%2F%2F$host$request_uri"
nginx.ingress.kubernetes.io/auth-url: "https://pass.junv.cc/auth"
nginx.ingress.kubernetes.io/auth-signin: "https://pass.junv.cc/?redirect=https%3A%2F%2F$host$request_uri"
# Skip authentication for /public, but looks like doesn't work
# nginx.ingress.kubernetes.io/auth-snippet: |
# if ($request_uri ~ "/public") {
# return 200;
# }
spec:
ingressClassName: nginx
tls:
- hosts:
- to.junv.cc
- go.junv.cc
secretName: links-tls
rules:
- host: go.junv.cc
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: links
port:
number: 80
- host: to.junv.cc
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: links
port:
number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: go-links-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
kubernetes.io/tls-acme: "false"
nginx.ingress.kubernetes.io/proxy-body-size: 1024m
spec:
ingressClassName: nginx
rules:
- host: go
http:
paths:
- backend:
service:
name: links
port:
number: 80
path: /
pathType: Prefix
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: public-links-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
kubernetes.io/tls-acme: "true"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/proxy-body-size: 100m
spec:
tls:
- hosts:
- xgo.junv.cc
secretName: public-links-tls
rules:
- host: xgo.junv.cc
http:
paths:
- path: /public
pathType: Prefix
backend:
service:
name: links
port:
number: 80
- path: /static
pathType: Prefix
backend:
service:
name: links
port:
number: 80
- path: /favicon.ico
pathType: Prefix
backend:
service:
name: links
port:
number: 80
---
# apiVersion: apps/v1
# kind: Deployment
# metadata:
# name: links-worker
# labels:
# tags.datadoghq.com/env: "prod"
# tags.datadoghq.com/service: "links-worker"
# spec:
# selector:
# matchLabels:
# app: links-worker
# replicas: 1
# template:
# metadata:
# labels:
# app: links-worker
# tags.datadoghq.com/env: "prod"
# tags.datadoghq.com/service: "links-worker"
# spec:
# volumes:
# - name: data
# persistentVolumeClaim:
# claimName: links-pvc
# - name: cache
# emptyDir: {}
# containers:
# - name: celery-worker
# image: "ghcr.io/wahyd4/links:main"
# command: ["sh", "-c", "uv run celery -A core worker --loglevel=info"]
# securityContext:
# runAsUser: 1000
# imagePullPolicy: Always
# volumeMounts:
# - name: data
# mountPath: /app/data
# - name: cache
# mountPath: /app/.cache
# env:
# - name: DB_HOST
# value: new-postgres-postgresql.db.svc.cluster.local
# - name: DB_NAME
# value: badges
# - name: DB_USERNAME
# value: postgres
# - name: CELERY_BROKER_URL
# value: "redis://redis-master.db.svc.cluster.local:6379"
# - name: CELERY_RESULT_BACKEND
# value: "redis://redis-master.db.svc.cluster.local:6379"
# - name: UV_CACHE_DIR
# value: "/app/.cache/uv"
# resources:
# requests:
# cpu: 200m
# memory: 256Mi
# limits:
# cpu: 2000m
# memory: 2000Mi
# - name: celery-beat
# image: "ghcr.io/wahyd4/links:main"
# command: ["sh", "-c", "uv run celery -A core beat -s /app/data/celerybeat-schedule --loglevel=info"]
# securityContext:
# runAsUser: 1000
# imagePullPolicy: Always
# volumeMounts:
# - name: data
# mountPath: /app/data
# - name: cache
# mountPath: /app/.cache
# env:
# - name: DB_HOST
# value: new-postgres-postgresql.db.svc.cluster.local
# - name: DB_NAME
# value: badges
# - name: DB_USERNAME
# value: postgres
# - name: CELERY_BROKER_URL
# value: "redis://redis-master.db.svc.cluster.local:6379"
# - name: CELERY_RESULT_BACKEND
# value: "redis://redis-master.db.svc.cluster.local:6379"
# - name: UV_CACHE_DIR
# value: "/app/.cache/uv"
# resources:
# requests:
# cpu: 200m
# memory: 256Mi
# limits:
# cpu: 1000m
# memory: 1000Mi
# imagePullSecrets:
# - name: github-image-pull-secret