配置说明
本文档详细说明 KubePolaris 的所有配置项。
配置文件
KubePolaris 支持以下方式加载配置(优先级从高到低):
- 命令行参数
- 环境变量
- 配置文件 (
configs/config.yaml) - 默认值
配置项详解
服务器配置
server:
# 服务监听端口
port: 8080
# 运行模式: debug, release, test
mode: release
# 读取超时(秒)
read_timeout: 60
# 写入超时(秒)
write_timeout: 60
# 最大请求体大小(MB)
max_request_size: 100
# 静态文件目录
static_path: ./ui/dist
数据库配置
database:
# MySQL 主机地址
host: localhost
# MySQL 端口
port: 3306
# 数据库用户名
user: root
# 数据库密码
password: your_password
# 数据库名称
name: kubepolaris
# 字符集
charset: utf8mb4
# 连接池配置
max_idle_conns: 10
max_open_conns: 100
conn_max_lifetime: 3600 # 秒
# 是否启用 SQL 日志
log_mode: false
JWT 认证配置
jwt:
# JWT 签名密钥(请使用随机 字符串)
secret: your-jwt-secret-key-please-change-it
# Token 过期时间
expire: 24h
# Token 刷新时间
refresh_expire: 168h # 7 天
# Token 签发者
issuer: kubepolaris
日志配置
log:
# 日志级别: debug, info, warn, error
level: info
# 日志格式: json, text
format: json
# 是否输出到文件
file:
enabled: false
path: ./logs/kubepolaris.log
max_size: 100 # MB
max_backups: 10
max_age: 30 # 天
compress: true
CORS 配置
cors:
# 是否启用 CORS
enabled: true
# 允许的来源
allow_origins:
- "*" # 生产环境请指定具体域名
# 允许的方法
allow_methods:
- GET
- POST
- PUT
- DELETE
- PATCH
- OPTIONS
# 允许的请求头
allow_headers:
- Authorization
- Content-Type
- X-Requested-With
# 是否允许携带凭证
allow_credentials: true
# 预检请求缓存时间(秒)
max_age: 86400
Kubernetes 客户端配置
kubernetes:
# 默认请求超时(秒)
timeout: 30
# QPS 限制
qps: 100
# Burst 限制
burst: 200
# 是否缓存客户端
cache_enabled: true
# 缓存过期时间(秒)
cache_ttl: 300
监控配置
monitoring:
# Prometheus 配置
prometheus:
enabled: false
url: http://prometheus:9090
timeout: 30s
# Grafana 配置
grafana:
enabled: false
url: http://grafana:3000
api_key: your-grafana-api-key
org_id: 1
告警配置
alerting:
# AlertManager 配置
alertmanager:
enabled: false
url: http://alertmanager:9093
审计日志配置
audit:
# 是否启用审计日志
enabled: true
# 审计日志保留天数
retention_days: 90
# 敏感操作需要二次确认
require_confirm:
- delete_cluster
- delete_namespace
- scale_to_zero
终端配置
terminal:
# 终端会话超时(秒)
session_timeout: 1800 # 30 分钟
# 最大并发连接数
max_connections: 100
# 心跳间隔(秒)
heartbeat_interval: 30
# 是否记录终端操作
record_enabled: true
安全配置
security:
# 密码策略
password:
min_length: 8
require_uppercase: true
require_lowercase: true
require_number: true
require_special: false
# 登录安全
login:
max_attempts: 5
lockout_duration: 900 # 秒
captcha_after_attempts: 3
# 会话安全
session:
single_login: false # 是否限制单点登录
idle_timeout: 3600 # 空闲超时(秒)