- Add configuration to exclude system namespaces by default - Add UI checkbox to include system namespaces when needed - Update API endpoints to accept include_system_namespaces parameter - Update Kubernetes client to apply namespace filtering - Update ConfigMap and deployment with new environment variables - Fix Dockerfile to install dependencies globally - Test functionality with both filtered and unfiltered results
65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
"""
|
|
Configurações da aplicação
|
|
"""
|
|
import os
|
|
from typing import List, Optional
|
|
from pydantic_settings import BaseSettings
|
|
from pydantic import Field
|
|
|
|
class Settings(BaseSettings):
|
|
"""Configurações da aplicação"""
|
|
|
|
# Configurações do OpenShift/Kubernetes
|
|
kubeconfig_path: Optional[str] = None
|
|
cluster_url: Optional[str] = None
|
|
token: Optional[str] = None
|
|
|
|
# Configurações do Prometheus
|
|
prometheus_url: str = "http://prometheus.openshift-monitoring.svc.cluster.local:9090"
|
|
|
|
# Configurações de validação
|
|
cpu_limit_ratio: float = 3.0 # Ratio padrão limit:request para CPU
|
|
memory_limit_ratio: float = 3.0 # Ratio padrão limit:request para memória
|
|
min_cpu_request: str = "10m" # Mínimo de CPU request
|
|
min_memory_request: str = "32Mi" # Mínimo de memória request
|
|
|
|
# Namespaces críticos para VPA
|
|
critical_namespaces: List[str] = [
|
|
"openshift-monitoring",
|
|
"openshift-ingress",
|
|
"openshift-apiserver",
|
|
"openshift-controller-manager",
|
|
"openshift-sdn"
|
|
]
|
|
|
|
# Configurações de filtro de namespaces
|
|
include_system_namespaces: bool = Field(default=False, alias="INCLUDE_SYSTEM_NAMESPACES")
|
|
system_namespace_prefixes: List[str] = Field(
|
|
default=[
|
|
"kube-",
|
|
"openshift-",
|
|
"default",
|
|
"kube-system",
|
|
"kube-public",
|
|
"kube-node-lease"
|
|
],
|
|
alias="SYSTEM_NAMESPACE_PREFIXES"
|
|
)
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = False
|
|
|
|
# Configurações de relatório
|
|
report_export_path: str = "/tmp/reports"
|
|
|
|
# Configurações de segurança
|
|
enable_rbac: bool = True
|
|
service_account_name: str = "resource-governance-sa"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = False
|
|
|
|
settings = Settings()
|