MaiBot/helm-chart/templates/core/statefulset.yaml

166 lines
5.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-maibot-core
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-core
spec:
serviceName: {{ .Release.Name }}-maibot-core
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}-maibot-core
template:
metadata:
labels:
app: {{ .Release.Name }}-maibot-core
spec:
containers:
- name: core
command: # 为了在k8s中初始化这里替换启动命令为指定脚本
- sh
args:
- /MaiMBot/k8s-init.sh
env:
- name: TZ
value: "Asia/Shanghai"
- name: EULA_AGREE
value: "99f08e0cab0190de853cb6af7d64d4de"
- name: PRIVACY_AGREE
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:
- containerPort: 8000
name: adapter-ws
protocol: TCP
{{- if .Values.core.webui.enabled }}
- containerPort: 8001
name: webui
protocol: TCP
{{- end }}
{{- if .Values.core.resources }}
resources:
{{ toYaml .Values.core.resources | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /MaiMBot/data
name: data
- mountPath: /MaiMBot/k8s-init.sh
name: scripts
readOnly: true
subPath: k8s-init.sh
- mountPath: /MaiMBot/.env
name: env-config
readOnly: true
subPath: .env
{{- if not .Values.core.webui.enabled }}
- mountPath: /MaiMBot/config/model_config.toml
name: model-config
readOnly: true
subPath: model_config.toml
- mountPath: /MaiMBot/config/bot_config.toml
name: bot-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: 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:
{{ toYaml .Values.core.image.pullSecrets | nindent 8 }}
{{- end }}
{{- if .Values.core.nodeSelector }}
nodeSelector:
{{ toYaml .Values.core.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.core.tolerations }}
tolerations:
{{ toYaml .Values.core.tolerations | nindent 8 }}
{{- end }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-core
- configMap:
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
- 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
{{- 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 }}