feat: 为helm chart添加WebUI的辅助容器,用于反向同步配置到ConfigMap

This commit is contained in:
zhangxinhui02
2025-11-21 01:38:50 +08:00
parent 14514ba837
commit 4f6e159000
13 changed files with 232 additions and 94 deletions

View File

@@ -18,17 +18,21 @@ spec:
spec:
containers:
- name: core
command: # 为了在k8s中初始化存储卷,这里替换启动命令为指定脚本
command: # 为了在k8s中初始化这里替换启动命令为指定脚本
- sh
args:
- /MaiMBot/volume-linker.sh
- /MaiMBot/k8s-init.sh
env:
- name: TZ
value: Asia/Shanghai
value: "Asia/Shanghai"
- name: EULA_AGREE
value: 99f08e0cab0190de853cb6af7d64d4de
value: "99f08e0cab0190de853cb6af7d64d4de"
- name: PRIVACY_AGREE
value: 9943b855e72199d0f5016ea39052f1b6
value: "9943b855e72199d0f5016ea39052f1b6"
{{- if .Values.core.webui.enabled }}
- name: MAIBOT_WEBUI_ENABLED
value: "true"
{{- end}}
image: {{ .Values.core.image.repository | default "sengokucola/maibot" }}:{{ .Values.core.image.tag | default "0.11.5-beta" }}
imagePullPolicy: {{ .Values.core.image.pullPolicy }}
ports:
@@ -47,14 +51,15 @@ spec:
volumeMounts:
- mountPath: /MaiMBot/data
name: data
- mountPath: /MaiMBot/volume-linker.sh
- mountPath: /MaiMBot/k8s-init.sh
name: scripts
readOnly: true
subPath: volume-linker.sh
subPath: k8s-init.sh
- mountPath: /MaiMBot/.env
name: config
readOnly: true
subPath: .env
{{- if not .Values.core.webui.enabled }}
- mountPath: /MaiMBot/config/model_config.toml
name: config
readOnly: true
@@ -63,10 +68,26 @@ spec:
name: config
readOnly: true
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: RELEASE_NAME
value: {{ .Release.Name }}
volumeMounts:
- mountPath: /MaiMBot/webui-cm-sync
name: webui-cm-sync
{{- end }}
{{- if .Values.core.setup_default_plugins }}
initContainers: # 用户插件目录存储在存储卷中,会在启动时覆盖掉容器的默认插件目录。此初始化容器用于默认插件更新后或麦麦首次启动时为用户自动安装默认插件到存储卷中
- args:
@@ -86,6 +107,7 @@ spec:
readOnly: true
subPath: setup-plugins.py
{{- end }}
serviceAccountName: {{ .Release.Name }}-maibot-sa
{{- if .Values.core.image.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.core.image.pullSecrets | nindent 8 }}
@@ -104,8 +126,8 @@ spec:
claimName: {{ .Release.Name }}-maibot-core
- configMap:
items:
- key: volume-linker.sh
path: volume-linker.sh
- key: k8s-init.sh
path: k8s-init.sh
{{- if .Values.core.setup_default_plugins }}
- key: setup-plugins.py
path: setup-plugins.py
@@ -127,3 +149,7 @@ spec:
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-statistics-dashboard
{{- end }}
{{- if .Values.core.webui.enabled }}
- emptyDir: {}
name: webui-cm-sync
{{- end }}

View File

@@ -5,8 +5,8 @@ metadata:
namespace: {{ .Release.Namespace }}
data:
# core
volume-linker.sh: |
{{ .Files.Get "files/volume-linker.sh" | nindent 4 }}
k8s-init.sh: |
{{ .Files.Get "files/k8s-init.sh" | nindent 4 }}
# core的初始化容器
{{- if .Values.core.setup_default_plugins }}
setup-plugins.py: |

View File

@@ -11,7 +11,7 @@ spec:
backoffLimit: 2
template:
spec:
serviceAccountName: {{ .Release.Name }}-maibot-adapter-cm-generator
serviceAccountName: {{ .Release.Name }}-maibot-sa
restartPolicy: Never
containers:
- name: adapter-cm-generator

View File

@@ -1,14 +1,14 @@
# 动态生成adapter配置文件的configmap所需要的rbac授权
# 初始化及反向修改ConfigMap所需要的rbac授权
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-maibot-adapter-cm-generator
name: {{ .Release.Name }}-maibot-sa
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Release.Name }}-maibot-adapter-cm-gen-role
name: {{ .Release.Name }}-maibot-role
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: [""]
@@ -21,13 +21,13 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-maibot-adapter-cm-gen-role-binding
name: {{ .Release.Name }}-maibot-rolebinding
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-maibot-adapter-cm-generator
name: {{ .Release.Name }}-maibot-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ .Release.Name }}-maibot-adapter-cm-gen-role
name: {{ .Release.Name }}-maibot-role
apiGroup: rbac.authorization.k8s.io