feat(chart): 添加 Helm Chart 部署方案#445
Conversation
新增 Helm Chart 支持完整的 SkillHub 私有化部署,包括: - PostgreSQL/Redis 内置 StatefulSet 及外部模式切换 - 零依赖设计,无需 Bitnami 子 Chart - 支持 standalone/cluster 数据库架构 - NodePort/LoadBalancer/ClusterIP 多种服务类型 - HPA、PDB、ServiceMonitor 完整运维支持 - cert-manager 证书自动签发 - initContainer 等待数据库和 Redis 就绪 - PVC 卸载保护 (helm.sh/resource-policy: keep) - GitHub Actions: PR 校验 + 发布到 GHCR OCI
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Helm chart for the SkillHub application, covering backend, frontend, and scanner components along with internal PostgreSQL and Redis statefulsets. The review identified several critical security and stability issues: sensitive credentials for Redis and S3 are exposed as plain text environment variables, and the use of randAlphaNum for secrets without persistence checks will cause authentication failures during Helm upgrades. Furthermore, the PostgreSQL configuration for multiple replicas is invalid for the base image used and risks data corruption. Other feedback includes the need for configuration checksums to trigger rolling updates, fixing hardcoded usernames in health probes, and avoiding the latest image tag for production stability.
| spring-datasource-password: {{ if eq .Values.database.mode "internal" }}{{ default (randAlphaNum 16) .Values.secrets.springDatasourcePassword }}{{ else }}{{ .Values.database.external.password }}{{ end }} | ||
|
|
||
| bootstrap-admin-password: {{ .Values.secrets.bootstrapAdminPassword | default .Values.bootstrapAdmin.password | default (randAlphaNum 16) }} |
There was a problem hiding this comment.
已修复。使用 lookup 函数检查集群中是否已存在该 Secret,若存在则保留原值,仅在首次安装时生成随机密码。避免了 helm upgrade 因密码重新生成导致的数据库连接中断问题。
| - name: SPRING_DATA_REDIS_PASSWORD | ||
| value: {{ .Values.redis.external.password }} | ||
| {{- end }} |
There was a problem hiding this comment.
已修复。Redis 密码已从明文环境变量移除,改为通过 secretKeyRef 从 Secret 中引用。对应的 redis-password 字段已添加至 Secret 模板。
| - name: SKILLHUB_S3_ACCESS_KEY | ||
| value: {{ .Values.storage.s3.accessKey }} | ||
| {{- end }} | ||
| {{- if .Values.storage.s3.secretKey }} | ||
| - name: SKILLHUB_S3_SECRET_KEY | ||
| value: {{ .Values.storage.s3.secretKey }} | ||
| {{- end }} |
There was a problem hiding this comment.
已修复。S3 的 AccessKey 和 SecretKey 已从 Deployment 明文配置移除,改为通过 secretKeyRef 从 Secret 中引用。对应的 s3-access-key 和 s3-secret-key 字段已在 Secret 模板中定义。
| labels: | ||
| {{- include "skillhub.server.selectorLabels" . | nindent 8 }} | ||
| annotations: | ||
| {{- toYaml .Values.server.podAnnotations | nindent 8 }} |
There was a problem hiding this comment.
建议在 Pod 模板的注解中添加 ConfigMap 和 Secret 的校验和(checksum)。这样当配置发生变化时,Deployment 会自动触发 Pod 的滚动更新。如果没有这些注解,用户修改配置后必须手动重启 Pod 才能生效。
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- toYaml .Values.server.podAnnotations | nindent 8 }}There was a problem hiding this comment.
已修复。已在 server/web/scanner 三个 Deployment 的 Pod 注解中添加 checksum/config 和 checksum/secret,基于 ConfigMap 和 Secret 相关的 values 子集计算 SHA256。配置变更后 Deployment 将自动触发滚动更新。
| echo "Redis is ready!" | ||
| containers: | ||
| - name: server | ||
| image: {{ .Values.images.registry }}/skillhub-server:{{ .Values.images.tag }} |
There was a problem hiding this comment.
已修复。server/web/scanner 三个 Deployment 的镜像地址均已改为 {{ .Values.global.imageRegistry | default .Values.images.registry }},优先使用全局 registry 覆盖。
| app.kubernetes.io/component: database | ||
| spec: | ||
| serviceName: {{ include "skillhub.fullname" . }}-postgres | ||
| replicas: {{ if eq .Values.database.architecture "cluster" }}3{{ else }}1{{ end }} |
There was a problem hiding this comment.
已修复。internal 模式下 PostgreSQL StatefulSet 的 replicas 强制为 1,移除了 architecture: cluster 时设为 3 的逻辑。内置 postgres:16-alpine 镜像不支持自动集群化,如需高可用请使用 external 模式连接外部 PostgreSQL 集群(如 Patroni)。
| - skillhub | ||
| - -h | ||
| - localhost | ||
| initialDelaySeconds: 10 | ||
| periodSeconds: 10 | ||
| livenessProbe: | ||
| exec: | ||
| command: | ||
| - pg_isready | ||
| - -U | ||
| - skillhub |
There was a problem hiding this comment.
已修复。探针命令已改用 sh -c "pg_isready -U \"${POSTGRES_USER}\" -h localhost",通过环境变量动态获取数据库用户名,不再硬编码。
| # ============================================================================ | ||
| images: | ||
| registry: ghcr.io/iflytek | ||
| tag: latest |
There was a problem hiding this comment.
已修复。默认镜像标签已从 latest 改为 v0.2.8,支持可追溯的版本回滚。
- secret.yaml: lookup 检查现有 Secret 避免 upgrade 重新生成密码 - secret.yaml: Redis/S3 凭据通过 Secret 引用,移除明文环境变量 - backend/frontend/scanner: 新增 checksum 注解,配置变更自动触发滚动更新 - backend/frontend/scanner: 镜像地址支持 global.imageRegistry 覆盖 - postgres: internal 模式仅支持单副本,移除伪集群配置 - postgres: 探针用户名改用 POSTGRES_USER 环境变量 - values.yaml: accessMode 默认 ReadWriteMany,tag 指定 v0.2.8
values.yaml 中 images.tag 留空时自动取 Chart.yaml 的 appVersion,
格式为 v{appVersion}(如 0.2.8 → v0.2.8)。
用户仍可通过 --set images.tag=xxx 显式覆盖。
|
您好!这个 PR 添加了 Helm Chart 部署方案与 CI/CD 工作流,包括:
当前有 workflows 需要您的批准才能运行,烦请批准,谢谢! |
概述
添加 Helm Chart 部署支持。
核心特性
安装示例
CI/CD