Files
links/k8s/manifest.yaml
T
2024-11-09 08:59:48 +11:00

300 lines
7.7 KiB
YAML

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: 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
env:
- 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"
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/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"
# Skip authentication for /public, but looks like doesn't work
nginx.ingress.kubernetes.io/auth-snippet: |
if ($request_uri ~ "/public") {
return 200;
}
spec:
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"
spec:
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"
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: Exact
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: 1000m
memory: 1000Mi
- 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