r2
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: vitfit
|
||||
@@ -0,0 +1,18 @@
|
||||
# Persistent storage for SQLite database + uploaded videos.
|
||||
# SQLite requires ReadWriteOnce — this limits the Deployment to a single replica.
|
||||
# If you need horizontal scaling in the future, migrate to PostgreSQL and use
|
||||
# a separate object store (S3-compatible) for uploads.
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: vitfit-data
|
||||
namespace: vitfit
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 20Gi
|
||||
# Set storageClassName to match your cluster's provisioner.
|
||||
# Leave blank to use the default StorageClass.
|
||||
# storageClassName: standard
|
||||
@@ -0,0 +1,19 @@
|
||||
# Non-sensitive environment variables.
|
||||
# Sensitive values (JWT_SECRET, etc.) go in 03-secret.yaml.
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: vitfit-config
|
||||
namespace: vitfit
|
||||
data:
|
||||
NODE_ENV: "production"
|
||||
PORT: "3000"
|
||||
DB_PATH: "/data/vitfit.sqlite"
|
||||
UPLOADS_DIR: "/data/uploads"
|
||||
UPLOAD_TEMP_DIR: "/data/tmp"
|
||||
LOG_LEVEL: "info"
|
||||
# Set to your domain: https://your.domain.com
|
||||
CORS_ORIGIN: "https://your.domain.com"
|
||||
# Storage warning threshold in bytes (default 10 GB)
|
||||
STORAGE_WARN_BYTES: "10737418240"
|
||||
UPLOAD_MAX_BYTES: "2147483648"
|
||||
@@ -0,0 +1,18 @@
|
||||
# TEMPLATE — do not commit real values.
|
||||
# Generate and apply this manually:
|
||||
#
|
||||
# kubectl create secret generic vitfit-secrets \
|
||||
# --namespace=vitfit \
|
||||
# --from-literal=JWT_SECRET="$(openssl rand -hex 64)" \
|
||||
# --dry-run=client -o yaml | kubectl apply -f -
|
||||
#
|
||||
# Or fill in base64-encoded values below (echo -n 'value' | base64):
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: vitfit-secrets
|
||||
namespace: vitfit
|
||||
type: Opaque
|
||||
data:
|
||||
# base64-encoded values — replace before applying
|
||||
JWT_SECRET: REPLACE_WITH_BASE64_ENCODED_SECRET
|
||||
@@ -0,0 +1,76 @@
|
||||
# Single replica required — SQLite (ReadWriteOnce PVC) cannot be shared across pods.
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: vitfit
|
||||
namespace: vitfit
|
||||
labels:
|
||||
app: vitfit
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: vitfit
|
||||
# Recreate ensures the old pod releases the PVC before the new one starts.
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: vitfit
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
fsGroup: 1000
|
||||
|
||||
containers:
|
||||
- name: app
|
||||
image: vitfit:latest # replace with your registry path
|
||||
imagePullPolicy: Always
|
||||
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
name: http
|
||||
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: vitfit-config
|
||||
- secretRef:
|
||||
name: vitfit-secrets
|
||||
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: "250m"
|
||||
memory: "256Mi"
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: "512Mi"
|
||||
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 3000
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 3000
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: vitfit-data
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: vitfit
|
||||
namespace: vitfit
|
||||
labels:
|
||||
app: vitfit
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: vitfit
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 3000
|
||||
@@ -0,0 +1,42 @@
|
||||
# cert-manager ClusterIssuers — requires cert-manager to be installed in the cluster.
|
||||
# Install cert-manager: https://cert-manager.io/docs/installation/
|
||||
#
|
||||
# Apply staging first to verify ACME account + DNS, then switch Ingress to prod.
|
||||
#
|
||||
# Usage:
|
||||
# kubectl apply -f 06-cluster-issuer.yaml
|
||||
# # verify: kubectl describe clusterissuer letsencrypt-staging
|
||||
|
||||
---
|
||||
# Staging — safe for testing (not trusted by browsers, no rate limits)
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: ClusterIssuer
|
||||
metadata:
|
||||
name: letsencrypt-staging
|
||||
spec:
|
||||
acme:
|
||||
server: https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
email: admin@your.domain.com # replace with your email
|
||||
privateKeySecretRef:
|
||||
name: letsencrypt-staging-key
|
||||
solvers:
|
||||
- http01:
|
||||
ingress:
|
||||
ingressClassName: nginx
|
||||
|
||||
---
|
||||
# Production — real trusted certs, rate-limited (5 failures/hour per domain)
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: ClusterIssuer
|
||||
metadata:
|
||||
name: letsencrypt-prod
|
||||
spec:
|
||||
acme:
|
||||
server: https://acme-v02.api.letsencrypt.org/directory
|
||||
email: admin@your.domain.com # replace with your email
|
||||
privateKeySecretRef:
|
||||
name: letsencrypt-prod-key
|
||||
solvers:
|
||||
- http01:
|
||||
ingress:
|
||||
ingressClassName: nginx
|
||||
@@ -0,0 +1,54 @@
|
||||
# Nginx Ingress with TLS.
|
||||
#
|
||||
# ── Option A: Let's Encrypt (cert-manager) ────────────────────────────────────
|
||||
# Requires cert-manager + ClusterIssuer from 06-cluster-issuer.yaml.
|
||||
# Switch between staging and prod by changing the annotation value.
|
||||
# cert-manager will auto-create the Secret named in tls.secretName.
|
||||
#
|
||||
# ── Option B: Custom / uploaded certificate ───────────────────────────────────
|
||||
# 1. Remove (or comment out) the cert-manager annotation.
|
||||
# 2. Pre-create the TLS Secret:
|
||||
# kubectl create secret tls vitfit-tls \
|
||||
# --namespace=vitfit \
|
||||
# --cert=/path/to/your.crt \
|
||||
# --key=/path/to/your.key
|
||||
# 3. The tls.secretName below stays the same — no other changes needed.
|
||||
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: vitfit
|
||||
namespace: vitfit
|
||||
annotations:
|
||||
# ── [LE] cert-manager — comment out for custom cert (Option B)
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
|
||||
# WebSocket support (socket.io)
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
|
||||
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
|
||||
nginx.ingress.kubernetes.io/proxy-buffering: "off"
|
||||
|
||||
# Video upload size — match UPLOAD_MAX_BYTES
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: "2100m"
|
||||
|
||||
# Force HTTPS
|
||||
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
tls:
|
||||
- hosts:
|
||||
- your.domain.com # replace with your domain
|
||||
secretName: vitfit-tls # cert-manager creates this (LE) or you create it (custom)
|
||||
rules:
|
||||
- host: your.domain.com # replace with your domain
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: vitfit
|
||||
port:
|
||||
name: http
|
||||
Reference in New Issue
Block a user