Add client production url to allowed cors
This commit is contained in:
parent
7c2a38788b
commit
a1e6c1289f
@ -7,7 +7,7 @@ class Settings(BaseSettings):
|
||||
jwt_secret: str = "your-secret-key-change-in-production"
|
||||
jwt_expires_minutes: int = 1440
|
||||
media_dir: str = "./media"
|
||||
cors_origins: str = "http://localhost:5173,http://localhost:3000,http://localhost"
|
||||
cors_origins: str = "http://localhost:5173,http://localhost:3000,http://localhost,https://dateme.dvirlabs.com"
|
||||
|
||||
class Config:
|
||||
env_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".env")
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
apiVersion: v2
|
||||
name: dating-app
|
||||
description: MVP dating app Helm chart for Kubernetes deployment
|
||||
type: application
|
||||
version: 1.0.0
|
||||
appVersion: "1.0.0"
|
||||
keywords:
|
||||
- dating
|
||||
- social
|
||||
- chat
|
||||
maintainers:
|
||||
- name: DevOps Team
|
||||
@ -1,201 +0,0 @@
|
||||
# Helm Chart README
|
||||
|
||||
## Dating App Helm Chart
|
||||
|
||||
This Helm chart deploys the MVP dating application to Kubernetes with all necessary components.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Kubernetes 1.19+
|
||||
- Helm 3.0+
|
||||
- Nginx Ingress Controller (for ingress)
|
||||
- Storage provisioner (for PVC)
|
||||
|
||||
### Installation
|
||||
|
||||
#### Basic Installation (Development)
|
||||
|
||||
```bash
|
||||
# Install with default values
|
||||
helm install dating-app ./helm/dating-app -n dating-app --create-namespace
|
||||
```
|
||||
|
||||
#### Production Installation with Custom Values
|
||||
|
||||
```bash
|
||||
# Create custom values file
|
||||
cp helm/dating-app/values.yaml my-values.yaml
|
||||
|
||||
# Edit my-values.yaml with your configuration
|
||||
# Then install
|
||||
helm install dating-app ./helm/dating-app -n dating-app --create-namespace -f my-values.yaml
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
Edit `values.yaml` to customize:
|
||||
|
||||
#### Ingress Hosts
|
||||
```yaml
|
||||
backend:
|
||||
ingress:
|
||||
host: api.yourdomain.com
|
||||
|
||||
frontend:
|
||||
ingress:
|
||||
host: app.yourdomain.com
|
||||
```
|
||||
|
||||
#### Database
|
||||
```yaml
|
||||
postgres:
|
||||
credentials:
|
||||
username: your_user
|
||||
password: your_password
|
||||
database: your_db
|
||||
```
|
||||
|
||||
#### Backend Environment
|
||||
```yaml
|
||||
backend:
|
||||
environment:
|
||||
JWT_SECRET: your-secret-key
|
||||
CORS_ORIGINS: "https://app.yourdomain.com"
|
||||
```
|
||||
|
||||
#### Frontend API URL
|
||||
```yaml
|
||||
frontend:
|
||||
environment:
|
||||
VITE_API_URL: "https://api.yourdomain.com"
|
||||
```
|
||||
|
||||
#### Storage Classes
|
||||
For cloud deployments (AWS, GCP, etc.), specify storage class:
|
||||
```yaml
|
||||
backend:
|
||||
persistence:
|
||||
storageClass: ebs-sc # AWS EBS
|
||||
size: 10Gi
|
||||
|
||||
postgres:
|
||||
persistence:
|
||||
storageClass: ebs-sc
|
||||
size: 20Gi
|
||||
```
|
||||
|
||||
#### Replicas and Resources
|
||||
```yaml
|
||||
backend:
|
||||
replicas: 3
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "200m"
|
||||
limits:
|
||||
memory: "1Gi"
|
||||
cpu: "500m"
|
||||
|
||||
frontend:
|
||||
replicas: 2
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "200m"
|
||||
```
|
||||
|
||||
### Upgrading
|
||||
|
||||
```bash
|
||||
helm upgrade dating-app ./helm/dating-app -f my-values.yaml
|
||||
```
|
||||
|
||||
### Uninstalling
|
||||
|
||||
```bash
|
||||
helm uninstall dating-app -n dating-app
|
||||
```
|
||||
|
||||
### AWS Migration
|
||||
|
||||
To deploy to AWS:
|
||||
|
||||
1. **RDS for PostgreSQL**: Disable postgres in chart
|
||||
```yaml
|
||||
postgres:
|
||||
enabled: false
|
||||
```
|
||||
|
||||
2. **Update database URL** to RDS endpoint
|
||||
```yaml
|
||||
backend:
|
||||
environment:
|
||||
DATABASE_URL: "postgresql://user:password@your-rds-endpoint:5432/dating_app"
|
||||
```
|
||||
|
||||
3. **S3 for Media Storage**: Update backend environment
|
||||
```yaml
|
||||
backend:
|
||||
environment:
|
||||
MEDIA_STORAGE: s3
|
||||
S3_BUCKET: your-bucket
|
||||
AWS_REGION: us-east-1
|
||||
```
|
||||
|
||||
4. **Use AWS Load Balancer Controller** for ingress
|
||||
```yaml
|
||||
ingress:
|
||||
className: aws-alb
|
||||
annotations:
|
||||
alb.ingress.kubernetes.io/scheme: internet-facing
|
||||
```
|
||||
|
||||
5. **Use EBS for persistent storage**
|
||||
```yaml
|
||||
backend:
|
||||
persistence:
|
||||
storageClass: ebs-sc
|
||||
```
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
Check pod status:
|
||||
```bash
|
||||
kubectl get pods -n dating-app
|
||||
kubectl logs -n dating-app <pod-name>
|
||||
```
|
||||
|
||||
Check services:
|
||||
```bash
|
||||
kubectl get svc -n dating-app
|
||||
```
|
||||
|
||||
Check ingress:
|
||||
```bash
|
||||
kubectl get ingress -n dating-app
|
||||
```
|
||||
|
||||
Port forward for debugging:
|
||||
```bash
|
||||
kubectl port-forward -n dating-app svc/backend 8000:8000
|
||||
kubectl port-forward -n dating-app svc/frontend 3000:80
|
||||
```
|
||||
|
||||
### Database Initialization
|
||||
|
||||
The backend automatically initializes tables on startup. To verify:
|
||||
|
||||
```bash
|
||||
kubectl exec -it -n dating-app <postgres-pod> -- psql -U dating_user -d dating_app -c "\dt"
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
- This chart is designed to be portable between on-premises and cloud deployments
|
||||
- Modify `values.yaml` for your specific infrastructure
|
||||
- For production, use external secrets management (HashiCorp Vault, AWS Secrets Manager, etc.)
|
||||
- Enable TLS/SSL with cert-manager for production ingress
|
||||
- Configure proper backup strategies for PostgreSQL PVC
|
||||
@ -1,99 +0,0 @@
|
||||
---
|
||||
# PVC for Backend media storage
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: backend-media-pvc
|
||||
namespace: dating-app
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
{{- if .Values.backend.persistence.storageClass }}
|
||||
storageClassName: {{ .Values.backend.persistence.storageClass }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.backend.persistence.size }}
|
||||
|
||||
---
|
||||
# Backend Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: backend
|
||||
namespace: dating-app
|
||||
labels:
|
||||
app: backend
|
||||
spec:
|
||||
replicas: {{ .Values.backend.replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: backend
|
||||
spec:
|
||||
initContainers:
|
||||
- name: db-init
|
||||
image: postgres:15-alpine
|
||||
command: ['sh', '-c', 'until pg_isready -h postgres.dating-app.svc.cluster.local -p {{ .Values.postgres.service.port }}; do echo waiting for db; sleep 2; done;']
|
||||
containers:
|
||||
- name: backend
|
||||
image: {{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}
|
||||
imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: {{ .Values.backend.service.targetPort }}
|
||||
name: http
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: backend-config
|
||||
resources:
|
||||
requests:
|
||||
memory: {{ .Values.backend.resources.requests.memory }}
|
||||
cpu: {{ .Values.backend.resources.requests.cpu }}
|
||||
limits:
|
||||
memory: {{ .Values.backend.resources.limits.memory }}
|
||||
cpu: {{ .Values.backend.resources.limits.cpu }}
|
||||
volumeMounts:
|
||||
- name: media-storage
|
||||
mountPath: {{ .Values.backend.persistence.mountPath }}
|
||||
{{- if .Values.backend.probes.readiness.enabled }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.backend.probes.readiness.path }}
|
||||
port: {{ .Values.backend.service.targetPort }}
|
||||
initialDelaySeconds: {{ .Values.backend.probes.readiness.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.backend.probes.readiness.periodSeconds }}
|
||||
{{- end }}
|
||||
{{- if .Values.backend.probes.liveness.enabled }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.backend.probes.liveness.path }}
|
||||
port: {{ .Values.backend.service.targetPort }}
|
||||
initialDelaySeconds: {{ .Values.backend.probes.liveness.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.backend.probes.liveness.periodSeconds }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: media-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: backend-media-pvc
|
||||
|
||||
---
|
||||
# Backend Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: backend
|
||||
namespace: dating-app
|
||||
labels:
|
||||
app: backend
|
||||
spec:
|
||||
type: {{ .Values.backend.service.type }}
|
||||
selector:
|
||||
app: backend
|
||||
ports:
|
||||
- port: {{ .Values.backend.service.port }}
|
||||
targetPort: {{ .Values.backend.service.targetPort }}
|
||||
protocol: TCP
|
||||
name: http
|
||||
@ -1,23 +0,0 @@
|
||||
---
|
||||
# ConfigMap for backend configuration
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: backend-config
|
||||
namespace: dating-app
|
||||
data:
|
||||
JWT_SECRET: {{ .Values.backend.environment.JWT_SECRET | quote }}
|
||||
JWT_EXPIRES_MINUTES: {{ .Values.backend.environment.JWT_EXPIRES_MINUTES | quote }}
|
||||
MEDIA_DIR: {{ .Values.backend.environment.MEDIA_DIR | quote }}
|
||||
CORS_ORIGINS: {{ .Values.backend.environment.CORS_ORIGINS | quote }}
|
||||
DATABASE_URL: "postgresql://{{ .Values.postgres.credentials.username }}:{{ .Values.postgres.credentials.password }}@postgres.dating-app.svc.cluster.local:{{ .Values.postgres.service.port }}/{{ .Values.postgres.credentials.database }}"
|
||||
|
||||
---
|
||||
# ConfigMap for frontend configuration
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: frontend-config
|
||||
namespace: dating-app
|
||||
data:
|
||||
VITE_API_URL: {{ .Values.frontend.environment.VITE_API_URL | quote }}
|
||||
@ -1,71 +0,0 @@
|
||||
---
|
||||
# Frontend Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: frontend
|
||||
namespace: dating-app
|
||||
labels:
|
||||
app: frontend
|
||||
spec:
|
||||
replicas: {{ .Values.frontend.replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: frontend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: frontend
|
||||
image: {{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag }}
|
||||
imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: {{ .Values.frontend.service.targetPort }}
|
||||
name: http
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: frontend-config
|
||||
resources:
|
||||
requests:
|
||||
memory: {{ .Values.frontend.resources.requests.memory }}
|
||||
cpu: {{ .Values.frontend.resources.requests.cpu }}
|
||||
limits:
|
||||
memory: {{ .Values.frontend.resources.limits.memory }}
|
||||
cpu: {{ .Values.frontend.resources.limits.cpu }}
|
||||
{{- if .Values.frontend.probes.readiness.enabled }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.frontend.probes.readiness.path }}
|
||||
port: {{ .Values.frontend.service.targetPort }}
|
||||
initialDelaySeconds: {{ .Values.frontend.probes.readiness.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.frontend.probes.readiness.periodSeconds }}
|
||||
{{- end }}
|
||||
{{- if .Values.frontend.probes.liveness.enabled }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.frontend.probes.liveness.path }}
|
||||
port: {{ .Values.frontend.service.targetPort }}
|
||||
initialDelaySeconds: {{ .Values.frontend.probes.liveness.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.frontend.probes.liveness.periodSeconds }}
|
||||
{{- end }}
|
||||
|
||||
---
|
||||
# Frontend Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: frontend
|
||||
namespace: dating-app
|
||||
labels:
|
||||
app: frontend
|
||||
spec:
|
||||
type: {{ .Values.frontend.service.type }}
|
||||
selector:
|
||||
app: frontend
|
||||
ports:
|
||||
- port: {{ .Values.frontend.service.port }}
|
||||
targetPort: {{ .Values.frontend.service.targetPort }}
|
||||
protocol: TCP
|
||||
name: http
|
||||
@ -1,51 +0,0 @@
|
||||
{{- if .Values.ingress.enabled }}
|
||||
---
|
||||
# Ingress for Backend API
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: backend-ingress
|
||||
namespace: dating-app
|
||||
annotations:
|
||||
{{- range $key, $value := .Values.ingress.annotations }}
|
||||
{{ $key }}: {{ $value | quote }}
|
||||
{{- end }}
|
||||
spec:
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
rules:
|
||||
- host: {{ .Values.backend.ingress.host }}
|
||||
http:
|
||||
paths:
|
||||
- path: {{ .Values.backend.ingress.path }}
|
||||
pathType: {{ .Values.backend.ingress.pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: backend
|
||||
port:
|
||||
number: {{ .Values.backend.service.port }}
|
||||
|
||||
---
|
||||
# Ingress for Frontend
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: frontend-ingress
|
||||
namespace: dating-app
|
||||
annotations:
|
||||
{{- range $key, $value := .Values.ingress.annotations }}
|
||||
{{ $key }}: {{ $value | quote }}
|
||||
{{- end }}
|
||||
spec:
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
rules:
|
||||
- host: {{ .Values.frontend.ingress.host }}
|
||||
http:
|
||||
paths:
|
||||
- path: {{ .Values.frontend.ingress.path }}
|
||||
pathType: {{ .Values.frontend.ingress.pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: frontend
|
||||
port:
|
||||
number: {{ .Values.frontend.service.port }}
|
||||
{{- end }}
|
||||
@ -1,6 +0,0 @@
|
||||
---
|
||||
# Namespace
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: dating-app
|
||||
@ -1,105 +0,0 @@
|
||||
{{- if .Values.postgres.enabled }}
|
||||
---
|
||||
# ConfigMap for PostgreSQL initialization scripts
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: postgres-init-scripts
|
||||
namespace: dating-app
|
||||
data:
|
||||
01-init-db.sh: |
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Create the application user if it doesn't exist
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
-- Create application user if not exists
|
||||
DO \$do\$ BEGIN
|
||||
CREATE ROLE {{ .Values.postgres.credentials.username }} WITH LOGIN PASSWORD '{{ .Values.postgres.credentials.password }}';
|
||||
EXCEPTION WHEN DUPLICATE_OBJECT THEN
|
||||
RAISE NOTICE 'Role {{ .Values.postgres.credentials.username }} already exists';
|
||||
END
|
||||
\$do\$;
|
||||
|
||||
-- Grant privileges
|
||||
GRANT ALL PRIVILEGES ON DATABASE {{ .Values.postgres.credentials.database }} TO {{ .Values.postgres.credentials.username }};
|
||||
GRANT ALL PRIVILEGES ON SCHEMA public TO {{ .Values.postgres.credentials.username }};
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO {{ .Values.postgres.credentials.username }};
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO {{ .Values.postgres.credentials.username }};
|
||||
EOSQL
|
||||
|
||||
02-create-tables.sql: |
|
||||
-- Create tables for dating app
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
hashed_password VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS profiles (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL UNIQUE,
|
||||
display_name VARCHAR(255) NOT NULL,
|
||||
age INTEGER NOT NULL,
|
||||
gender VARCHAR(50) NOT NULL,
|
||||
location VARCHAR(255) NOT NULL,
|
||||
bio TEXT,
|
||||
interests JSONB DEFAULT '[]',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS photos (
|
||||
id SERIAL PRIMARY KEY,
|
||||
profile_id INTEGER NOT NULL,
|
||||
file_path VARCHAR(255) NOT NULL,
|
||||
display_order INTEGER NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (profile_id) REFERENCES profiles(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS likes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
liker_id INTEGER NOT NULL,
|
||||
liked_id INTEGER NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(liker_id, liked_id),
|
||||
FOREIGN KEY (liker_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (liked_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS conversations (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id_1 INTEGER NOT NULL,
|
||||
user_id_2 INTEGER NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(user_id_1, user_id_2),
|
||||
FOREIGN KEY (user_id_1) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id_2) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS messages (
|
||||
id SERIAL PRIMARY KEY,
|
||||
conversation_id INTEGER NOT NULL,
|
||||
sender_id INTEGER NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (conversation_id) REFERENCES conversations(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (sender_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Create indexes for performance
|
||||
CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
|
||||
CREATE INDEX IF NOT EXISTS idx_profiles_user_id ON profiles(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_photos_profile_id ON photos(profile_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_likes_liker_id ON likes(liker_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_likes_liked_id ON likes(liked_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_conversations_users ON conversations(user_id_1, user_id_2);
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_conversation_id ON messages(conversation_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_created_at ON messages(created_at);
|
||||
|
||||
{{- end }}
|
||||
@ -1,127 +0,0 @@
|
||||
{{- if .Values.postgres.enabled }}
|
||||
---
|
||||
# Headless Service for StatefulSet
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres
|
||||
namespace: dating-app
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
ports:
|
||||
- port: {{ .Values.postgres.service.port }}
|
||||
targetPort: {{ .Values.postgres.service.port }}
|
||||
name: postgres
|
||||
clusterIP: None # Headless service for StatefulSet
|
||||
selector:
|
||||
app: postgres
|
||||
|
||||
---
|
||||
# PostgreSQL StatefulSet
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: postgres
|
||||
namespace: dating-app
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
serviceName: postgres
|
||||
replicas: {{ .Values.postgres.replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
securityContext:
|
||||
fsGroup: 999
|
||||
containers:
|
||||
- name: postgres
|
||||
image: {{ .Values.postgres.image }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: {{ .Values.postgres.service.port }}
|
||||
name: postgres
|
||||
env:
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-credentials
|
||||
key: username
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-credentials
|
||||
key: password
|
||||
- name: POSTGRES_DB
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-credentials
|
||||
key: database
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
resources:
|
||||
requests:
|
||||
memory: {{ .Values.postgres.resources.requests.memory }}
|
||||
cpu: {{ .Values.postgres.resources.requests.cpu }}
|
||||
limits:
|
||||
memory: {{ .Values.postgres.resources.limits.memory }}
|
||||
cpu: {{ .Values.postgres.resources.limits.cpu }}
|
||||
volumeMounts:
|
||||
- name: postgres-storage
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: init-scripts
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- pg_isready -U $POSTGRES_USER
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- pg_isready -U $POSTGRES_USER
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 3
|
||||
volumes:
|
||||
- name: init-scripts
|
||||
configMap:
|
||||
name: postgres-init-scripts
|
||||
defaultMode: 0755
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: postgres-storage
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
{{- if .Values.postgres.persistence.storageClass }}
|
||||
storageClassName: {{ .Values.postgres.persistence.storageClass }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.postgres.persistence.size }}
|
||||
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.postgres.service.type | default "ClusterIP" }}
|
||||
selector:
|
||||
app: postgres
|
||||
ports:
|
||||
- port: {{ .Values.postgres.service.port }}
|
||||
targetPort: {{ .Values.postgres.service.port }}
|
||||
protocol: TCP
|
||||
name: postgres
|
||||
{{- end }}
|
||||
@ -1,12 +0,0 @@
|
||||
---
|
||||
# Secret for PostgreSQL credentials
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: postgres-credentials
|
||||
namespace: dating-app
|
||||
type: Opaque
|
||||
data:
|
||||
username: {{ .Values.postgres.credentials.username | b64enc }}
|
||||
password: {{ .Values.postgres.credentials.password | b64enc }}
|
||||
database: {{ .Values.postgres.credentials.database | b64enc }}
|
||||
@ -1,79 +0,0 @@
|
||||
---
|
||||
# Example values for AWS deployment
|
||||
# Copy to values-aws.yaml and customize with your AWS details
|
||||
|
||||
global:
|
||||
domain: yourdomain.com
|
||||
|
||||
# Disable built-in PostgreSQL and use RDS instead
|
||||
postgres:
|
||||
enabled: false
|
||||
|
||||
backend:
|
||||
image:
|
||||
repository: 123456789.dkr.ecr.us-east-1.amazonaws.com/dating-app-backend
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
replicas: 3
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "200m"
|
||||
limits:
|
||||
memory: "1Gi"
|
||||
cpu: "500m"
|
||||
service:
|
||||
port: 8000
|
||||
type: ClusterIP
|
||||
ingress:
|
||||
enabled: true
|
||||
className: aws-alb
|
||||
host: api.yourdomain.com
|
||||
path: /
|
||||
pathType: Prefix
|
||||
environment:
|
||||
# Use RDS endpoint here with updated credentials
|
||||
DATABASE_URL: "postgresql://dating_app_user:Aa123456@your-rds-endpoint.us-east-1.rds.amazonaws.com:5432/dating_app"
|
||||
JWT_SECRET: "your-secure-secret-key"
|
||||
JWT_EXPIRES_MINUTES: "1440"
|
||||
MEDIA_DIR: /app/media
|
||||
CORS_ORIGINS: "https://yourdomain.com,https://api.yourdomain.com"
|
||||
persistence:
|
||||
enabled: true
|
||||
size: 20Gi
|
||||
storageClass: ebs-sc # AWS EBS storage class
|
||||
mountPath: /app/media
|
||||
|
||||
frontend:
|
||||
image:
|
||||
repository: 123456789.dkr.ecr.us-east-1.amazonaws.com/dating-app-frontend
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
replicas: 3
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "200m"
|
||||
service:
|
||||
port: 80
|
||||
type: ClusterIP
|
||||
ingress:
|
||||
enabled: true
|
||||
className: aws-alb
|
||||
host: yourdomain.com
|
||||
path: /
|
||||
pathType: Prefix
|
||||
environment:
|
||||
VITE_API_URL: "https://api.yourdomain.com"
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: aws-alb
|
||||
annotations:
|
||||
alb.ingress.kubernetes.io/scheme: internet-facing
|
||||
alb.ingress.kubernetes.io/target-type: ip
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
alb.ingress.kubernetes.io/certificate-arn: "arn:aws:acm:us-east-1:123456789:certificate/xxxx"
|
||||
@ -1,80 +0,0 @@
|
||||
---
|
||||
# Example values for development/lab deployment
|
||||
# Copy to values-dev.yaml and customize
|
||||
|
||||
global:
|
||||
domain: lab.local
|
||||
|
||||
postgres:
|
||||
enabled: true
|
||||
replicas: 1
|
||||
persistence:
|
||||
enabled: true
|
||||
size: 5Gi
|
||||
storageClass: "" # Use default storage class
|
||||
credentials:
|
||||
username: dating_app_user
|
||||
password: Aa123456
|
||||
database: dating_app
|
||||
|
||||
backend:
|
||||
image:
|
||||
repository: dating-app-backend
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
replicas: 1
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
service:
|
||||
port: 8000
|
||||
type: ClusterIP
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
host: api.lab.local
|
||||
path: /
|
||||
pathType: Prefix
|
||||
environment:
|
||||
JWT_SECRET: dev-secret-key-change-in-production
|
||||
JWT_EXPIRES_MINUTES: "1440"
|
||||
MEDIA_DIR: /app/media
|
||||
CORS_ORIGINS: "http://localhost:5173,http://localhost:3000,http://api.lab.local,http://app.lab.local"
|
||||
persistence:
|
||||
enabled: true
|
||||
size: 5Gi
|
||||
storageClass: ""
|
||||
|
||||
frontend:
|
||||
image:
|
||||
repository: dating-app-frontend
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
replicas: 1
|
||||
resources:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "200m"
|
||||
service:
|
||||
port: 80
|
||||
type: ClusterIP
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
host: app.lab.local
|
||||
path: /
|
||||
pathType: Prefix
|
||||
environment:
|
||||
VITE_API_URL: "http://api.lab.local"
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
annotations: {}
|
||||
@ -1,127 +0,0 @@
|
||||
# Default values for dating-app Helm chart
|
||||
|
||||
# Global settings
|
||||
global:
|
||||
domain: example.com
|
||||
|
||||
# PostgreSQL configuration
|
||||
postgres:
|
||||
enabled: true
|
||||
image: postgres:15-alpine
|
||||
replicas: 1
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
persistence:
|
||||
enabled: true
|
||||
size: 10Gi
|
||||
storageClass: ""
|
||||
credentials:
|
||||
username: dating_app_user
|
||||
password: Aa123456
|
||||
database: dating_app
|
||||
service:
|
||||
port: 5432
|
||||
|
||||
# Backend configuration
|
||||
backend:
|
||||
image:
|
||||
repository: dating-app-backend
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
replicas: 2
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
service:
|
||||
port: 8000
|
||||
targetPort: 8000
|
||||
type: ClusterIP
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
host: api-dateme.dvirlabs.com
|
||||
path: /
|
||||
pathType: Prefix
|
||||
environment:
|
||||
JWT_SECRET: your-secret-key-change-in-production
|
||||
JWT_EXPIRES_MINUTES: "1440"
|
||||
MEDIA_DIR: /app/media
|
||||
CORS_ORIGINS: "http://localhost:5173,http://localhost:3000,http://localhost,https://dateme.dvirlabs.com"
|
||||
persistence:
|
||||
enabled: true
|
||||
size: 5Gi
|
||||
storageClass: ""
|
||||
mountPath: /app/media
|
||||
probes:
|
||||
readiness:
|
||||
enabled: true
|
||||
path: /health
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
liveness:
|
||||
enabled: true
|
||||
path: /health
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
|
||||
# Frontend configuration
|
||||
frontend:
|
||||
image:
|
||||
repository: dating-app-frontend
|
||||
tag: latest
|
||||
pullPolicy: IfNotPresent
|
||||
replicas: 2
|
||||
resources:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "200m"
|
||||
service:
|
||||
port: 80
|
||||
targetPort: 80
|
||||
type: ClusterIP
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
host: dateme.dvirlabs.com
|
||||
path: /
|
||||
pathType: Prefix
|
||||
environment:
|
||||
VITE_API_URL: "https://api-dateme.dvirlabs.com"
|
||||
probes:
|
||||
readiness:
|
||||
enabled: true
|
||||
path: /health
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
liveness:
|
||||
enabled: true
|
||||
path: /health
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 30
|
||||
|
||||
# Ingress configuration
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
|
||||
# ConfigMap for shared configuration
|
||||
configmap:
|
||||
enabled: true
|
||||
|
||||
# Secret for sensitive data (use external secrets in production)
|
||||
secrets:
|
||||
enabled: true
|
||||
Loading…
x
Reference in New Issue
Block a user