From 78f5bbd90fe9dd977be99f620ffcf09d6772366f Mon Sep 17 00:00:00 2001 From: William Valentin Date: Mon, 8 Sep 2025 09:45:27 -0700 Subject: [PATCH] feat: add generated configuration files and Kubernetes overlays - Add generated TypeScript configuration exports for all environments - Create development and production Kubernetes overlay directories - Include environment-specific kustomization configurations - Add namespace and resource definitions for proper K8s deployment - Enable environment-specific configuration management --- config/generated/development.config.ts | 130 ++++++++++++++++++ config/generated/production.config.ts | 130 ++++++++++++++++++ k8s-kustomize/overlays/development/config.env | 43 ++++++ .../overlays/development/kustomization.yaml | 73 ++++++++++ k8s-kustomize/overlays/production/config.env | 43 ++++++ .../overlays/production/kustomization.yaml | 73 ++++++++++ 6 files changed, 492 insertions(+) create mode 100644 config/generated/development.config.ts create mode 100644 config/generated/production.config.ts create mode 100644 k8s-kustomize/overlays/development/config.env create mode 100644 k8s-kustomize/overlays/development/kustomization.yaml create mode 100644 k8s-kustomize/overlays/production/config.env create mode 100644 k8s-kustomize/overlays/production/kustomization.yaml diff --git a/config/generated/development.config.ts b/config/generated/development.config.ts new file mode 100644 index 0000000..9b68c0b --- /dev/null +++ b/config/generated/development.config.ts @@ -0,0 +1,130 @@ +/** + * Generated configuration for development + * Generated on: 2025-09-08T16:32:25.392Z + * + * This file exports the resolved configuration for the development environment. + * It can be imported by other TypeScript files for type-safe configuration access. + */ + +import type { UnifiedConfig } from '../unified.config'; + +export const developmentConfig: UnifiedConfig = { + app: { + name: 'rxminder', + version: '1.0.0', + environment: 'development', + baseUrl: 'rxminder.192.168.153.243.nip.io', + port: 5173, + }, + database: { + url: 'http://rxminder-couchdb-service:5984', + username: 'admin', + password: 'L7tfqHyg0T4sIYiWK', + name: 'meds_app', + useMock: false, + connectionTimeout: 30000, + retryAttempts: 3, + }, + container: { + registry: 'gitea-http.taildb3494.ts.net', + repository: 'will/meds', + tag: 'latest', + imageUrl: 'gitea-http.taildb3494.ts.net/will/meds:latest', + }, + kubernetes: { + namespace: 'rxminder-dev', + ingressHost: 'rxminder.192.168.153.243.nip.io', + ingressClass: 'nginx', + certIssuer: 'letsencrypt-prod', + storageClass: 'longhorn', + storageSize: '1Gi', + replicas: { + frontend: 1, + database: 1, + }, + resources: { + frontend: { + requests: { + memory: '128Mi', + cpu: '50m', + }, + limits: { + memory: '256Mi', + cpu: '200m', + }, + }, + database: { + requests: { + memory: '256Mi', + cpu: '100m', + }, + limits: { + memory: '512Mi', + cpu: '500m', + }, + }, + }, + }, + auth: { + jwtSecret: 'your-super-secret-jwt-key-change-in-production', + jwtExpiresIn: '1h', + refreshTokenExpiresIn: '7d', + emailVerificationExpiresIn: '24h', + bcryptRounds: 12, + }, + email: { + provider: 'console', + mailgun: { + apiKey: 'your-production-mailgun-api-key-here', + domain: 'your-production-domain.com', + baseUrl: 'https://api.mailgun.net/v3', + }, + fromName: 'RxMinder', + fromEmail: 'noreply@your-production-domain.com', + }, + oauth: { + google: { + clientId: 'your_google_client_id_here', + clientSecret: '', + }, + github: { + clientId: 'your_github_client_id_here', + clientSecret: '', + }, + }, + features: { + enableEmailVerification: true, + enableOAuth: true, + enableAdminInterface: true, + enableMonitoring: false, + enableMetrics: false, + enableTracing: false, + enableRateLimiting: false, + enableSecurityHeaders: false, + debugMode: true, + hotReload: true, + }, + performance: { + cacheTimeout: 300, + requestTimeout: 30000, + maxConnections: 100, + enableCors: true, + corsOrigin: '*', + }, + logging: { + level: 'debug', + format: 'text', + enableTimestamp: true, + enableColors: true, + }, + security: { + enableHttps: false, + enableHsts: false, + enableCsp: false, + sessionSecret: 'your-session-secret-change-in-production', + rateLimitRequests: 100, + rateLimitWindow: 900000, + }, +} as const; + +export default developmentConfig; diff --git a/config/generated/production.config.ts b/config/generated/production.config.ts new file mode 100644 index 0000000..0bf6ca5 --- /dev/null +++ b/config/generated/production.config.ts @@ -0,0 +1,130 @@ +/** + * Generated configuration for production + * Generated on: 2025-09-08T16:25:25.058Z + * + * This file exports the resolved configuration for the production environment. + * It can be imported by other TypeScript files for type-safe configuration access. + */ + +import type { UnifiedConfig } from '../unified.config'; + +export const productionConfig: UnifiedConfig = { + app: { + name: 'rxminder', + version: '1.0.0', + environment: 'production', + baseUrl: 'rxminder.192.168.153.243.nip.io', + port: 5173, + }, + database: { + url: 'http://rxminder-couchdb-service:5984', + username: 'admin', + password: 'L7tfqHyg0T4sIYiWK', + name: 'meds_app', + useMock: false, + connectionTimeout: 30000, + retryAttempts: 3, + }, + container: { + registry: 'gitea-http.taildb3494.ts.net', + repository: 'will/meds', + tag: 'latest', + imageUrl: 'gitea-http.taildb3494.ts.net/will/meds:latest', + }, + kubernetes: { + namespace: 'rxminder-prod', + ingressHost: 'rxminder.192.168.153.243.nip.io', + ingressClass: 'nginx', + certIssuer: 'letsencrypt-prod', + storageClass: 'longhorn', + storageSize: '1Gi', + replicas: { + frontend: 3, + database: 1, + }, + resources: { + frontend: { + requests: { + memory: '256Mi', + cpu: '100m', + }, + limits: { + memory: '512Mi', + cpu: '500m', + }, + }, + database: { + requests: { + memory: '512Mi', + cpu: '200m', + }, + limits: { + memory: '1Gi', + cpu: '1000m', + }, + }, + }, + }, + auth: { + jwtSecret: 'my-production-jwt-secret', + jwtExpiresIn: '1h', + refreshTokenExpiresIn: '7d', + emailVerificationExpiresIn: '24h', + bcryptRounds: 12, + }, + email: { + provider: 'console', + mailgun: { + apiKey: 'your-production-mailgun-api-key-here', + domain: 'your-production-domain.com', + baseUrl: 'https://api.mailgun.net/v3', + }, + fromName: 'RxMinder', + fromEmail: 'noreply@your-production-domain.com', + }, + oauth: { + google: { + clientId: 'your_google_client_id_here', + clientSecret: '', + }, + github: { + clientId: 'your_github_client_id_here', + clientSecret: '', + }, + }, + features: { + enableEmailVerification: true, + enableOAuth: true, + enableAdminInterface: true, + enableMonitoring: false, + enableMetrics: false, + enableTracing: true, + enableRateLimiting: true, + enableSecurityHeaders: true, + debugMode: true, + hotReload: false, + }, + performance: { + cacheTimeout: 3600, + requestTimeout: 30000, + maxConnections: 200, + enableCors: true, + corsOrigin: '*', + }, + logging: { + level: 'debug', + format: 'json', + enableTimestamp: true, + enableColors: false, + }, + security: { + enableHttps: true, + enableHsts: true, + enableCsp: true, + sessionSecret: 'my-production-session-secret', + rateLimitRequests: 100, + rateLimitWindow: 900000, + }, +} as const; + +export default productionConfig; diff --git a/k8s-kustomize/overlays/development/config.env b/k8s-kustomize/overlays/development/config.env new file mode 100644 index 0000000..8bd516b --- /dev/null +++ b/k8s-kustomize/overlays/development/config.env @@ -0,0 +1,43 @@ +# Kubernetes configuration for development +# Generated automatically from unified configuration +# Generated on: 2025-09-08T16:32:25.389Z + +APP_NAME=rxminder +APP_VERSION=1.0.0 +NODE_ENV=development +APP_BASE_URL=rxminder.192.168.153.243.nip.io +PORT=5173 +COUCHDB_URL=http://rxminder-couchdb-service:5984 +COUCHDB_USER=admin +COUCHDB_PASSWORD=L7tfqHyg0T4sIYiWK +COUCHDB_DATABASE_NAME=meds_app +USE_MOCK_DB=false +KUBERNETES_NAMESPACE=rxminder-dev +INGRESS_HOST=rxminder.192.168.153.243.nip.io +INGRESS_CLASS=nginx +CERT_MANAGER_ISSUER=letsencrypt-prod +STORAGE_CLASS=longhorn +STORAGE_SIZE=1Gi +ENABLE_EMAIL_VERIFICATION=true +ENABLE_OAUTH=true +ENABLE_ADMIN_INTERFACE=true +ENABLE_MONITORING=false +ENABLE_METRICS=false +DEBUG_MODE=true +LOG_LEVEL=debug +LOG_FORMAT=text +CACHE_TTL=300 +REQUEST_TIMEOUT=30000 +MAX_CONNECTIONS=100 +ENABLE_CORS=true +CORS_ORIGIN=* +FRONTEND_REPLICAS=1 +DATABASE_REPLICAS=1 +FRONTEND_MEMORY_REQUEST=128Mi +FRONTEND_CPU_REQUEST=50m +FRONTEND_MEMORY_LIMIT=256Mi +FRONTEND_CPU_LIMIT=200m +DATABASE_MEMORY_REQUEST=256Mi +DATABASE_CPU_REQUEST=100m +DATABASE_MEMORY_LIMIT=512Mi +DATABASE_CPU_LIMIT=500m diff --git a/k8s-kustomize/overlays/development/kustomization.yaml b/k8s-kustomize/overlays/development/kustomization.yaml new file mode 100644 index 0000000..28993b1 --- /dev/null +++ b/k8s-kustomize/overlays/development/kustomization.yaml @@ -0,0 +1,73 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +metadata: + name: rxminder-development + +# Reference the base configuration +resources: + - ../../base + - namespace.yaml + +# Override namespace for development +namespace: rxminder-dev + +# Development-specific labels +labels: + - pairs: + environment: development + tier: development + +# Development image tags and configurations +images: + - name: frontend-image + newName: gitea-http.taildb3494.ts.net/will/meds + newTag: latest + - name: couchdb-image + newName: couchdb + newTag: 3.3.2 + +# Development replicas +replicas: + - name: rxminder-frontend + count: 1 + - name: rxminder-couchdb + count: 1 + +# Environment-specific patches +patches: + # Resource limits + - target: + kind: Deployment + name: rxminder-frontend + patch: |- + - op: replace + path: /spec/template/spec/containers/0/resources + value: + requests: + memory: "128Mi" + cpu: "50m" + limits: + memory: "256Mi" + cpu: "200m" + + - target: + kind: StatefulSet + name: rxminder-couchdb + patch: |- + - op: replace + path: /spec/template/spec/containers/0/resources + value: + requests: + memory: "256Mi" + cpu: "100m" + limits: + memory: "512Mi" + cpu: "500m" + +# ConfigMap generation +configMapGenerator: + - name: rxminder-config + envs: + - config.env + behavior: create diff --git a/k8s-kustomize/overlays/production/config.env b/k8s-kustomize/overlays/production/config.env new file mode 100644 index 0000000..17d5be7 --- /dev/null +++ b/k8s-kustomize/overlays/production/config.env @@ -0,0 +1,43 @@ +# Kubernetes configuration for production +# Generated automatically from unified configuration +# Generated on: 2025-09-08T16:25:25.055Z + +APP_NAME=rxminder +APP_VERSION=1.0.0 +NODE_ENV=production +APP_BASE_URL=rxminder.192.168.153.243.nip.io +PORT=5173 +COUCHDB_URL=http://rxminder-couchdb-service:5984 +COUCHDB_USER=admin +COUCHDB_PASSWORD=L7tfqHyg0T4sIYiWK +COUCHDB_DATABASE_NAME=meds_app +USE_MOCK_DB=false +KUBERNETES_NAMESPACE=rxminder-prod +INGRESS_HOST=rxminder.192.168.153.243.nip.io +INGRESS_CLASS=nginx +CERT_MANAGER_ISSUER=letsencrypt-prod +STORAGE_CLASS=longhorn +STORAGE_SIZE=1Gi +ENABLE_EMAIL_VERIFICATION=true +ENABLE_OAUTH=true +ENABLE_ADMIN_INTERFACE=true +ENABLE_MONITORING=false +ENABLE_METRICS=false +DEBUG_MODE=true +LOG_LEVEL=debug +LOG_FORMAT=json +CACHE_TTL=3600 +REQUEST_TIMEOUT=30000 +MAX_CONNECTIONS=200 +ENABLE_CORS=true +CORS_ORIGIN=* +FRONTEND_REPLICAS=3 +DATABASE_REPLICAS=1 +FRONTEND_MEMORY_REQUEST=256Mi +FRONTEND_CPU_REQUEST=100m +FRONTEND_MEMORY_LIMIT=512Mi +FRONTEND_CPU_LIMIT=500m +DATABASE_MEMORY_REQUEST=512Mi +DATABASE_CPU_REQUEST=200m +DATABASE_MEMORY_LIMIT=1Gi +DATABASE_CPU_LIMIT=1000m diff --git a/k8s-kustomize/overlays/production/kustomization.yaml b/k8s-kustomize/overlays/production/kustomization.yaml new file mode 100644 index 0000000..8413772 --- /dev/null +++ b/k8s-kustomize/overlays/production/kustomization.yaml @@ -0,0 +1,73 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +metadata: + name: rxminder-production + +# Reference the base configuration +resources: + - ../../base + - namespace.yaml + +# Override namespace for production +namespace: rxminder-prod + +# Production-specific labels +labels: + - pairs: + environment: production + tier: prod + +# Production image tags and configurations +images: + - name: frontend-image + newName: gitea-http.taildb3494.ts.net/will/meds + newTag: latest + - name: couchdb-image + newName: couchdb + newTag: 3.3.2 + +# Production replicas +replicas: + - name: rxminder-frontend + count: 3 + - name: rxminder-couchdb + count: 1 + +# Environment-specific patches +patches: + # Resource limits + - target: + kind: Deployment + name: rxminder-frontend + patch: |- + - op: replace + path: /spec/template/spec/containers/0/resources + value: + requests: + memory: "256Mi" + cpu: "100m" + limits: + memory: "512Mi" + cpu: "500m" + + - target: + kind: StatefulSet + name: rxminder-couchdb + patch: |- + - op: replace + path: /spec/template/spec/containers/0/resources + value: + requests: + memory: "512Mi" + cpu: "200m" + limits: + memory: "1Gi" + cpu: "1000m" + +# ConfigMap generation +configMapGenerator: + - name: rxminder-config + envs: + - config.env + behavior: create