Add base kubernetes support
This commit is contained in:
@@ -13,11 +13,23 @@ class AlertProcessorConfig(BaseServiceSettings):
|
||||
APP_NAME: str = "Alert Processor Service"
|
||||
DESCRIPTION: str = "Central alert and recommendation processor"
|
||||
|
||||
# Use dedicated database for alert storage
|
||||
DATABASE_URL: str = os.getenv(
|
||||
"ALERT_PROCESSOR_DATABASE_URL",
|
||||
"postgresql+asyncpg://alert_processor_user:alert_processor_pass123@alert-processor-db:5432/alert_processor_db"
|
||||
)
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("ALERT_PROCESSOR_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("ALERT_PROCESSOR_DB_USER", "alert_processor_user")
|
||||
password = os.getenv("ALERT_PROCESSOR_DB_PASSWORD", "alert_processor_pass123")
|
||||
host = os.getenv("ALERT_PROCESSOR_DB_HOST", "localhost")
|
||||
port = os.getenv("ALERT_PROCESSOR_DB_PORT", "5432")
|
||||
name = os.getenv("ALERT_PROCESSOR_DB_NAME", "alert_processor_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Use dedicated Redis DB for alert processing
|
||||
REDIS_DB: int = int(os.getenv("ALERT_PROCESSOR_REDIS_DB", "6"))
|
||||
|
||||
@@ -19,9 +19,23 @@ class AuthSettings(BaseServiceSettings):
|
||||
SERVICE_NAME: str = "auth-service"
|
||||
DESCRIPTION: str = "User authentication and authorization service"
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("AUTH_DATABASE_URL",
|
||||
"postgresql+asyncpg://auth_user:auth_pass123@auth-db:5432/auth_db")
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("AUTH_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("AUTH_DB_USER", "auth_user")
|
||||
password = os.getenv("AUTH_DB_PASSWORD", "auth_pass123")
|
||||
host = os.getenv("AUTH_DB_HOST", "localhost")
|
||||
port = os.getenv("AUTH_DB_PORT", "5432")
|
||||
name = os.getenv("AUTH_DB_NAME", "auth_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Redis Database (dedicated for auth)
|
||||
REDIS_DB: int = 0
|
||||
|
||||
22
services/external/app/core/config.py
vendored
22
services/external/app/core/config.py
vendored
@@ -16,11 +16,23 @@ class DataSettings(BaseServiceSettings):
|
||||
# API Configuration
|
||||
API_V1_STR: str = "/api/v1"
|
||||
|
||||
# Override database URL to use EXTERNAL_DATABASE_URL
|
||||
DATABASE_URL: str = Field(
|
||||
default="postgresql+asyncpg://external_user:external_pass123@external-db:5432/external_db",
|
||||
env="EXTERNAL_DATABASE_URL"
|
||||
)
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("EXTERNAL_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("EXTERNAL_DB_USER", "external_user")
|
||||
password = os.getenv("EXTERNAL_DB_PASSWORD", "external_pass123")
|
||||
host = os.getenv("EXTERNAL_DB_HOST", "localhost")
|
||||
port = os.getenv("EXTERNAL_DB_PORT", "5432")
|
||||
name = os.getenv("EXTERNAL_DB_NAME", "external_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# External API Configuration
|
||||
AEMET_API_KEY: str = os.getenv("AEMET_API_KEY", "")
|
||||
|
||||
@@ -19,9 +19,23 @@ class ForecastingSettings(BaseServiceSettings):
|
||||
SERVICE_NAME: str = "forecasting-service"
|
||||
DESCRIPTION: str = "Demand prediction and forecasting service"
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("FORECASTING_DATABASE_URL",
|
||||
"postgresql+asyncpg://forecasting_user:forecasting_pass123@forecasting-db:5432/forecasting_db")
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("FORECASTING_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("FORECASTING_DB_USER", "forecasting_user")
|
||||
password = os.getenv("FORECASTING_DB_PASSWORD", "forecasting_pass123")
|
||||
host = os.getenv("FORECASTING_DB_HOST", "localhost")
|
||||
port = os.getenv("FORECASTING_DB_PORT", "5432")
|
||||
name = os.getenv("FORECASTING_DB_NAME", "forecasting_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Redis Database (dedicated for prediction cache)
|
||||
REDIS_DB: int = 2
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Inventory Service Configuration
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
from pydantic import Field
|
||||
from shared.config.base import BaseServiceSettings
|
||||
@@ -20,11 +21,23 @@ class Settings(BaseServiceSettings):
|
||||
# API Configuration
|
||||
API_V1_STR: str = "/api/v1"
|
||||
|
||||
# Override database URL to use INVENTORY_DATABASE_URL
|
||||
DATABASE_URL: str = Field(
|
||||
default="postgresql+asyncpg://inventory_user:inventory_pass123@inventory-db:5432/inventory_db",
|
||||
env="INVENTORY_DATABASE_URL"
|
||||
)
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("INVENTORY_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("INVENTORY_DB_USER", "inventory_user")
|
||||
password = os.getenv("INVENTORY_DB_PASSWORD", "inventory_pass123")
|
||||
host = os.getenv("INVENTORY_DB_HOST", "localhost")
|
||||
port = os.getenv("INVENTORY_DB_PORT", "5432")
|
||||
name = os.getenv("INVENTORY_DB_NAME", "inventory_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Inventory-specific Redis database
|
||||
REDIS_DB: int = Field(default=3, env="INVENTORY_REDIS_DB")
|
||||
|
||||
@@ -19,9 +19,23 @@ class NotificationSettings(BaseServiceSettings):
|
||||
SERVICE_NAME: str = "notification-service"
|
||||
DESCRIPTION: str = "Email and WhatsApp notification service"
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("NOTIFICATION_DATABASE_URL",
|
||||
"postgresql+asyncpg://notification_user:notification_pass123@notification-db:5432/notification_db")
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("NOTIFICATION_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("NOTIFICATION_DB_USER", "notification_user")
|
||||
password = os.getenv("NOTIFICATION_DB_PASSWORD", "notification_pass123")
|
||||
host = os.getenv("NOTIFICATION_DB_HOST", "localhost")
|
||||
port = os.getenv("NOTIFICATION_DB_PORT", "5432")
|
||||
name = os.getenv("NOTIFICATION_DB_NAME", "notification_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Redis Database (dedicated for notification queue)
|
||||
REDIS_DB: int = 5
|
||||
|
||||
@@ -18,9 +18,23 @@ class OrdersSettings(BaseServiceSettings):
|
||||
VERSION: str = "1.0.0"
|
||||
DESCRIPTION: str = "Customer orders and procurement planning"
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("ORDERS_DATABASE_URL",
|
||||
"postgresql+asyncpg://orders_user:orders_pass123@orders-db:5432/orders_db")
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("ORDERS_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("ORDERS_DB_USER", "orders_user")
|
||||
password = os.getenv("ORDERS_DB_PASSWORD", "orders_pass123")
|
||||
host = os.getenv("ORDERS_DB_HOST", "localhost")
|
||||
port = os.getenv("ORDERS_DB_PORT", "5432")
|
||||
name = os.getenv("ORDERS_DB_NAME", "orders_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Order Processing
|
||||
ORDER_PROCESSING_ENABLED: bool = os.getenv("ORDER_PROCESSING_ENABLED", "true").lower() == "true"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
POS Integration Service Configuration
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List, Optional
|
||||
from pydantic import Field
|
||||
from shared.config.base import BaseServiceSettings
|
||||
@@ -20,11 +21,23 @@ class Settings(BaseServiceSettings):
|
||||
# API Configuration
|
||||
API_V1_STR: str = "/api/v1"
|
||||
|
||||
# Override database URL to use POS_DATABASE_URL
|
||||
DATABASE_URL: str = Field(
|
||||
default="postgresql+asyncpg://pos_user:pos_pass123@pos-db:5432/pos_db",
|
||||
env="POS_DATABASE_URL"
|
||||
)
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("POS_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("POS_DB_USER", "pos_user")
|
||||
password = os.getenv("POS_DB_PASSWORD", "pos_pass123")
|
||||
host = os.getenv("POS_DB_HOST", "localhost")
|
||||
port = os.getenv("POS_DB_PORT", "5432")
|
||||
name = os.getenv("POS_DB_NAME", "pos_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# POS-specific Redis database
|
||||
REDIS_DB: int = Field(default=5, env="POS_REDIS_DB")
|
||||
|
||||
@@ -20,9 +20,23 @@ class ProductionSettings(BaseServiceSettings):
|
||||
VERSION: str = "1.0.0"
|
||||
DESCRIPTION: str = "Production planning and batch management"
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("PRODUCTION_DATABASE_URL",
|
||||
"postgresql+asyncpg://production_user:production_pass123@production-db:5432/production_db")
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("PRODUCTION_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("PRODUCTION_DB_USER", "production_user")
|
||||
password = os.getenv("PRODUCTION_DB_PASSWORD", "production_pass123")
|
||||
host = os.getenv("PRODUCTION_DB_HOST", "localhost")
|
||||
port = os.getenv("PRODUCTION_DB_PORT", "5432")
|
||||
name = os.getenv("PRODUCTION_DB_NAME", "production_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Redis Database (for production queues and caching)
|
||||
REDIS_DB: int = 3
|
||||
|
||||
@@ -17,11 +17,23 @@ class Settings:
|
||||
# API settings
|
||||
API_V1_PREFIX: str = "/api/v1"
|
||||
|
||||
# Override DATABASE_URL for recipes service
|
||||
DATABASE_URL: str = os.getenv(
|
||||
"RECIPES_DATABASE_URL",
|
||||
"postgresql://recipes_user:recipes_pass@localhost:5432/recipes_db"
|
||||
)
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("RECIPES_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("RECIPES_DB_USER", "recipes_user")
|
||||
password = os.getenv("RECIPES_DB_PASSWORD", "recipes_pass123")
|
||||
host = os.getenv("RECIPES_DB_HOST", "localhost")
|
||||
port = os.getenv("RECIPES_DB_PORT", "5432")
|
||||
name = os.getenv("RECIPES_DB_NAME", "recipes_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Redis (if needed for caching)
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Sales Service Configuration
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
from pydantic import Field
|
||||
from shared.config.base import BaseServiceSettings
|
||||
@@ -20,11 +21,23 @@ class Settings(BaseServiceSettings):
|
||||
# API Configuration
|
||||
API_V1_STR: str = "/api/v1"
|
||||
|
||||
# Override database URL to use SALES_DATABASE_URL
|
||||
DATABASE_URL: str = Field(
|
||||
default="postgresql+asyncpg://sales_user:sales_pass123@sales-db:5432/sales_db",
|
||||
env="SALES_DATABASE_URL"
|
||||
)
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("SALES_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("SALES_DB_USER", "sales_user")
|
||||
password = os.getenv("SALES_DB_PASSWORD", "sales_pass123")
|
||||
host = os.getenv("SALES_DB_HOST", "localhost")
|
||||
port = os.getenv("SALES_DB_PORT", "5432")
|
||||
name = os.getenv("SALES_DB_NAME", "sales_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Sales-specific Redis database
|
||||
REDIS_DB: int = Field(default=2, env="SALES_REDIS_DB")
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Supplier & Procurement Service Configuration
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
from pydantic import Field
|
||||
from shared.config.base import BaseServiceSettings
|
||||
@@ -20,11 +21,23 @@ class Settings(BaseServiceSettings):
|
||||
# API Configuration
|
||||
API_V1_STR: str = "/api/v1"
|
||||
|
||||
# Override database URL to use SUPPLIERS_DATABASE_URL
|
||||
DATABASE_URL: str = Field(
|
||||
default="postgresql+asyncpg://suppliers_user:suppliers_pass123@suppliers-db:5432/suppliers_db",
|
||||
env="SUPPLIERS_DATABASE_URL"
|
||||
)
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("SUPPLIERS_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("SUPPLIERS_DB_USER", "suppliers_user")
|
||||
password = os.getenv("SUPPLIERS_DB_PASSWORD", "suppliers_pass123")
|
||||
host = os.getenv("SUPPLIERS_DB_HOST", "localhost")
|
||||
port = os.getenv("SUPPLIERS_DB_PORT", "5432")
|
||||
name = os.getenv("SUPPLIERS_DB_NAME", "suppliers_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Suppliers-specific Redis database
|
||||
REDIS_DB: int = Field(default=4, env="SUPPLIERS_REDIS_DB")
|
||||
|
||||
@@ -19,9 +19,23 @@ class TenantSettings(BaseServiceSettings):
|
||||
SERVICE_NAME: str = "tenant-service"
|
||||
DESCRIPTION: str = "Multi-tenant management and subscription service"
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("TENANT_DATABASE_URL",
|
||||
"postgresql+asyncpg://tenant_user:tenant_pass123@tenant-db:5432/tenant_db")
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("TENANT_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("TENANT_DB_USER", "tenant_user")
|
||||
password = os.getenv("TENANT_DB_PASSWORD", "tenant_pass123")
|
||||
host = os.getenv("TENANT_DB_HOST", "localhost")
|
||||
port = os.getenv("TENANT_DB_PORT", "5432")
|
||||
name = os.getenv("TENANT_DB_NAME", "tenant_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Redis Database (dedicated for tenant data)
|
||||
REDIS_DB: int = 4
|
||||
|
||||
@@ -19,9 +19,23 @@ class TrainingSettings(BaseServiceSettings):
|
||||
SERVICE_NAME: str = "training-service"
|
||||
DESCRIPTION: str = "Machine learning model training service"
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("TRAINING_DATABASE_URL",
|
||||
"postgresql+asyncpg://training_user:training_pass123@training-db:5432/training_db")
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("TRAINING_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("TRAINING_DB_USER", "training_user")
|
||||
password = os.getenv("TRAINING_DB_PASSWORD", "training_pass123")
|
||||
host = os.getenv("TRAINING_DB_HOST", "localhost")
|
||||
port = os.getenv("TRAINING_DB_PORT", "5432")
|
||||
name = os.getenv("TRAINING_DB_NAME", "training_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# Redis Database (dedicated for training cache)
|
||||
REDIS_DB: int = 1
|
||||
|
||||
Reference in New Issue
Block a user