From a7659198a4ce9d65e65d7ae858b34d5a1dec2702 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Wed, 17 Dec 2025 06:32:03 +0200 Subject: [PATCH] Add dateme app --- argocd-apps/dateme.yaml | 21 ++ charts/dateme-chart/Chart.yaml | 12 ++ charts/dateme-chart/README.md | 201 ++++++++++++++++++ charts/dateme-chart/templates/backend.yaml | 99 +++++++++ charts/dateme-chart/templates/configmap.yaml | 23 ++ charts/dateme-chart/templates/frontend.yaml | 71 +++++++ charts/dateme-chart/templates/ingress.yaml | 51 +++++ charts/dateme-chart/templates/namespace.yaml | 6 + .../dateme-chart/templates/postgres-init.yaml | 105 +++++++++ charts/dateme-chart/templates/postgres.yaml | 127 +++++++++++ charts/dateme-chart/templates/secret.yaml | 12 ++ charts/dateme-chart/values-aws.yaml | 79 +++++++ charts/dateme-chart/values-lab.yaml | 80 +++++++ charts/dateme-chart/values.yaml | 127 +++++++++++ manifests/dateme/values.yaml | 4 + 15 files changed, 1018 insertions(+) create mode 100644 argocd-apps/dateme.yaml create mode 100644 charts/dateme-chart/Chart.yaml create mode 100644 charts/dateme-chart/README.md create mode 100644 charts/dateme-chart/templates/backend.yaml create mode 100644 charts/dateme-chart/templates/configmap.yaml create mode 100644 charts/dateme-chart/templates/frontend.yaml create mode 100644 charts/dateme-chart/templates/ingress.yaml create mode 100644 charts/dateme-chart/templates/namespace.yaml create mode 100644 charts/dateme-chart/templates/postgres-init.yaml create mode 100644 charts/dateme-chart/templates/postgres.yaml create mode 100644 charts/dateme-chart/templates/secret.yaml create mode 100644 charts/dateme-chart/values-aws.yaml create mode 100644 charts/dateme-chart/values-lab.yaml create mode 100644 charts/dateme-chart/values.yaml create mode 100644 manifests/dateme/values.yaml diff --git a/argocd-apps/dateme.yaml b/argocd-apps/dateme.yaml new file mode 100644 index 0000000..8c29822 --- /dev/null +++ b/argocd-apps/dateme.yaml @@ -0,0 +1,21 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: my-recipes + namespace: argocd +spec: + project: my-apps + source: + repoURL: https://git.dvirlabs.com/dvirlabs/my-apps.git + targetRevision: HEAD + path: charts/dateme-chart + helm: + valueFiles: + - ../../manifests/dateme/values.yaml + destination: + server: https://kubernetes.default.svc + namespace: my-apps + syncPolicy: + automated: + prune: true + selfHeal: true diff --git a/charts/dateme-chart/Chart.yaml b/charts/dateme-chart/Chart.yaml new file mode 100644 index 0000000..de547a8 --- /dev/null +++ b/charts/dateme-chart/Chart.yaml @@ -0,0 +1,12 @@ +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 diff --git a/charts/dateme-chart/README.md b/charts/dateme-chart/README.md new file mode 100644 index 0000000..9989546 --- /dev/null +++ b/charts/dateme-chart/README.md @@ -0,0 +1,201 @@ +# 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 +``` + +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 -- 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 diff --git a/charts/dateme-chart/templates/backend.yaml b/charts/dateme-chart/templates/backend.yaml new file mode 100644 index 0000000..83bdb36 --- /dev/null +++ b/charts/dateme-chart/templates/backend.yaml @@ -0,0 +1,99 @@ +--- +# 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 diff --git a/charts/dateme-chart/templates/configmap.yaml b/charts/dateme-chart/templates/configmap.yaml new file mode 100644 index 0000000..e25d4d4 --- /dev/null +++ b/charts/dateme-chart/templates/configmap.yaml @@ -0,0 +1,23 @@ +--- +# 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 }} diff --git a/charts/dateme-chart/templates/frontend.yaml b/charts/dateme-chart/templates/frontend.yaml new file mode 100644 index 0000000..23d0910 --- /dev/null +++ b/charts/dateme-chart/templates/frontend.yaml @@ -0,0 +1,71 @@ +--- +# 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 diff --git a/charts/dateme-chart/templates/ingress.yaml b/charts/dateme-chart/templates/ingress.yaml new file mode 100644 index 0000000..3c68a6b --- /dev/null +++ b/charts/dateme-chart/templates/ingress.yaml @@ -0,0 +1,51 @@ +{{- 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 }} diff --git a/charts/dateme-chart/templates/namespace.yaml b/charts/dateme-chart/templates/namespace.yaml new file mode 100644 index 0000000..ab53699 --- /dev/null +++ b/charts/dateme-chart/templates/namespace.yaml @@ -0,0 +1,6 @@ +--- +# Namespace +apiVersion: v1 +kind: Namespace +metadata: + name: dating-app diff --git a/charts/dateme-chart/templates/postgres-init.yaml b/charts/dateme-chart/templates/postgres-init.yaml new file mode 100644 index 0000000..3026e6b --- /dev/null +++ b/charts/dateme-chart/templates/postgres-init.yaml @@ -0,0 +1,105 @@ +{{- 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 }} diff --git a/charts/dateme-chart/templates/postgres.yaml b/charts/dateme-chart/templates/postgres.yaml new file mode 100644 index 0000000..ab62ede --- /dev/null +++ b/charts/dateme-chart/templates/postgres.yaml @@ -0,0 +1,127 @@ +{{- 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 }} diff --git a/charts/dateme-chart/templates/secret.yaml b/charts/dateme-chart/templates/secret.yaml new file mode 100644 index 0000000..7b74bcc --- /dev/null +++ b/charts/dateme-chart/templates/secret.yaml @@ -0,0 +1,12 @@ +--- +# 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 }} diff --git a/charts/dateme-chart/values-aws.yaml b/charts/dateme-chart/values-aws.yaml new file mode 100644 index 0000000..5aee87c --- /dev/null +++ b/charts/dateme-chart/values-aws.yaml @@ -0,0 +1,79 @@ +--- +# 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" diff --git a/charts/dateme-chart/values-lab.yaml b/charts/dateme-chart/values-lab.yaml new file mode 100644 index 0000000..ca5d6db --- /dev/null +++ b/charts/dateme-chart/values-lab.yaml @@ -0,0 +1,80 @@ +--- +# 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: {} diff --git a/charts/dateme-chart/values.yaml b/charts/dateme-chart/values.yaml new file mode 100644 index 0000000..f0d703a --- /dev/null +++ b/charts/dateme-chart/values.yaml @@ -0,0 +1,127 @@ +# 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 diff --git a/manifests/dateme/values.yaml b/manifests/dateme/values.yaml new file mode 100644 index 0000000..1ff0106 --- /dev/null +++ b/manifests/dateme/values.yaml @@ -0,0 +1,4 @@ +enabled: true +hostname: + - dateme.dvirlabs.com + - api-dateme.dvirlabs.com \ No newline at end of file