creativestore · app 命名空间下的后端微服务

creativestore 是 yldm-services ApplicationSet 生成的一个 app 类微服务,镜像来自私有 GHCR,以 2 副本无状态 Deployment 运行在 workload: app 的节点上,对外暴露 HTTP 8080。它通过 pgbouncer 连接 Postgres、使用 Redis 做缓存与 pub/sub,并在启动时向 Consul 注册自身。以下事实均来自 applications/app/creativestore/ 下的 manifest,业务语义未在仓库中说明,这里只描述可验证的技术形态。

部署形态

  • Name
    命名空间
    Description
    app(kustomization 设 namespace: app + namePrefix: app-,生成的资源为 app-creativestore-*)
  • Name
    工作负载
    Description
    Deployment,replicas: 2(kustomization replicas: 也固定为 2)
  • Name
    镜像
    Description
    ghcr.io/yldm-tech/creativestore,kustomization images: 的 newTag 为 2.5.0(由 argocd-image-updater semver 写回,是权威版本;deployment.yaml 内联的 2.3.1 会被 kustomize 覆盖)
  • Name
    调度
    Description
    nodeSelector: workload: app;priorityClassName: production-medium;软反亲和(podAntiAffinity preferred,按 kubernetes.io/hostname 打散同 app=creativestore 的 pod)
  • Name
    端口
    Description
    容器 containerPort: 8080(name http)
  • Name
    资源
    Description
    requests cpu 50m / memory 64Mi,limits cpu 200m / memory 256Mi
  • Name
    滚动策略
    Description
    maxUnavailable: 0,maxSurge: 1
  • Name
    探针
    Description
    livenessProbe GET /health/live(initialDelay 30s,period 10s);readinessProbe GET /health/ready(initialDelay 15s,period 5s,timeout 5s)
  • Name
    拉取凭证
    Description
    imagePullSecrets: ghcr-secret

无 PVC,纯无状态服务。Deployment 带 reloader.stakater.com/auto: "true" 注解,挂载的 ConfigMap/Secret 变更时会自动触发重启。

配置与依赖

配置分两层挂载:共享的 base-config ConfigMap 挂到 /root/configs/base,服务专属的 creativestore-config ConfigMap 以 subPath 挂到 /root/configs/services/creativestore.yaml,容器用 CONFIG_FILE=configs/services/creativestore.yaml 加载。服务配置继承 base 的 production.yaml 并覆盖以下字段:

配置项
database.database${DB_NAME:yldm_creativestore}
redis.db${REDIS_DB:7}
tracing.service_nameyldm-creativestore
pubsub.prefixyldm:creativestore
pubsub.redis.db${REDIS_PUBSUB_DB:1}
pubsub.dead_letter.keyyldm:creativestore:deadletter

数据库连接走 pgbouncer:DB_HOST=pgbouncer.postgres.svc.cluster.local(明文 env),其余 DB/Redis/JWT 凭证从专属 Secret creativestore-db-secret 注入,实现凭证隔离。该 Secret 由 ExternalSecret 从 Vault 拉取,refreshInterval: 1h,通过 ClusterSecretStore vault-backend 读取:

  • Name
    remoteRef.key (服务专属)
    Description
    yldm/production/creativestore —— db_host/db_port/db_name/db_user/db_password、redis_host/redis_port/redis_password/redis_db/redis_pubsub_db、jwt_secret/jwt_expires_in/jwt_refresh_expires_in
  • Name
    remoteRef.key (共享库凭证)
    Description
    yldm/database —— user → DB_ADMIN_USER,password → DB_ADMIN_PASSWORD

Consul 服务注册由 env 开启:CONSUL_ENABLED=true,CONSUL_ADDR=consul.consul.svc.cluster.local:8500,SERVER_NAME=creativestore,SERVER_PORT=8080。运行模式相关 env:ENV=productionENVIRONMENT=productionSERVER_MODE=releaseSWAGGER_AUTO_GEN=false

依赖小结:Postgres(经 postgres 命名空间的 pgbouncer)、Redis(db 7 缓存 / db 1 pub/sub)、Consul、Vault(经 External Secrets)。

访问与监控

  • Name
    Service
    Description
    ClusterIP(默认类型),port: 80targetPort: 8080,name http。仓库内无 Ingress,仅集群内访问。
  • Name
    ServiceMonitor
    Description
    有。抓 http 端口 path: /metrics,interval: 30s,并 relabel 出 pod/namespace/service 标签。
  • Name
    PrometheusRule
    Description
    有,creativestore.rules(interval 30s)。覆盖 pod 宕机(CreativestorePodDown,1m critical)、副本不足(CreativestoreInsufficientPods)、5xx 错误率(>3% warning / >5% critical)、P95 延迟(>0.5s warning / >1s critical)、频繁重启、CPU/内存超 80% 等告警。
  • Name
    HPA
    Description
    creativestore-hpa,min 2 / max 5,按 CPU 平均利用率 70%、内存平均利用率 80% 扩缩。
  • Name
    VPA
    Description
    creativestore-vpa,updateMode: "Off"(仅建议不自动改),min cpu 25m/mem 32Mi,max cpu 500m/mem 512Mi。
  • Name
    PDB
    Description
    maxUnavailable: 1(符合本仓库单/多副本约定,不会卡住节点 drain)。

返回 app 服务总览

评论