Vitron-Front/k8s/prod/frontend-prod.yaml
2026-04-29 01:44:16 +03:30

176 lines
3.9 KiB
YAML

# Production Frontend Configuration
# Optimized for high availability and performance
---
apiVersion: v1
kind: ConfigMap
metadata:
name: frontend-config
namespace: vitrown-prod
data:
NODE_ENV: "production"
VITE_API_BASE_URL: "https://api.vitrown.com"
VITE_API_SOCKET_BASE_URL: "wss://api.vitrown.com"
VITE_API_URL: "https://api.vitrown.com"
VITE_SITE_URL: "https://vitrown.com"
VITE_DOMAIN_URL: "https://vitrown.com"
VITE_APP_VERSION_TYPE: "production"
VITE_SUPPORT_PHONE: "+989223740993"
VITE_BUILD_TARGET: "production"
# Internal API URL for server-side requests (SSR) to avoid hairpin NAT issues
INTERNAL_API_URL: "http://django-backend:8000"
---
apiVersion: v1
kind: Secret
metadata:
name: frontend-secret
namespace: vitrown-prod
type: Opaque
stringData:
# IMPORTANT: Replace with secure production secret
REMIX_SECRET: "CHANGE_ME_TO_SECURE_PRODUCTION_SECRET"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
namespace: vitrown-prod
labels:
app: frontend
environment: production
spec:
replicas: 3
selector:
matchLabels:
app: frontend
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: frontend
environment: production
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- frontend
topologyKey: kubernetes.io/hostname
containers:
- name: frontend
image: harbor.abrino.cloud/sotoontech/vitron-frontend:latest
ports:
- containerPort: 3000
name: http
protocol: TCP
envFrom:
- configMapRef:
name: frontend-config
- secretRef:
name: frontend-secret
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "1000m"
livenessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 30
periodSeconds: 15
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
imagePullSecrets:
- name: harbor-registry
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
name: frontend
namespace: vitrown-prod
spec:
selector:
app: frontend
ports:
- protocol: TCP
port: 3000
targetPort: 3000
type: ClusterIP
---
# Horizontal Pod Autoscaler for Production
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: frontend-hpa
namespace: vitrown-prod
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: frontend
minReplicas: 3
maxReplicas: 8
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 25
periodSeconds: 60
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 15
- type: Pods
value: 2
periodSeconds: 15
selectPolicy: Max
---
# Pod Disruption Budget for high availability
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: frontend-pdb
namespace: vitrown-prod
spec:
minAvailable: 2
selector:
matchLabels:
app: frontend