feat(helm chart): 更新Helm Chart到0.11.6-beta版本,调整配置存储方式到文件。

This commit is contained in:
zhangxinhui02
2025-12-23 01:14:28 +08:00
parent c105884658
commit 53bef5ae26
29 changed files with 504 additions and 592 deletions

View File

@@ -4,13 +4,30 @@ metadata:
name: {{ .Release.Name }}-maibot-adapter
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.adapter.persistence.accessModes }}
{{- if .Values.adapter.persistence.data.accessModes }}
accessModes:
{{ toYaml .Values.adapter.persistence.accessModes | nindent 4 }}
{{ toYaml .Values.adapter.persistence.data.accessModes | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ .Values.adapter.persistence.size }}
{{- if .Values.adapter.persistence.storageClass }}
storageClassName: {{ .Values.adapter.persistence.storageClass | default nil }}
storage: {{ .Values.adapter.persistence.data.size }}
{{- if .Values.adapter.persistence.data.storageClass }}
storageClassName: {{ .Values.adapter.persistence.data.storageClass | default nil }}
{{- end }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-maibot-adapter-config
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.adapter.persistence.config.accessModes }}
accessModes:
{{ toYaml .Values.adapter.persistence.config.accessModes | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ .Values.adapter.persistence.config.size }}
{{- if .Values.adapter.persistence.config.storageClass }}
storageClassName: {{ .Values.adapter.persistence.config.storageClass | default nil }}
{{- end }}

View File

@@ -7,7 +7,7 @@ metadata:
app: {{ .Release.Name }}-maibot-adapter
spec:
serviceName: {{ .Release.Name }}-maibot-adapter
replicas: 1
replicas: 0 # post-install任务初始化完毕后自动扩容至1
selector:
matchLabels:
app: {{ .Release.Name }}-maibot-adapter
@@ -36,7 +36,6 @@ spec:
name: data
- mountPath: /adapters/config.toml
name: config
readOnly: true
subPath: config.toml
{{- if .Values.adapter.image.pullSecrets }}
imagePullSecrets:
@@ -54,9 +53,6 @@ spec:
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-adapter
- configMap:
items:
- key: config.toml
path: config.toml
name: {{ .Release.Name }}-maibot-adapter-config
name: config
- name: config
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-adapter-config

View File

@@ -1,14 +0,0 @@
{{- if or .Release.IsInstall (and .Values.core.webui.enabled .Values.config.enable_config_override_with_webui) (and (not .Values.core.webui.enabled) .Values.config.enable_config_override_without_webui) }}
# 渲染规则:
# 初次安装,或配置了覆盖规则
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-maibot-core-bot-config
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/resource-policy": keep
data:
bot_config.toml: |
{{ .Values.config.core_bot_config | nindent 4 }}
{{- end }}

View File

@@ -1,13 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-maibot-core-env-config
namespace: {{ .Release.Namespace }}
data:
.env: |
HOST=0.0.0.0
PORT=8000
WEBUI_ENABLED={{ if .Values.core.webui.enabled }}true{{ else }}false{{ end }}
WEBUI_MODE=production
WEBUI_HOST=0.0.0.0
WEBUI_PORT=8001

View File

@@ -1,14 +0,0 @@
{{- if or .Release.IsInstall (and .Values.core.webui.enabled .Values.config.enable_config_override_with_webui) (and (not .Values.core.webui.enabled) .Values.config.enable_config_override_without_webui) }}
# 渲染规则:
# 初次安装,或配置了覆盖规则
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-maibot-core-model-config
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/resource-policy": keep
data:
model_config.toml: |
{{ .Values.config.core_model_config | nindent 4 }}
{{- end }}

View File

@@ -4,13 +4,30 @@ metadata:
name: {{ .Release.Name }}-maibot-core
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.core.persistence.accessModes }}
{{- if .Values.core.persistence.data.accessModes }}
accessModes:
{{ toYaml .Values.core.persistence.accessModes | nindent 4 }}
{{ toYaml .Values.core.persistence.data.accessModes | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ .Values.core.persistence.size }}
{{- if .Values.core.persistence.storageClass }}
storageClassName: {{ .Values.core.persistence.storageClass | default nil }}
storage: {{ .Values.core.persistence.data.size }}
{{- if .Values.core.persistence.data.storageClass }}
storageClassName: {{ .Values.core.persistence.data.storageClass | default nil }}
{{- end }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-maibot-core-config
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.core.persistence.config.accessModes }}
accessModes:
{{ toYaml .Values.core.persistence.config.accessModes | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ .Values.core.persistence.config.size }}
{{- if .Values.core.persistence.config.storageClass }}
storageClassName: {{ .Values.core.persistence.config.storageClass | default nil }}
{{- end }}

View File

@@ -7,7 +7,7 @@ metadata:
app: {{ .Release.Name }}-maibot-core
spec:
serviceName: {{ .Release.Name }}-maibot-core
replicas: 1
replicas: 0 # post-install任务初始化完毕后自动扩容至1
selector:
matchLabels:
app: {{ .Release.Name }}-maibot-core
@@ -31,9 +31,9 @@ spec:
value: "9943b855e72199d0f5016ea39052f1b6"
{{- if .Values.core.webui.enabled }}
- name: MAIBOT_WEBUI_ENABLED
value: "true"
value: {{ .Values.core.webui.enabled }}
{{- end}}
image: {{ .Values.core.image.repository | default "sengokucola/maibot" }}:{{ .Values.core.image.tag | default "0.11.5-beta" }}
image: {{ .Values.core.image.repository | default "sengokucola/maibot" }}:{{ .Values.core.image.tag | default "0.11.6-beta" }}
imagePullPolicy: {{ .Values.core.image.pullPolicy }}
ports:
- containerPort: 8000
@@ -56,59 +56,18 @@ spec:
readOnly: true
subPath: k8s-init.sh
- mountPath: /MaiMBot/.env
name: env-config
readOnly: true
name: config
subPath: .env
{{- if not .Values.core.webui.enabled }}
- mountPath: /MaiMBot/config/model_config.toml
name: model-config
readOnly: true
name: config
subPath: model_config.toml
- mountPath: /MaiMBot/config/bot_config.toml
name: bot-config
readOnly: true
name: config
subPath: bot_config.toml
{{- end }}
{{- if .Values.statistics_dashboard.enabled }}
- mountPath: /MaiMBot/statistics
name: statistics
{{- end }}
{{- if .Values.core.webui.enabled }}
- mountPath: /MaiMBot/webui-cm-sync
name: webui-cm-sync
{{- end }}
{{- if .Values.core.webui.enabled }}
- name: webui-cm-sync
image: {{ .Values.core.webui.cm_sync.image.repository | default "reg.mikumikumi.xyz/maibot/core-webui-cm-sync" }}:{{ .Values.core.webui.cm_sync.image.tag | default "0.11.5-beta" }}
imagePullPolicy: {{ .Values.core.webui.cm_sync.image.pullPolicy }}
env:
- name: PYTHONUNBUFFERED
value: "1"
- name: RELEASE_NAME
value: {{ .Release.Name }}
volumeMounts:
- mountPath: /MaiMBot/webui-cm-sync
name: webui-cm-sync
{{- end }}
{{- if .Values.core.setup_default_plugins }}
initContainers: # 用户插件目录存储在存储卷中,会在启动时覆盖掉容器的默认插件目录。此初始化容器用于默认插件更新后或麦麦首次启动时为用户自动安装默认插件到存储卷中
- args:
- setup-plugins.py
command:
- python3
workingDir: /MaiMBot
image: {{ .Values.core.image.repository | default "sengokucola/maibot" }}:{{ .Values.core.image.tag | default "0.11.5-beta" }}
imagePullPolicy: {{ .Values.core.image.pullPolicy }}
name: setup-plugins
resources: { }
volumeMounts:
- mountPath: /MaiMBot/data
name: data
- mountPath: /MaiMBot/setup-plugins.py
name: scripts
readOnly: true
subPath: setup-plugins.py
{{- end }}
serviceAccountName: {{ .Release.Name }}-maibot-sa
{{- if .Values.core.image.pullSecrets }}
imagePullSecrets:
@@ -130,38 +89,13 @@ spec:
items:
- key: k8s-init.sh
path: k8s-init.sh
{{- if .Values.core.setup_default_plugins }}
- key: setup-plugins.py
path: setup-plugins.py
{{- end }}
name: {{ .Release.Name }}-maibot-scripts
name: scripts
- configMap:
items:
- key: .env
path: .env
name: {{ .Release.Name }}-maibot-core-env-config
name: env-config
{{- if not .Values.core.webui.enabled }}
- configMap:
items:
- key: model_config.toml
path: model_config.toml
name: {{ .Release.Name }}-maibot-core-model-config
name: model-config
- configMap:
items:
- key: bot_config.toml
path: bot_config.toml
name: {{ .Release.Name }}-maibot-core-bot-config
name: bot-config
{{- end }}
- name: config
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-core-config
{{- if .Values.statistics_dashboard.enabled }}
- name: statistics
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-statistics-dashboard
{{- end }}
{{- if .Values.core.webui.enabled }}
- emptyDir: {}
name: webui-cm-sync
{{- end }}

View File

@@ -26,7 +26,7 @@ spec:
value: "{{ .Values.napcat.permission.uid }}"
- name: TZ
value: Asia/Shanghai
image: {{ .Values.napcat.image.repository | default "mlikiowa/napcat-docker" }}:{{ .Values.napcat.image.tag | default "v4.9.73" }}
image: {{ .Values.napcat.image.repository | default "mlikiowa/napcat-docker" }}:{{ .Values.napcat.image.tag | default "v4.9.80" }}
imagePullPolicy: {{ .Values.napcat.image.pullPolicy }}
livenessProbe:
failureThreshold: 3

View File

@@ -1,8 +1,8 @@
# 检查EULA和PRIVACY
{{- if not .Values.EULA_AGREE }}
{{- fail "You must accept the EULA by setting 'EULA_AGREE: true'. EULA: https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md" }}
{{ fail "You must accept the EULA by setting 'EULA_AGREE: true'. EULA: https://github.com/Mai-with-u/MaiBot/blob/main/EULA.md" }}
{{- end }}
{{- if not .Values.PRIVACY_AGREE }}
{{- fail "You must accept the Privacy Policy by setting 'PRIVACY_AGREE: true'. Privacy Policy: https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md" }}
{{ fail "You must accept the Privacy Policy by setting 'PRIVACY_AGREE: true'. Privacy Policy: https://github.com/Mai-with-u/MaiBot/blob/main/PRIVACY.md" }}
{{- end }}

View File

@@ -7,8 +7,3 @@ data:
# core
k8s-init.sh: |
{{ .Files.Get "files/k8s-init.sh" | nindent 4 }}
# core的初始化容器
{{- if .Values.core.setup_default_plugins }}
setup-plugins.py: |
{{ .Files.Get "files/setup-plugins.py" | nindent 4 }}
{{- end }}

View File

@@ -1,30 +0,0 @@
# 动态生成adapter配置文件的configmap的job仅会在部署时运行一次
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-maibot-adapter-cm-generator
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
backoffLimit: 2
template:
spec:
serviceAccountName: {{ .Release.Name }}-maibot-sa
restartPolicy: Never
containers:
- name: adapter-cm-generator
image: {{ .Values.adapter.cm_generator.image.repository | default "reg.mikumikumi.xyz/maibot/adapter-cm-generator" }}:{{ .Values.adapter.cm_generator.image.tag | default "0.11.5-beta" }}
workingDir: /app
env:
- name: PYTHONUNBUFFERED
value: "1"
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: RELEASE_NAME
value: {{ .Release.Name }}
- name: DATA_B64
value: {{ .Values.config.adapter_config | b64enc }} # 将配置文件编码为base64从环境变量注入

View File

@@ -0,0 +1,58 @@
# 预处理脚本,仅会在部署前运行一次
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-maibot-preprocessor
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
backoffLimit: 2
template:
spec:
serviceAccountName: {{ .Release.Name }}-maibot-sa
restartPolicy: Never
containers:
- name: preprocessor
image: {{ .Values.pre_processor.image.repository | default "reg.mikumikumi.xyz/maibot/preprocessor" }}:{{ .Values.pre_processor.image.tag | default "0.11.6-beta" }}
imagePullPolicy: {{ .Values.pre_processor.image.pullPolicy }}
env:
- name: RELEASE_NAME
value: {{ .Release.Name }}
{{- if or .Values.config.override_adapter_config .Release.IsInstall }}
- name: CONFIG_ADAPTER_B64
value: {{ .Values.config.adapter_config | b64enc | quote }}
{{- end }}
- name: CONFIG_CORE_ENV_B64
value: {{ tpl .Files.Get "files/.env" . | b64enc | quote }}
{{- if or .Values.config.override_core_bot_config .Release.IsInstall }}
- name: CONFIG_CORE_BOT_B64
value: {{ .Values.config.core_bot_config | b64enc | quote }}
{{- end }}
{{- if or .Values.config.override_core_model_config .Release.IsInstall }}
- name: CONFIG_CORE_MODEL_B64
value: {{ .Values.config.core_model_config | b64enc | quote }}
{{- end }}
volumeMounts:
- mountPath: /app/config/adapter/config.toml
name: adapter-config
subPath: config.toml
- mountPath: /app/config/core/.env
name: core-config
subPath: .env
- mountPath: /app/config/core/bot_config.toml
name: core-config
subPath: bot_config.toml
- mountPath: /app/config/core/model_config.toml
name: core-config
subPath: model_config.toml
imagePullSecrets:
{{ toYaml .Values.pre_processor.image.pullSecrets | nindent 8 }}
volumes:
- name: adapter-config
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-adapter-config
- name: core-config
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-core-config

View File

@@ -12,11 +12,14 @@ metadata:
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "create", "update", "patch"]
resources: ["configmaps", "pods"]
verbs: ["get", "list", "delete"]
- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["get", "list", "create", "update", "patch"]
verbs: ["get", "list", "update", "patch"]
- apiGroups: ["apps"]
resources: ["statefulsets/scale"]
verbs: ["get", "patch", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding