From a721ed7dddf09b4deaa7e142cf537e9884e5edfa Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:19:45 +0800 Subject: [PATCH 01/58] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Chart=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/Chart.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 helm-chart/Chart.yaml diff --git a/helm-chart/Chart.yaml b/helm-chart/Chart.yaml new file mode 100644 index 00000000..aaa8a215 --- /dev/null +++ b/helm-chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: maibot +description: "Maimai Bot, a cyber friend dedicated to group chats" +type: application +version: 0.10.0-alpha.0 +appVersion: 0.10.0-alpha \ No newline at end of file From 08d701b406960d1caac48e168584611d6dea33ff Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:20:29 +0800 Subject: [PATCH 02/58] =?UTF-8?q?=E8=AE=BE=E8=AE=A1values=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/values.yaml | 648 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 648 insertions(+) create mode 100644 helm-chart/values.yaml diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml new file mode 100644 index 00000000..689b27c1 --- /dev/null +++ b/helm-chart/values.yaml @@ -0,0 +1,648 @@ +# 麦麦Adapter的部署配置 +adapter: + + image: + repository: unclas/maimbot-adapter + tag: main-20250807151247 + pullPolicy: IfNotPresent + pullSecrets: [ ] + + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + + nodeSelector: {} + tolerations: [] + + # 配置adapter的napcat websocket service + # adapter会启动一个websocket服务端,用于与napcat通信 + # 这里的选项可以帮助你自定义服务端口 + # !!!默认不使用NodePort。如果通过NodePort将服务端口映射到公网可能会被恶意客户端连接,请自行使用中间件鉴权!!! + service: + type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的websocket端口映射到物理节点的端口 + port: 8095 # websocket监听端口ClusterIP的端口 + nodePort: # 仅在设置NodePort类型时有效,不指定则会随机分配端口 + + persistence: + storageClass: + accessModes: + - ReadWriteOnce + size: 1Gi + +# 麦麦本体的部署配置 +core: + + # 只有同意了EULA和PRIVACY协议才可以部署麦麦 + # 配置以下的选项为true表示你同意了EULA和PRIVACY条款 + # https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md + # https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md + EULA_AGREE: false + PRIVACY_AGREE: false + + image: + repository: sengokucola/maibot + tag: main-d919c34 + pullPolicy: IfNotPresent + pullSecrets: [ ] + + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + + nodeSelector: {} + tolerations: [] + + persistence: + storageClass: + accessModes: + - ReadWriteOnce + size: 10Gi + +# 麦麦的运行统计看板配置 +# 麦麦每隔一段时间会自动输出html格式的运行统计报告,此统计报告可以作为静态网页访问 +# 此功能默认禁用。如果你认为报告可以被公开访问(报告包含联系人/群组名称、模型token花费信息等),则可以启用此功能 +# 如果启用此功能,你也可以考虑使用中间件进行鉴权,保护隐私信息 +statistics_dashboard: + + enabled: false # 是否启用运行统计看板 + + replicaCount: 1 + + image: + repository: nginx + tag: latest + pullPolicy: IfNotPresent + pullSecrets: [ ] + + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + + nodeSelector: {} + tolerations: [] + + service: + type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的服务端口映射到物理节点的端口 + port: 80 # 服务端口 + nodePort: # 仅在设置NodePort类型时有效,不指定则会随机分配端口 + ingress: + enabled: false + className: nginx + annotations: { } + hosts: + - host: maim-statistics.example.com # 访问运行统计看板的域名 + paths: + - path: / + pathType: Prefix + + persistence: + storageClass: + # 如果你希望运行统计看板服务与麦麦本体运行在不同的节点(多活部署),那么需要ReadWriteMany访问模式 + # 注意:ReadWriteMany特性需要存储类底层支持 + accessModes: + - ReadWriteOnce + size: 100Mi + +# napcat的部署配置 +# !!!napcat部署完毕后,务必修改默认密码!!! +napcat: + + # 考虑到复用外部napcat实例的情况,napcat部署已被解耦 + # 如果你有外部部署的napcat,则可以修改下面的enabled为false,本次不会重复部署napcat + # 如果没有外部部署的napcat,默认会捆绑部署napcat,不需要修改此项 + enabled: true + + image: + repository: mlikiowa/napcat-docker + tag: v4.8.98 + pullPolicy: IfNotPresent + pullSecrets: [ ] + + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + + nodeSelector: {} + tolerations: [] + + # napcat进程的权限,默认不是特权用户 + permission: + uid: 1000 + gid: 1000 + + # 配置napcat web面板的service + service: + type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的服务端口映射到物理节点的端口 + port: 6099 # 服务端口 + nodePort: # 仅在设置NodePort类型时有效,不指定则会随机分配端口 + + # 配置napcat web面板的ingress + ingress: + enabled: false # 是否启用 + className: nginx + annotations: { } + hosts: + - host: napcat.example.com # 暴露napcat web面板使用的域名 + paths: + - path: / + pathType: Prefix + + persistence: + storageClass: + accessModes: + - ReadWriteOnce + size: 5Gi + +# sqlite-web的部署配置 +sqlite-web: + + # 通过sqlite-web可以在网页上操作麦麦的数据库,方便调试。不部署对麦麦的运行无影响 + # 默认不会捆绑部署sqlite-web,如果你需要部署,请修改下面的enabled为true + # !!!sqlite-web服务无鉴权,暴露在公网上十分危险,推荐使用集群ClusterIP内网访问!!! + # !!!如果一定要暴露在公网,请自行使用中间件鉴权!!! + enabled: false + + image: + repository: coleifer/sqlite-web + tag: latest + pullPolicy: IfNotPresent + pullSecrets: [ ] + + resources: + limits: + cpu: + memory: + requests: + cpu: + memory: + + # 配置sqlite-web面板的service + # !!!默认不使用NodePort。如果使用NodePort暴露到公网,请自行使用中间件鉴权!!! + service: + type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的服务端口映射到物理节点的端口 + port: 8080 # 服务端口 + nodePort: # 仅在设置NodePort类型时有效,不指定则会随机分配端口 + + # 配置sqlite-web面板的ingress + # !!!默认不使用ingress。如果使用ingress暴露到公网,请自行使用中间件鉴权!!! + ingress: + enabled: false # 是否启用 + className: nginx + annotations: { } + hosts: + - host: maim-sqlite.example.com # 暴露websocket使用的域名 + paths: + - path: / + pathType: Prefix + +# 麦麦各部分组件的运行配置文件 +config: + + # adapter的config.toml + adapter_config: | + [inner] + version = "0.1.1" # 版本号 + # 请勿修改版本号,除非你知道自己在做什么 + + [nickname] # 现在没用 + nickname = "" + + [napcat_server] # Napcat连接的ws服务设置 + host = "0.0.0.0" # Napcat设定的主机地址 + port = 8095 # Napcat设定的端口 + heartbeat_interval = 30 # 与Napcat设置的心跳相同(按秒计) + + [maibot_server] # 连接麦麦的ws服务设置 + host = "localhost" # 麦麦在.env文件中设置的主机地址,即HOST字段 + port = 8000 # 麦麦在.env文件中设置的端口,即PORT字段 + + [chat] # 黑白名单功能 + group_list_type = "whitelist" # 群组名单类型,可选为:whitelist, blacklist + group_list = [] # 群组名单 + # 当group_list_type为whitelist时,只有群组名单中的群组可以聊天 + # 当group_list_type为blacklist时,群组名单中的任何群组无法聊天 + private_list_type = "whitelist" # 私聊名单类型,可选为:whitelist, blacklist + private_list = [] # 私聊名单 + # 当private_list_type为whitelist时,只有私聊名单中的用户可以聊天 + # 当private_list_type为blacklist时,私聊名单中的任何用户无法聊天 + ban_user_id = [] # 全局禁止名单(全局禁止名单中的用户无法进行任何聊天) + ban_qq_bot = false # 是否屏蔽QQ官方机器人 + enable_poke = true # 是否启用戳一戳功能 + + [voice] # 发送语音设置 + use_tts = false # 是否使用tts语音(请确保你配置了tts并有对应的adapter) + + [debug] + level = "INFO" # 日志等级(DEBUG, INFO, WARNING, ERROR, CRITICAL) + + # core的model_config.toml + core_model_config: | + [inner] + version = "1.3.0" + + # 配置文件版本号迭代规则同bot_config.toml + + [[api_providers]] # API服务提供商(可以配置多个) + name = "DeepSeek" # API服务商名称(可随意命名,在models的api-provider中需使用这个命名) + base_url = "https://api.deepseek.cn/v1" # API服务商的BaseURL + api_key = "your-api-key-here" # API密钥(请替换为实际的API密钥) + client_type = "openai" # 请求客户端(可选,默认值为"openai",使用gimini等Google系模型时请配置为"gemini") + max_retry = 2 # 最大重试次数(单个模型API调用失败,最多重试的次数) + timeout = 30 # API请求超时时间(单位:秒) + retry_interval = 10 # 重试间隔时间(单位:秒) + + [[api_providers]] # SiliconFlow的API服务商配置 + name = "SiliconFlow" + base_url = "https://api.siliconflow.cn/v1" + api_key = "your-siliconflow-api-key" + client_type = "openai" + max_retry = 2 + timeout = 30 + retry_interval = 10 + + [[api_providers]] # 特殊:Google的Gimini使用特殊API,与OpenAI格式不兼容,需要配置client为"gemini" + name = "Google" + base_url = "https://api.google.com/v1" + api_key = "your-google-api-key-1" + client_type = "gemini" + max_retry = 2 + timeout = 30 + retry_interval = 10 + + + [[models]] # 模型(可以配置多个) + model_identifier = "deepseek-chat" # 模型标识符(API服务商提供的模型标识符) + name = "deepseek-v3" # 模型名称(可随意命名,在后面中需使用这个命名) + api_provider = "DeepSeek" # API服务商名称(对应在api_providers中配置的服务商名称) + price_in = 2.0 # 输入价格(用于API调用统计,单位:元/ M token)(可选,若无该字段,默认值为0) + price_out = 8.0 # 输出价格(用于API调用统计,单位:元/ M token)(可选,若无该字段,默认值为0) + #force_stream_mode = true # 强制流式输出模式(若模型不支持非流式输出,请取消该注释,启用强制流式输出,若无该字段,默认值为false) + + [[models]] + model_identifier = "Pro/deepseek-ai/DeepSeek-V3" + name = "siliconflow-deepseek-v3" + api_provider = "SiliconFlow" + price_in = 2.0 + price_out = 8.0 + + [[models]] + model_identifier = "Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B" + name = "deepseek-r1-distill-qwen-32b" + api_provider = "SiliconFlow" + price_in = 4.0 + price_out = 16.0 + + [[models]] + model_identifier = "Qwen/Qwen3-8B" + name = "qwen3-8b" + api_provider = "SiliconFlow" + price_in = 0 + price_out = 0 + [models.extra_params] # 可选的额外参数配置 + enable_thinking = false # 不启用思考 + + [[models]] + model_identifier = "Qwen/Qwen3-14B" + name = "qwen3-14b" + api_provider = "SiliconFlow" + price_in = 0.5 + price_out = 2.0 + [models.extra_params] # 可选的额外参数配置 + enable_thinking = false # 不启用思考 + + [[models]] + model_identifier = "Qwen/Qwen3-30B-A3B" + name = "qwen3-30b" + api_provider = "SiliconFlow" + price_in = 0.7 + price_out = 2.8 + [models.extra_params] # 可选的额外参数配置 + enable_thinking = false # 不启用思考 + + [[models]] + model_identifier = "Qwen/Qwen2.5-VL-72B-Instruct" + name = "qwen2.5-vl-72b" + api_provider = "SiliconFlow" + price_in = 4.13 + price_out = 4.13 + + [[models]] + model_identifier = "FunAudioLLM/SenseVoiceSmall" + name = "sensevoice-small" + api_provider = "SiliconFlow" + price_in = 0 + price_out = 0 + + [[models]] + model_identifier = "BAAI/bge-m3" + name = "bge-m3" + api_provider = "SiliconFlow" + price_in = 0 + price_out = 0 + + + [model_task_config.utils] # 在麦麦的一些组件中使用的模型,例如表情包模块,取名模块,关系模块,是麦麦必须的模型 + model_list = ["siliconflow-deepseek-v3"] # 使用的模型列表,每个子项对应上面的模型名称(name) + temperature = 0.2 # 模型温度,新V3建议0.1-0.3 + max_tokens = 800 # 最大输出token数 + + [model_task_config.utils_small] # 在麦麦的一些组件中使用的小模型,消耗量较大,建议使用速度较快的小模型 + model_list = ["qwen3-8b"] + temperature = 0.7 + max_tokens = 800 + + [model_task_config.replyer] # 首要回复模型,还用于表达器和表达方式学习 + model_list = ["siliconflow-deepseek-v3"] + temperature = 0.2 # 模型温度,新V3建议0.1-0.3 + max_tokens = 800 + + [model_task_config.planner] #决策:负责决定麦麦该做什么的模型 + model_list = ["siliconflow-deepseek-v3"] + temperature = 0.3 + max_tokens = 800 + + [model_task_config.emotion] #负责麦麦的情绪变化 + model_list = ["siliconflow-deepseek-v3"] + temperature = 0.3 + max_tokens = 800 + + [model_task_config.vlm] # 图像识别模型 + model_list = ["qwen2.5-vl-72b"] + max_tokens = 800 + + [model_task_config.voice] # 语音识别模型 + model_list = ["sensevoice-small"] + + [model_task_config.tool_use] #工具调用模型,需要使用支持工具调用的模型 + model_list = ["qwen3-14b"] + temperature = 0.7 + max_tokens = 800 + + #嵌入模型 + [model_task_config.embedding] + model_list = ["bge-m3"] + + #------------LPMM知识库模型------------ + + [model_task_config.lpmm_entity_extract] # 实体提取模型 + model_list = ["siliconflow-deepseek-v3"] + temperature = 0.2 + max_tokens = 800 + + [model_task_config.lpmm_rdf_build] # RDF构建模型 + model_list = ["siliconflow-deepseek-v3"] + temperature = 0.2 + max_tokens = 800 + + [model_task_config.lpmm_qa] # 问答模型 + model_list = ["deepseek-r1-distill-qwen-32b"] + temperature = 0.7 + max_tokens = 800 + + # core的bot_config.toml + core_bot_config: | + [inner] + version = "6.4.6" + + #----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- + #如果你想要修改配置文件,请递增version的值 + #如果新增项目,请阅读src/config/official_configs.py中的说明 + # + # 版本格式:主版本号.次版本号.修订号,版本号递增规则如下: + # 主版本号:MMC版本更新 + # 次版本号:配置文件内容大更新 + # 修订号:配置文件内容小更新 + #----以上是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- + + [bot] + platform = "qq" + qq_account = 1145141919810 # 麦麦的QQ账号 + nickname = "麦麦" # 麦麦的昵称 + alias_names = ["麦叠", "牢麦"] # 麦麦的别名 + + [personality] + # 建议50字以内,描述人格的核心特质 + personality_core = "是一个女孩子" + # 人格的细节,描述人格的一些侧面 + personality_side = "有时候说话不过脑子,喜欢开玩笑, 有时候会表现得无语,有时候会喜欢说一些奇怪的话" + #アイデンティティがない 生まれないらららら + # 可以描述外貌,性别,身高,职业,属性等等描述 + identity = "年龄为19岁,是女孩子,身高为160cm,有黑色的短发" + + # 描述麦麦说话的表达风格,表达习惯,如要修改,可以酌情新增内容 + reply_style = "回复可以简短一些。可以参考贴吧,知乎和微博的回复风格,回复不要浮夸,不要用夸张修辞,平淡一些。不要浮夸,不要夸张修辞。" + + compress_personality = false # 是否压缩人格,压缩后会精简人格信息,节省token消耗并提高回复性能,但是会丢失一些信息,如果人设不长,可以关闭 + compress_identity = true # 是否压缩身份,压缩后会精简身份信息,节省token消耗并提高回复性能,但是会丢失一些信息,如果不长,可以关闭 + + [expression] + # 表达学习配置 + learning_list = [ # 表达学习配置列表,支持按聊天流配置 + ["", "enable", "enable", "1.0"], # 全局配置:使用表达,启用学习,学习强度1.0 + ["qq:1919810:group", "enable", "enable", "1.5"], # 特定群聊配置:使用表达,启用学习,学习强度1.5 + ["qq:114514:private", "enable", "disable", "0.5"], # 特定私聊配置:使用表达,禁用学习,学习强度0.5 + # 格式说明: + # 第一位: chat_stream_id,空字符串表示全局配置 + # 第二位: 是否使用学到的表达 ("enable"/"disable") + # 第三位: 是否学习表达 ("enable"/"disable") + # 第四位: 学习强度(浮点数),影响学习频率,最短学习时间间隔 = 300/学习强度(秒) + # 学习强度越高,学习越频繁;学习强度越低,学习越少 + ] + + expression_groups = [ + ["qq:1919810:private","qq:114514:private","qq:1111111:group"], # 在这里设置互通组,相同组的chat_id会共享学习到的表达方式 + # 格式:["qq:123456:private","qq:654321:group"] + # 注意:如果为群聊,则需要设置为group,如果设置为私聊,则需要设置为private + ] + + + [chat] #麦麦的聊天设置 + talk_frequency = 0.5 + # 麦麦活跃度,越高,麦麦回复越多,范围0-1 + focus_value = 0.5 + # 麦麦的专注度,越高越容易持续连续对话,可能消耗更多token, 范围0-1 + + max_context_size = 20 # 上下文长度 + + mentioned_bot_inevitable_reply = true # 提及 bot 大概率回复 + at_bot_inevitable_reply = true # @bot 或 提及bot 大概率回复 + + focus_value_adjust = [ + ["", "8:00,1", "12:00,0.8", "18:00,1", "01:00,0.3"], + ["qq:114514:group", "12:20,0.6", "16:10,0.5", "20:10,0.8", "00:10,0.3"], + ["qq:1919810:private", "8:20,0.5", "12:10,0.8", "20:10,1", "00:10,0.2"] + ] + + talk_frequency_adjust = [ + ["", "8:00,0.5", "12:00,0.6", "18:00,0.8", "01:00,0.3"], + ["qq:114514:group", "12:20,0.3", "16:10,0.5", "20:10,0.4", "00:10,0.1"], + ["qq:1919810:private", "8:20,0.3", "12:10,0.4", "20:10,0.5", "00:10,0.1"] + ] + # 基于聊天流的个性化活跃度和专注度配置 + # 格式:[["platform:chat_id:type", "HH:MM,frequency", "HH:MM,frequency", ...], ...] + + # 全局配置示例: + # [["", "8:00,1", "12:00,2", "18:00,1.5", "00:00,0.5"]] + + # 特定聊天流配置示例: + # [ + # ["", "8:00,1", "12:00,1.2", "18:00,1.5", "01:00,0.6"], # 全局默认配置 + # ["qq:1026294844:group", "12:20,1", "16:10,2", "20:10,1", "00:10,0.3"], # 特定群聊配置 + # ["qq:729957033:private", "8:20,1", "12:10,2", "20:10,1.5", "00:10,0.2"] # 特定私聊配置 + # ] + + # 说明: + # - 当第一个元素为空字符串""时,表示全局默认配置 + # - 当第一个元素为"platform:id:type"格式时,表示特定聊天流配置 + # - 后续元素是"时间,频率"格式,表示从该时间开始使用该活跃度,直到下一个时间点 + # - 优先级:特定聊天流配置 > 全局配置 > 默认 talk_frequency + + + [relationship] + enable_relationship = true # 是否启用关系系统 + relation_frequency = 1 # 关系频率,麦麦构建关系的频率 + + [message_receive] + # 以下是消息过滤,可以根据规则过滤特定消息,将不会读取这些消息 + ban_words = [ + # "403","张三" + ] + + ban_msgs_regex = [ + # 需要过滤的消息(原始消息)匹配的正则表达式,匹配到的消息将被过滤,若不了解正则表达式请勿修改 + #"https?://[^\\s]+", # 匹配https链接 + #"\\d{4}-\\d{2}-\\d{2}", # 匹配日期 + ] + + [tool] + enable_tool = false # 是否在普通聊天中启用工具 + + [mood] + enable_mood = true # 是否启用情绪系统 + mood_update_threshold = 1 # 情绪更新阈值,越高,更新越慢 + + [emoji] + emoji_chance = 0.6 # 麦麦激活表情包动作的概率 + + max_reg_num = 60 # 表情包最大注册数量 + do_replace = true # 开启则在达到最大数量时删除(替换)表情包,关闭则达到最大数量时不会继续收集表情包 + check_interval = 10 # 检查表情包(注册,破损,删除)的时间间隔(分钟) + steal_emoji = true # 是否偷取表情包,让麦麦可以将一些表情包据为己有 + content_filtration = false # 是否启用表情包过滤,只有符合该要求的表情包才会被保存 + filtration_prompt = "符合公序良俗" # 表情包过滤要求,只有符合该要求的表情包才会被保存 + + [memory] + enable_memory = true # 是否启用记忆系统 + memory_build_frequency = 1 # 记忆构建频率 越高,麦麦学习越多 + memory_compress_rate = 0.1 # 记忆压缩率 控制记忆精简程度 建议保持默认,调高可以获得更多信息,但是冗余信息也会增多 + + forget_memory_interval = 3000 # 记忆遗忘间隔 单位秒 间隔越低,麦麦遗忘越频繁,记忆更精简,但更难学习 + memory_forget_time = 48 #多长时间后的记忆会被遗忘 单位小时 + memory_forget_percentage = 0.008 # 记忆遗忘比例 控制记忆遗忘程度 越大遗忘越多 建议保持默认 + + enable_instant_memory = false # 是否启用即时记忆,测试功能,可能存在未知问题 + + #不希望记忆的词,已经记忆的不会受到影响,需要手动清理 + memory_ban_words = [ "表情包", "图片", "回复", "聊天记录" ] + + [voice] + enable_asr = false # 是否启用语音识别,启用后麦麦可以识别语音消息,启用该功能需要配置语音识别模型[model.voice]s + + [lpmm_knowledge] # lpmm知识库配置 + enable = false # 是否启用lpmm知识库 + rag_synonym_search_top_k = 10 # 同义词搜索TopK + rag_synonym_threshold = 0.8 # 同义词阈值(相似度高于此阈值的词语会被认为是同义词) + info_extraction_workers = 3 # 实体提取同时执行线程数,非Pro模型不要设置超过5 + qa_relation_search_top_k = 10 # 关系搜索TopK + qa_relation_threshold = 0.5 # 关系阈值(相似度高于此阈值的关系会被认为是相关的关系) + qa_paragraph_search_top_k = 1000 # 段落搜索TopK(不能过小,可能影响搜索结果) + qa_paragraph_node_weight = 0.05 # 段落节点权重(在图搜索&PPR计算中的权重,当搜索仅使用DPR时,此参数不起作用) + qa_ent_filter_top_k = 10 # 实体过滤TopK + qa_ppr_damping = 0.8 # PPR阻尼系数 + qa_res_top_k = 3 # 最终提供的文段TopK + embedding_dimension = 1024 # 嵌入向量维度,应该与模型的输出维度一致 + + # keyword_rules 用于设置关键词触发的额外回复知识 + # 添加新规则方法:在 keyword_rules 数组中增加一项,格式如下: + # { keywords = ["关键词1", "关键词2"], reaction = "触发这些关键词时的回复内容" } + # 例如,添加一个新规则:当检测到“你好”或“hello”时回复“你好,有什么可以帮你?” + # { keywords = ["你好", "hello"], reaction = "你好,有什么可以帮你?" } + [keyword_reaction] + keyword_rules = [ + { keywords = ["人机", "bot", "机器", "入机", "robot", "机器人", "ai", "AI"], reaction = "有人说你是人机或者机器人,否定这一事实,攻击或反问他。注意,只有认为你是机器人才回复,否则不要否认" }, + { keywords = ["测试关键词回复", "test"], reaction = "回答测试成功" }, + #{ keywords = ["你好", "hello"], reaction = "你好,有什么可以帮你?" } + # 在此处添加更多规则,格式同上 + ] + + regex_rules = [ + { regex = ["^(?P\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" } + ] + + # 可以自定义部分提示词 + [custom_prompt] + image_prompt = "请用中文描述这张图片的内容。如果有文字,请把文字描述概括出来,请留意其主题,直观感受,输出为一段平文本,最多30字,请注意不要分点,就输出一段文本" + + [response_post_process] + enable_response_post_process = true # 是否启用回复后处理,包括错别字生成器,回复分割器 + + [chinese_typo] + enable = true # 是否启用中文错别字生成器 + error_rate=0.01 # 单字替换概率 + min_freq=9 # 最小字频阈值 + tone_error_rate=0.1 # 声调错误概率 + word_replace_rate=0.006 # 整词替换概率 + + [response_splitter] + enable = true # 是否启用回复分割器 + max_length = 512 # 回复允许的最大长度 + max_sentence_num = 8 # 回复允许的最大句子数 + enable_kaomoji_protection = false # 是否启用颜文字保护 + + [log] + date_style = "m-d H:i:s" # 日期格式 + log_level_style = "lite" # 日志级别样式,可选FULL,compact,lite + color_text = "full" # 日志文本颜色,可选none,title,full + log_level = "INFO" # 全局日志级别(向下兼容,优先级低于下面的分别设置) + console_log_level = "INFO" # 控制台日志级别,可选: DEBUG, INFO, WARNING, ERROR, CRITICAL + file_log_level = "DEBUG" # 文件日志级别,可选: DEBUG, INFO, WARNING, ERROR, CRITICAL + + # 第三方库日志控制 + suppress_libraries = ["faiss","httpx", "urllib3", "asyncio", "websockets", "httpcore", "requests", "peewee", "openai","uvicorn","jieba"] # 完全屏蔽的库 + library_log_levels = { "aiohttp" = "WARNING"} # 设置特定库的日志级别 + + [debug] + show_prompt = false # 是否显示prompt + + [maim_message] + auth_token = [] # 认证令牌,用于API验证,为空则不启用验证 + # 以下项目若要使用需要打开use_custom,并单独配置maim_message的服务器 + use_custom = false # 是否启用自定义的maim_message服务器,注意这需要设置新的端口,不能与.env重复 + host="127.0.0.1" + port=8090 + mode="ws" # 支持ws和tcp两种模式 + use_wss = false # 是否使用WSS安全连接,只支持ws模式 + cert_file = "" # SSL证书文件路径,仅在use_wss=true时有效 + key_file = "" # SSL密钥文件路径,仅在use_wss=true时有效 + + [telemetry] #发送统计信息,主要是看全球有多少只麦麦 + enable = true + + [experimental] #实验性功能 + enable_friend_chat = false # 是否启用好友聊天 From ad11f42d3dae493bf949c38c79a35cf090fa4c32 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:24:40 +0800 Subject: [PATCH 03/58] =?UTF-8?q?=E7=BC=96=E5=86=99volume-linker.sh?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E8=A6=86=E7=9B=96core=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E7=9A=84=E9=BB=98=E8=AE=A4=E5=90=AF=E5=8A=A8=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=20=E7=94=B1=E4=BA=8Ek8s=E4=B8=8Edocker-compose=E7=9A=84?= =?UTF-8?q?=E5=8D=B7=E6=8C=82=E8=BD=BD=E6=96=B9=E5=BC=8F=E6=9C=89=E6=89=80?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=EF=BC=8C=E9=9C=80=E8=A6=81=E5=88=A9=E7=94=A8?= =?UTF-8?q?=E6=AD=A4=E8=84=9A=E6=9C=AC=E4=B8=BA=E4=B8=80=E4=BA=9B=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=92=8C=E7=9B=AE=E5=BD=95=E6=8F=90=E5=89=8D=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=A5=BD=E8=BD=AF=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/files/volume-linker.sh | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 helm-chart/files/volume-linker.sh diff --git a/helm-chart/files/volume-linker.sh b/helm-chart/files/volume-linker.sh new file mode 100644 index 00000000..944a6e1e --- /dev/null +++ b/helm-chart/files/volume-linker.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# 此脚本用于覆盖core容器的默认启动命令 +# 由于k8s与docker-compose的卷挂载方式有所不同,需要利用此脚本为一些文件和目录提前创建好软链接 +# /MaiMBot/data是麦麦数据的实际挂载路径 +# /MaiMBot/statistics是统计数据的实际挂载路径 + +set -e +echo "[VolumeLinker]Preparing volume..." + +# 初次启动,在存储卷中检查并创建关键文件和目录 +if [ -d /MaiMBot/data/plugins ] +then + echo "[VolumeLinker] '/MaiMBot/data/plugins' exists." +else + mkdir /MaiMBot/data/plugins +fi +if [ -d /MaiMBot/data/logs ] +then + echo "[VolumeLinker] '/MaiMBot/data/logs' exists." +else + mkdir /MaiMBot/data/logs +fi +if [ -f /MaiMBot/statistics/index.html ] +then + echo "[VolumeLinker] '/MaiMBot/statistics/index.html' exists." +else + touch /MaiMBot/statistics/index.html +fi + +# 删除空的插件目录,准备创建软链接 +rm -rf /MaiMBot/plugins + +# 创建软链接,从存储卷链接到实际位置 +ln -s /MaiMBot/data/plugins /MaiMBot/plugins +ln -s /MaiMBot/data/logs /MaiMBot/logs +ln -s /MaiMBot/statistics/index.html /MaiMBot/maibot_statistics.html + +# 启动麦麦 +echo "[VolumeLinker]Starting MaiBot..." +python bot.py From dd52b3fff5aebb9bd3353b81eaf5269900d2ed3e Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:42:41 +0800 Subject: [PATCH 04/58] =?UTF-8?q?=E7=BC=96=E5=86=99core=E7=9A=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9A=84configmap=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-configmap.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 helm-chart/templates/core-configmap.yaml diff --git a/helm-chart/templates/core-configmap.yaml b/helm-chart/templates/core-configmap.yaml new file mode 100644 index 00000000..8dd24154 --- /dev/null +++ b/helm-chart/templates/core-configmap.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-maibot-core + namespace: {{ .Release.Namespace }} +data: + .env: | + HOST=0.0.0.0 + PORT=8000 + model_config: | + {{ .Values.config.core_model_config | indent 4 }} + bot_config.toml: | + {{ .Values.config.core_bot_config | indent 4 }} From 3b3dbf577762b3d3ec7949adef0c19080d5d30e2 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:45:27 +0800 Subject: [PATCH 05/58] =?UTF-8?q?=E7=BC=96=E5=86=99core=E7=9A=84=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=84=9A=E6=9C=AC=E7=9A=84configmap=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-scripts-configmap.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 helm-chart/templates/core-scripts-configmap.yaml diff --git a/helm-chart/templates/core-scripts-configmap.yaml b/helm-chart/templates/core-scripts-configmap.yaml new file mode 100644 index 00000000..57394122 --- /dev/null +++ b/helm-chart/templates/core-scripts-configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-maibot-core-scripts + namespace: {{ .Release.Namespace }} +data: + volume-linker.sh: | + {{ .Files.Get "files/volume-linker.sh" | indent 4 }} From c4cc642f7594c1c7b033a32fe45841134008c777 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:47:48 +0800 Subject: [PATCH 06/58] =?UTF-8?q?=E7=BC=96=E5=86=99core=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84pvc=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-pvc.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 helm-chart/templates/core-pvc.yaml diff --git a/helm-chart/templates/core-pvc.yaml b/helm-chart/templates/core-pvc.yaml new file mode 100644 index 00000000..3c7508cd --- /dev/null +++ b/helm-chart/templates/core-pvc.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-maibot-core + namespace: {{ .Release.Namespace }} +spec: + accessModes: {{ .Values.core.persistence.accessModes }} + resources: + requests: + storage: {{ .Values.core.persistence.size }} + storageClassName: {{ .Values.core.persistence.storageClass | default nil }} From 7dea93052ca4d1f4ee65039010a40f54f7a3b5fc Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:50:48 +0800 Subject: [PATCH 07/58] =?UTF-8?q?=E7=BC=96=E5=86=99core=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E4=BA=8Eadapter=E8=BF=9E=E6=8E=A5=E7=9A=84service=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-service.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 helm-chart/templates/core-service.yaml diff --git a/helm-chart/templates/core-service.yaml b/helm-chart/templates/core-service.yaml new file mode 100644 index 00000000..47c32332 --- /dev/null +++ b/helm-chart/templates/core-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-maibot-core + namespace: {{ .Release.Namespace }} +spec: + ports: + - name: adapter-ws + port: 8000 + protocol: TCP + targetPort: 8000 + selector: + app: {{ .Release.Name }}-maibot-core + type: ClusterIP From 6a047e02058426e8de531a38e06f2ae86bbb3803 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:53:14 +0800 Subject: [PATCH 08/58] =?UTF-8?q?=E7=BC=96=E5=86=99=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E5=89=8D=E6=A3=80=E6=9F=A5=E9=A1=B9=EF=BC=88EULA=E5=92=8CPOLIC?= =?UTF-8?q?Y=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/pre-check.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 helm-chart/templates/pre-check.yaml diff --git a/helm-chart/templates/pre-check.yaml b/helm-chart/templates/pre-check.yaml new file mode 100644 index 00000000..2455fd54 --- /dev/null +++ b/helm-chart/templates/pre-check.yaml @@ -0,0 +1,8 @@ +# 检查EULA和PRIVACY +{{- if not .Values.core.EULA_AGREE }} +{{- fail "You must accept the EULA by setting 'core.EULA_AGREE: true'. EULA: https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md" }} +{{- end }} + +{{- if not .Values.core.PRIVACY_AGREE }} +{{- fail "You must accept the Privacy Policy by setting 'core.PRIVACY_AGREE: true'. Privacy Policy: https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md" }} +{{- end }} From 39b5d532e152e100e0dac6c78689bc25cefa6137 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:01:07 +0800 Subject: [PATCH 09/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84configmap=E9=94=AE=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/templates/core-configmap.yaml b/helm-chart/templates/core-configmap.yaml index 8dd24154..a37e0425 100644 --- a/helm-chart/templates/core-configmap.yaml +++ b/helm-chart/templates/core-configmap.yaml @@ -7,7 +7,7 @@ data: .env: | HOST=0.0.0.0 PORT=8000 - model_config: | + model_config.toml: | {{ .Values.config.core_model_config | indent 4 }} bot_config.toml: | {{ .Values.config.core_bot_config | indent 4 }} From 1b8e11995c7e11481d20835792489487cd181533 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:02:27 +0800 Subject: [PATCH 10/58] =?UTF-8?q?=E7=BC=96=E5=86=99core=E7=9A=84StatefulSe?= =?UTF-8?q?t=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-statefulset.yaml | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 helm-chart/templates/core-statefulset.yaml diff --git a/helm-chart/templates/core-statefulset.yaml b/helm-chart/templates/core-statefulset.yaml new file mode 100644 index 00000000..87472361 --- /dev/null +++ b/helm-chart/templates/core-statefulset.yaml @@ -0,0 +1,88 @@ +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/volume-linker.sh + env: + - name: TZ + value: Asia/Shanghai + - name: EULA_AGREE + value: 99f08e0cab0190de853cb6af7d64d4de + - name: PRIVACY_AGREE + value: 9943b855e72199d0f5016ea39052f1b6 + image: {{ .Values.core.image.repository }}:{{ .Values.core.image.tag }} + imagePullPolicy: {{ .Values.core.image.pullPolicy }} + ports: + - containerPort: 8000 + name: adapter-ws + protocol: TCP + resources: {{ .Values.core.resources }} + volumeMounts: + - mountPath: /MaiMBot/data + name: data + - mountPath: /MaiMBot/volume-linker.sh + name: scripts + readOnly: true + subPath: volume-linker.sh + - mountPath: /MaiMBot/.env + name: config + readOnly: true + subPath: .env + - mountPath: /MaiMBot/config/model_config.toml + name: config + readOnly: true + subPath: model_config.toml + - mountPath: /MaiMBot/config/bot_config.toml + name: config + readOnly: true + subPath: bot_config.toml + {{- if .Values.statistics_dashboard.enabled }} + - mountPath: /MaiMBot/statistics + name: statistics + {{- end }} + imagePullSecrets: {{ .Values.core.image.pullSecrets }} + nodeSelector: {{ .Values.core.nodeSelector }} + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-maibot-core + - configMap: + items: + - key: volume-linker.sh + path: volume-linker.sh + name: {{ .Release.Name }}-maibot-core-scripts + name: scripts + - configMap: + items: + - key: .env + path: .env + - key: model_config.toml + path: model_config.toml + - key: bot_config.toml + path: bot_config.toml + name: {{ .Release.Name }}-maibot-core + name: config + {{- if .Values.statistics_dashboard.enabled }} + - name: statistics + persistentVolumeClaim: + claimName: {{ .Release.Name }}-maibot-statistics + {{- end }} From ae7eab0aa87509b46570cfaf15fdb59ff3c87edc Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:04:05 +0800 Subject: [PATCH 11/58] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E5=AE=8C=E6=AF=95=E7=9A=84=E5=B8=AE=E5=8A=A9=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/NOTES.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 helm-chart/templates/NOTES.txt diff --git a/helm-chart/templates/NOTES.txt b/helm-chart/templates/NOTES.txt new file mode 100644 index 00000000..d898adf3 --- /dev/null +++ b/helm-chart/templates/NOTES.txt @@ -0,0 +1,3 @@ +MaiBot has been successfully deployed. + +MaiBot on GitHub: https://github.com/MaiM-with-u/MaiBot From 8b315fcfa2753130006e093354a4cdc04e0e66b9 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:06:20 +0800 Subject: [PATCH 12/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9EULA=E5=92=8CPrivacy=20?= =?UTF-8?q?Policy=E7=9A=84=E5=90=AF=E7=94=A8=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/pre-check.yaml | 8 ++++---- helm-chart/values.yaml | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/helm-chart/templates/pre-check.yaml b/helm-chart/templates/pre-check.yaml index 2455fd54..18b0cca2 100644 --- a/helm-chart/templates/pre-check.yaml +++ b/helm-chart/templates/pre-check.yaml @@ -1,8 +1,8 @@ # 检查EULA和PRIVACY -{{- if not .Values.core.EULA_AGREE }} -{{- fail "You must accept the EULA by setting 'core.EULA_AGREE: true'. EULA: https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md" }} +{{- 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" }} {{- end }} -{{- if not .Values.core.PRIVACY_AGREE }} -{{- fail "You must accept the Privacy Policy by setting 'core.PRIVACY_AGREE: true'. Privacy Policy: https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md" }} +{{- 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" }} {{- end }} diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index 689b27c1..304329e2 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -1,3 +1,10 @@ +# 只有同意了EULA和PRIVACY协议才可以部署麦麦 +# 配置以下的选项为true表示你同意了EULA和PRIVACY条款 +# https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md +# https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md +EULA_AGREE: false +PRIVACY_AGREE: false + # 麦麦Adapter的部署配置 adapter: @@ -36,13 +43,6 @@ adapter: # 麦麦本体的部署配置 core: - # 只有同意了EULA和PRIVACY协议才可以部署麦麦 - # 配置以下的选项为true表示你同意了EULA和PRIVACY条款 - # https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md - # https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md - EULA_AGREE: false - PRIVACY_AGREE: false - image: repository: sengokucola/maibot tag: main-d919c34 From 65110d597ab5e6fc6c895568809173dcc0640735 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:16:57 +0800 Subject: [PATCH 13/58] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E9=81=97?= =?UTF-8?q?=E6=BC=8F=E7=9A=84=E5=AE=B9=E5=BF=8D=E5=BA=A6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-statefulset.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/helm-chart/templates/core-statefulset.yaml b/helm-chart/templates/core-statefulset.yaml index 87472361..d6717a5b 100644 --- a/helm-chart/templates/core-statefulset.yaml +++ b/helm-chart/templates/core-statefulset.yaml @@ -61,6 +61,7 @@ spec: {{- end }} imagePullSecrets: {{ .Values.core.image.pullSecrets }} nodeSelector: {{ .Values.core.nodeSelector }} + tolerations: {{ .Values.core.tolerations }} volumes: - name: data persistentVolumeClaim: From 1d795b4006da7cb65333bdba9810b15131f68172 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:25:01 +0800 Subject: [PATCH 14/58] =?UTF-8?q?=E7=BC=96=E5=86=99adapter=E7=9A=84?= =?UTF-8?q?=E6=B8=85=E5=8D=95=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-configmap.yaml | 8 +++ helm-chart/templates/adapter-pvc-yaml | 11 ++++ helm-chart/templates/adapter-service.yaml | 17 +++++++ helm-chart/templates/adapter-statefulset.yaml | 50 +++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 helm-chart/templates/adapter-configmap.yaml create mode 100644 helm-chart/templates/adapter-pvc-yaml create mode 100644 helm-chart/templates/adapter-service.yaml create mode 100644 helm-chart/templates/adapter-statefulset.yaml diff --git a/helm-chart/templates/adapter-configmap.yaml b/helm-chart/templates/adapter-configmap.yaml new file mode 100644 index 00000000..6b4c80cc --- /dev/null +++ b/helm-chart/templates/adapter-configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-maibot-adapter + namespace: {{ .Release.Namespace }} +data: + config.toml: | + {{ .Values.config.adapter_config | indent 4 }} diff --git a/helm-chart/templates/adapter-pvc-yaml b/helm-chart/templates/adapter-pvc-yaml new file mode 100644 index 00000000..288ca9b3 --- /dev/null +++ b/helm-chart/templates/adapter-pvc-yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-maibot-adapter + namespace: {{ .Release.Namespace }} +spec: + accessModes: {{ .Values.adapter.persistence.accessModes }} + resources: + requests: + storage: {{ .Values.adapter.persistence.size }} + storageClassName: {{ .Values.adapter.persistence.storageClass | default nil }} diff --git a/helm-chart/templates/adapter-service.yaml b/helm-chart/templates/adapter-service.yaml new file mode 100644 index 00000000..1b019912 --- /dev/null +++ b/helm-chart/templates/adapter-service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-maibot-adapter + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-adapter +spec: + ports: + - name: napcat-ws + port: {{ .Values.adapter.service.port }} + protocol: TCP + targetPort: {{ .Values.adapter.service.port }} + nodePort: {{ .Values.adapter.service.nodePort }} + selector: + app: {{ .Release.Name }}-maibot-adapter + type: {{ .Values.adapter.service.type }} diff --git a/helm-chart/templates/adapter-statefulset.yaml b/helm-chart/templates/adapter-statefulset.yaml new file mode 100644 index 00000000..836c3f5a --- /dev/null +++ b/helm-chart/templates/adapter-statefulset.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Release.Name }}-maibot-adapter + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-adapter +spec: + serviceName: {{ .Release.Name }}-maibot-adapter + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-maibot-adapter + template: + metadata: + labels: + app: {{ .Release.Name }}-maibot-adapter + spec: + containers: + - name: adapter + env: + - name: TZ + value: Asia/Shanghai + image: {{ .Values.adapter.image.repository }}:{{ .Values.adapter.image.tag }} + imagePullPolicy: {{ .Values.adapter.image.pullPolicy }} + ports: + - containerPort: {{ .Values.adapter.service.port }} + name: napcat-ws + protocol: TCP + resources: {{ .Values.adapter.resources }} + volumeMounts: + - mountPath: /adapters/data + name: data + - mountPath: /adapters/config.toml + name: config + readOnly: true + subPath: config.toml + imagePullSecrets: {{ .Values.adapter.image.pullSecrets }} + nodeSelector: {{ .Values.adapter.nodeSelector }} + tolerations: {{ .Values.adapter.tolerations }} + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-maibot-adapter + - configMap: + items: + - key: config.toml + path: config.toml + name: {{ .Release.Name }}-maibot-adapter + name: config From 8e12b7ca010fcde9ee5e20bce397f58448c4c319 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:31:23 +0800 Subject: [PATCH 15/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3core=E7=9A=84ser?= =?UTF-8?q?vice=E6=9C=AA=E8=AE=BE=E7=BD=AE=E6=A0=87=E7=AD=BE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-service.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helm-chart/templates/core-service.yaml b/helm-chart/templates/core-service.yaml index 47c32332..c236e746 100644 --- a/helm-chart/templates/core-service.yaml +++ b/helm-chart/templates/core-service.yaml @@ -3,6 +3,8 @@ kind: Service metadata: name: {{ .Release.Name }}-maibot-core namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-core spec: ports: - name: adapter-ws From 6297b6bffb56b69d915be19b6bb7f88076b77341 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:39:20 +0800 Subject: [PATCH 16/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9values=E4=B8=AD?= =?UTF-8?q?=E7=9A=84ingress=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/values.yaml | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index 304329e2..bbb3e467 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -101,11 +101,9 @@ statistics_dashboard: enabled: false className: nginx annotations: { } - hosts: - - host: maim-statistics.example.com # 访问运行统计看板的域名 - paths: - - path: / - pathType: Prefix + host: maim-statistics.example.com # 访问运行统计看板的域名 + path: / + pathType: Prefix persistence: storageClass: @@ -157,11 +155,9 @@ napcat: enabled: false # 是否启用 className: nginx annotations: { } - hosts: - - host: napcat.example.com # 暴露napcat web面板使用的域名 - paths: - - path: / - pathType: Prefix + host: napcat.example.com # 暴露napcat web面板使用的域名 + path: / + pathType: Prefix persistence: storageClass: @@ -205,11 +201,9 @@ sqlite-web: enabled: false # 是否启用 className: nginx annotations: { } - hosts: - - host: maim-sqlite.example.com # 暴露websocket使用的域名 - paths: - - path: / - pathType: Prefix + host: maim-sqlite.example.com # 暴露websocket使用的域名 + path: / + pathType: Prefix # 麦麦各部分组件的运行配置文件 config: From 5fd0277b6f62631b3f78ff5a2baec5ed0a14816d Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:47:06 +0800 Subject: [PATCH 17/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/{adapter-pvc-yaml => adapter-pvc.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename helm-chart/templates/{adapter-pvc-yaml => adapter-pvc.yaml} (100%) diff --git a/helm-chart/templates/adapter-pvc-yaml b/helm-chart/templates/adapter-pvc.yaml similarity index 100% rename from helm-chart/templates/adapter-pvc-yaml rename to helm-chart/templates/adapter-pvc.yaml From 2540388df5467d035addc4eb697422e8a50b8456 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 23:55:29 +0800 Subject: [PATCH 18/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3adapter=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E7=AB=AF=E5=8F=A3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-service.yaml | 2 +- helm-chart/templates/adapter-statefulset.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/helm-chart/templates/adapter-service.yaml b/helm-chart/templates/adapter-service.yaml index 1b019912..5db4a3b2 100644 --- a/helm-chart/templates/adapter-service.yaml +++ b/helm-chart/templates/adapter-service.yaml @@ -10,7 +10,7 @@ spec: - name: napcat-ws port: {{ .Values.adapter.service.port }} protocol: TCP - targetPort: {{ .Values.adapter.service.port }} + targetPort: 8095 nodePort: {{ .Values.adapter.service.nodePort }} selector: app: {{ .Release.Name }}-maibot-adapter diff --git a/helm-chart/templates/adapter-statefulset.yaml b/helm-chart/templates/adapter-statefulset.yaml index 836c3f5a..7d6df8b4 100644 --- a/helm-chart/templates/adapter-statefulset.yaml +++ b/helm-chart/templates/adapter-statefulset.yaml @@ -24,7 +24,7 @@ spec: image: {{ .Values.adapter.image.repository }}:{{ .Values.adapter.image.tag }} imagePullPolicy: {{ .Values.adapter.image.pullPolicy }} ports: - - containerPort: {{ .Values.adapter.service.port }} + - containerPort: 8095 name: napcat-ws protocol: TCP resources: {{ .Values.adapter.resources }} From 15e6bac7e41747be2dd9d4e546b25a3bf3ba9603 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 00:00:03 +0800 Subject: [PATCH 19/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3adapter=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E7=AB=AF=E5=8F=A3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-service.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helm-chart/templates/adapter-service.yaml b/helm-chart/templates/adapter-service.yaml index 5db4a3b2..af306103 100644 --- a/helm-chart/templates/adapter-service.yaml +++ b/helm-chart/templates/adapter-service.yaml @@ -11,7 +11,9 @@ spec: port: {{ .Values.adapter.service.port }} protocol: TCP targetPort: 8095 + {{- if eq .Values.adapter.service.type "nodePort" }} nodePort: {{ .Values.adapter.service.nodePort }} + {{- end }} selector: app: {{ .Release.Name }}-maibot-adapter type: {{ .Values.adapter.service.type }} From 65f0515e80ccd139f392cf8fb4e11a4ec8dbfcd9 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 00:00:56 +0800 Subject: [PATCH 20/58] =?UTF-8?q?=E7=BC=96=E5=86=99statistics-dashboard?= =?UTF-8?q?=E7=9A=84=E6=B8=85=E5=8D=95=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/statistics-deployment.yaml | 49 +++++++++++++++++++ helm-chart/templates/statistics-ingress.yaml | 23 +++++++++ helm-chart/templates/statistics-pvc.yaml | 13 +++++ helm-chart/templates/statistics-service.yaml | 21 ++++++++ 4 files changed, 106 insertions(+) create mode 100644 helm-chart/templates/statistics-deployment.yaml create mode 100644 helm-chart/templates/statistics-ingress.yaml create mode 100644 helm-chart/templates/statistics-pvc.yaml create mode 100644 helm-chart/templates/statistics-service.yaml diff --git a/helm-chart/templates/statistics-deployment.yaml b/helm-chart/templates/statistics-deployment.yaml new file mode 100644 index 00000000..808257b6 --- /dev/null +++ b/helm-chart/templates/statistics-deployment.yaml @@ -0,0 +1,49 @@ +{{- if .Values.statistics_dashboard.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-maibot-statistics-dashboard + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-statistics-dashboard +spec: + replicas: {{ .Values.statistics_dashboard.replicaCount }} + selector: + matchLabels: + app: {{ .Release.Name }}-maibot-statistics-dashboard + template: + metadata: + labels: + app: {{ .Release.Name }}-maibot-statistics-dashboard + spec: + containers: + - name: nginx + image: {{ .Values.statistics_dashboard.image.repository }}:{{ .Values.statistics_dashboard.image.tag }} + imagePullPolicy: {{ .Values.statistics_dashboard.image.pullPolicy }} + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 80 + scheme: HTTP + initialDelaySeconds: 60 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + ports: + - containerPort: 80 + name: dashboard + protocol: TCP + resources: {{ .Values.statistics_dashboard.resources }} + volumeMounts: + - mountPath: /usr/share/nginx/html + name: statistics + readOnly: true + imagePullSecrets: {{ .Values.statistics_dashboard.image.pullSecrets }} + nodeSelector: {{ .Values.statistics_dashboard.nodeSelector }} + tolerations: {{ .Values.core.tolerations }} + volumes: + - name: statistics + persistentVolumeClaim: + claimName: {{ .Release.Name }}-maibot-statistics-dashboard +{{- end }} diff --git a/helm-chart/templates/statistics-ingress.yaml b/helm-chart/templates/statistics-ingress.yaml new file mode 100644 index 00000000..9c7c2a51 --- /dev/null +++ b/helm-chart/templates/statistics-ingress.yaml @@ -0,0 +1,23 @@ +{{- if .Values.statistics_dashboard.enabled and .Values.statistics_dashboard.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-maibot-statistics-dashboard + namespace: {{ .Release.Namespace }} + annotations: {{ .Values.statistics_dashboard.ingress.annotations }} + labels: + app: {{ .Release.Name }}-maibot-statistics-dashboard +spec: + ingressClassName: {{ .Values.statistics_dashboard.ingress.className }} + rules: + - host: {{ .Values.statistics_dashboard.ingress.host }} + http: + paths: + - backend: + service: + name: {{ .Release.Name }}-maibot-statistics-dashboard + port: + number: {{ .Values.statistics_dashboard.service.port }} + path: {{ .Values.statistics_dashboard.ingress.path }} + pathType: {{ .Values.statistics_dashboard.ingress.pathType }} +{{- end }} diff --git a/helm-chart/templates/statistics-pvc.yaml b/helm-chart/templates/statistics-pvc.yaml new file mode 100644 index 00000000..783614ab --- /dev/null +++ b/helm-chart/templates/statistics-pvc.yaml @@ -0,0 +1,13 @@ +{{- if .Values.statistics_dashboard.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-maibot-statistics-dashboard + namespace: {{ .Release.Namespace }} +spec: + accessModes: {{ .Values.statistics_dashboard.persistence.accessModes }} + resources: + requests: + storage: {{ .Values.statistics_dashboard.persistence.size }} + storageClassName: {{ .Values.statistics_dashboard.persistence.storageClass | default nil }} +{{- end }} diff --git a/helm-chart/templates/statistics-service.yaml b/helm-chart/templates/statistics-service.yaml new file mode 100644 index 00000000..86d0d628 --- /dev/null +++ b/helm-chart/templates/statistics-service.yaml @@ -0,0 +1,21 @@ +{{- if .Values.statistics_dashboard.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-maibot-statistics-dashboard + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-statistics-dashboard +spec: + ports: + - name: dashboard + port: {{ .Values.statistics_dashboard.service.port }} + protocol: TCP + targetPort: 80 + {{- if eq .Values.statistics_dashboard.service.type "nodePort" }} + nodePort: {{ .Values.statistics_dashboard.service.nodePort }} + {{- end }} + selector: + app: {{ .Release.Name }}-maibot-statistics-dashboard + type: {{ .Values.statistics_dashboard.service.type }} +{{- end }} From a72fc3b9f465093361ee0f4abdbe7c6961e4590f Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 00:04:24 +0800 Subject: [PATCH 21/58] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index bbb3e467..2f9f1be0 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -2,8 +2,8 @@ # 配置以下的选项为true表示你同意了EULA和PRIVACY条款 # https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md # https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md -EULA_AGREE: false -PRIVACY_AGREE: false +EULA_AGREE: false +PRIVACY_AGREE: false # 麦麦Adapter的部署配置 adapter: From 7f719fd3b7e6f42166ad7906fa657dbe925b9509 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 00:29:06 +0800 Subject: [PATCH 22/58] =?UTF-8?q?=E7=BC=96=E5=86=99napcat=E7=9A=84?= =?UTF-8?q?=E6=B8=85=E5=8D=95=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/napcat-ingress.yaml | 23 ++++++++ helm-chart/templates/napcat-pvc.yaml | 13 +++++ helm-chart/templates/napcat-service.yaml | 21 +++++++ helm-chart/templates/napcat-statefulset.yaml | 60 ++++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 helm-chart/templates/napcat-ingress.yaml create mode 100644 helm-chart/templates/napcat-pvc.yaml create mode 100644 helm-chart/templates/napcat-service.yaml create mode 100644 helm-chart/templates/napcat-statefulset.yaml diff --git a/helm-chart/templates/napcat-ingress.yaml b/helm-chart/templates/napcat-ingress.yaml new file mode 100644 index 00000000..bd28cd3c --- /dev/null +++ b/helm-chart/templates/napcat-ingress.yaml @@ -0,0 +1,23 @@ +{{- if .Values.napcat.enabled and .Values.napcat.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-maibot-napcat + namespace: {{ .Release.Namespace }} + annotations: {{ .Values.napcat.ingress.annotations }} + labels: + app: {{ .Release.Name }}-maibot-napcat +spec: + ingressClassName: {{ .Values.napcat.ingress.className }} + rules: + - host: {{ .Values.napcat.ingress.host }} + http: + paths: + - backend: + service: + name: {{ .Release.Name }}-maibot-napcat + port: + number: {{ .Values.napcat.service.port }} + path: {{ .Values.napcat.ingress.path }} + pathType: {{ .Values.napcat.ingress.pathType }} +{{- end }} diff --git a/helm-chart/templates/napcat-pvc.yaml b/helm-chart/templates/napcat-pvc.yaml new file mode 100644 index 00000000..b1a008b3 --- /dev/null +++ b/helm-chart/templates/napcat-pvc.yaml @@ -0,0 +1,13 @@ +{{- if .Values.napcat.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-maibot-napcat + namespace: {{ .Release.Namespace }} +spec: + accessModes: {{ .Values.napcat.persistence.accessModes }} + resources: + requests: + storage: {{ .Values.napcat.persistence.size }} + storageClassName: {{ .Values.napcat.persistence.storageClass | default nil }} +{{- end }} diff --git a/helm-chart/templates/napcat-service.yaml b/helm-chart/templates/napcat-service.yaml new file mode 100644 index 00000000..a3dc0c8d --- /dev/null +++ b/helm-chart/templates/napcat-service.yaml @@ -0,0 +1,21 @@ +{{- if .Values.napcat.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-maibot-napcat + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-napcat +spec: + ports: + - name: webui + port: {{ .Values.napcat.service.port }} + protocol: TCP + targetPort: 6099 + {{- if eq .Values.napcat.service.type "nodePort" }} + nodePort: {{ .Values.napcat.service.nodePort }} + {{- end }} + selector: + app: {{ .Release.Name }}-maibot-napcat + type: {{ .Values.napcat.service.type }} +{{- end }} diff --git a/helm-chart/templates/napcat-statefulset.yaml b/helm-chart/templates/napcat-statefulset.yaml new file mode 100644 index 00000000..c7f78f63 --- /dev/null +++ b/helm-chart/templates/napcat-statefulset.yaml @@ -0,0 +1,60 @@ +{{- if .Values.napcat.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Release.Name }}-maibot-napcat + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-napcat +spec: + serviceName: {{ .Release.Name }}-maibot-napcat + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-maibot-napcat + template: + metadata: + labels: + app: {{ .Release.Name }}-maibot-napcat + spec: + containers: + - name: napcat + env: + - name: NAPCAT_GID + value: {{ .Values.napcat.permission.gid }} + - name: NAPCAT_UID + value: {{ .Values.napcat.permission.uid }} + - name: TZ + value: Asia/Shanghai + image: {{ .Values.napcat.image.repository }}:{{ .Values.napcat.image.tag }} + imagePullPolicy: {{ .Values.napcat.image.pullPolicy }} + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 6099 + scheme: HTTP + initialDelaySeconds: 60 + periodSeconds: 60 + successThreshold: 1 + timeoutSeconds: 10 + ports: + - containerPort: 6099 + name: webui + protocol: TCP + resources: {{ .Values.napcat.resources }} + volumeMounts: + - mountPath: /app/napcat/config + name: napcat + subPath: config + - mountPath: /app/.config/QQ + name: napcat + subPath: data + imagePullSecrets: {{ .Values.napcat.image.pullSecrets }} + nodeSelector: {{ .Values.napcat.nodeSelector }} + tolerations: {{ .Values.napcat.tolerations }} + volumes: + - name: napcat + persistentVolumeClaim: + claimName: {{ .Release.Name }}-maibot-napcat +{{- end }} From 37c73072777d00ddf3e322b5969e35b8cb9b4c7e Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 00:33:42 +0800 Subject: [PATCH 23/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9values=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E6=A8=AA=E6=9D=A0=E4=B8=BA=E4=B8=8B=E5=88=92=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index 2f9f1be0..149d30d1 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -166,7 +166,7 @@ napcat: size: 5Gi # sqlite-web的部署配置 -sqlite-web: +sqlite_web: # 通过sqlite-web可以在网页上操作麦麦的数据库,方便调试。不部署对麦麦的运行无影响 # 默认不会捆绑部署sqlite-web,如果你需要部署,请修改下面的enabled为true From c2c08887fa3bb1ac3f347d78d0898df671931efc Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 00:38:39 +0800 Subject: [PATCH 24/58] =?UTF-8?q?fix:=20=E4=B8=BAsqlite-web=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=81=97=E6=BC=8F=E7=9A=84nodeSelector=E5=92=8Ctolera?= =?UTF-8?q?tions=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/values.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index 149d30d1..a160af63 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -188,6 +188,9 @@ sqlite_web: cpu: memory: + nodeSelector: {} + tolerations: [] + # 配置sqlite-web面板的service # !!!默认不使用NodePort。如果使用NodePort暴露到公网,请自行使用中间件鉴权!!! service: From c65424f0760a9913b2942585bbe1bcffa9047db3 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 00:44:54 +0800 Subject: [PATCH 25/58] =?UTF-8?q?=E7=BC=96=E5=86=99sqlite-web=E7=9A=84?= =?UTF-8?q?=E6=B8=85=E5=8D=95=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/sqlite-web-ingress.yaml | 23 ++++++++ helm-chart/templates/sqlite-web-service.yaml | 21 ++++++++ .../templates/sqlite-web-statefulset.yaml | 52 +++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 helm-chart/templates/sqlite-web-ingress.yaml create mode 100644 helm-chart/templates/sqlite-web-service.yaml create mode 100644 helm-chart/templates/sqlite-web-statefulset.yaml diff --git a/helm-chart/templates/sqlite-web-ingress.yaml b/helm-chart/templates/sqlite-web-ingress.yaml new file mode 100644 index 00000000..e5426d39 --- /dev/null +++ b/helm-chart/templates/sqlite-web-ingress.yaml @@ -0,0 +1,23 @@ +{{- if .Values.sqlite_web.enabled and .Values.sqlite_web.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-maibot-sqlite-web + namespace: {{ .Release.Namespace }} + annotations: {{ .Values.sqlite_web.ingress.annotations }} + labels: + app: {{ .Release.Name }}-maibot-sqlite-web +spec: + ingressClassName: {{ .Values.sqlite_web.ingress.className }} + rules: + - host: {{ .Values.sqlite_web.ingress.host }} + http: + paths: + - backend: + service: + name: {{ .Release.Name }}-maibot-sqlite-web + port: + number: {{ .Values.sqlite_web.service.port }} + path: {{ .Values.sqlite_web.ingress.path }} + pathType: {{ .Values.sqlite_web.ingress.pathType }} +{{- end }} diff --git a/helm-chart/templates/sqlite-web-service.yaml b/helm-chart/templates/sqlite-web-service.yaml new file mode 100644 index 00000000..4212a5a8 --- /dev/null +++ b/helm-chart/templates/sqlite-web-service.yaml @@ -0,0 +1,21 @@ +{{- if .Values.sqlite_web.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-maibot-sqlite-web + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-sqlite-web +spec: + ports: + - name: webui + port: {{ .Values.sqlite_web.service.port }} + protocol: TCP + targetPort: 8080 + {{- if eq .Values.sqlite_web.service.type "nodePort" }} + nodePort: {{ .Values.sqlite_web.service.nodePort }} + {{- end }} + selector: + app: {{ .Release.Name }}-maibot-sqlite-web + type: {{ .Values.sqlite_web.service.type }} +{{- end }} diff --git a/helm-chart/templates/sqlite-web-statefulset.yaml b/helm-chart/templates/sqlite-web-statefulset.yaml new file mode 100644 index 00000000..121d11cf --- /dev/null +++ b/helm-chart/templates/sqlite-web-statefulset.yaml @@ -0,0 +1,52 @@ +{{- if .Values.sqlite_web.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Release.Name }}-maibot-sqlite-web + namespace: {{ .Release.Namespace }} + labels: + app: {{ .Release.Name }}-maibot-sqlite-web +spec: + serviceName: {{ .Release.Name }}-maibot-sqlite-web + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-maibot-sqlite-web + template: + metadata: + labels: + app: {{ .Release.Name }}-maibot-sqlite-web + spec: + containers: + - name: sqlite-web + env: + - name: SQLITE_DATABASE + value: /data/MaiMBot/MaiBot.db + image: {{ .Values.sqlite_web.image.repository }}:{{ .Values.sqlite_web.image.tag }} + imagePullPolicy: {{ .Values.sqlite_web.image.pullPolicy }} + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 8080 + scheme: HTTP + initialDelaySeconds: 60 + periodSeconds: 60 + successThreshold: 1 + timeoutSeconds: 10 + ports: + - containerPort: 8080 + name: webui + protocol: TCP + resources: {{ .Values.sqlite_web.resources }} + volumeMounts: + - mountPath: /data/MaiMBot + name: data + imagePullSecrets: {{ .Values.sqlite_web.image.pullSecrets }} + nodeSelector: {{ .Values.sqlite_web.nodeSelector }} + tolerations: {{ .Values.sqlite_web.tolerations }} + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-maibot-core +{{- end }} From f891fdd0c45ff51d8810aad90e5557efec540c0b Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 00:52:27 +0800 Subject: [PATCH 26/58] =?UTF-8?q?fix:=20=E6=9D=A1=E4=BB=B6=E4=B8=8E?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/napcat-ingress.yaml | 2 +- helm-chart/templates/sqlite-web-ingress.yaml | 2 +- helm-chart/templates/statistics-ingress.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helm-chart/templates/napcat-ingress.yaml b/helm-chart/templates/napcat-ingress.yaml index bd28cd3c..9c590895 100644 --- a/helm-chart/templates/napcat-ingress.yaml +++ b/helm-chart/templates/napcat-ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.napcat.enabled and .Values.napcat.ingress.enabled }} +{{- if and .Values.napcat.enabled .Values.napcat.ingress.enabled }} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/helm-chart/templates/sqlite-web-ingress.yaml b/helm-chart/templates/sqlite-web-ingress.yaml index e5426d39..967c9999 100644 --- a/helm-chart/templates/sqlite-web-ingress.yaml +++ b/helm-chart/templates/sqlite-web-ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.sqlite_web.enabled and .Values.sqlite_web.ingress.enabled }} +{{- if and .Values.sqlite_web.enabled .Values.sqlite_web.ingress.enabled }} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/helm-chart/templates/statistics-ingress.yaml b/helm-chart/templates/statistics-ingress.yaml index 9c7c2a51..c7756647 100644 --- a/helm-chart/templates/statistics-ingress.yaml +++ b/helm-chart/templates/statistics-ingress.yaml @@ -1,4 +1,4 @@ -{{- if .Values.statistics_dashboard.enabled and .Values.statistics_dashboard.ingress.enabled }} +{{- if and .Values.statistics_dashboard.enabled .Values.statistics_dashboard.ingress.enabled }} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: From df3ebc07ee7c7fc6286aecf9c588be455dace0a1 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 01:01:07 +0800 Subject: [PATCH 27/58] =?UTF-8?q?fix:=20helm=E6=A8=A1=E6=9D=BF=E7=BC=A9?= =?UTF-8?q?=E8=BF=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-configmap.yaml | 2 +- helm-chart/templates/core-configmap.yaml | 4 ++-- helm-chart/templates/core-scripts-configmap.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helm-chart/templates/adapter-configmap.yaml b/helm-chart/templates/adapter-configmap.yaml index 6b4c80cc..ebc9e568 100644 --- a/helm-chart/templates/adapter-configmap.yaml +++ b/helm-chart/templates/adapter-configmap.yaml @@ -5,4 +5,4 @@ metadata: namespace: {{ .Release.Namespace }} data: config.toml: | - {{ .Values.config.adapter_config | indent 4 }} + {{ .Values.config.adapter_config | nindent 4 }} diff --git a/helm-chart/templates/core-configmap.yaml b/helm-chart/templates/core-configmap.yaml index a37e0425..25f0ef2d 100644 --- a/helm-chart/templates/core-configmap.yaml +++ b/helm-chart/templates/core-configmap.yaml @@ -8,6 +8,6 @@ data: HOST=0.0.0.0 PORT=8000 model_config.toml: | - {{ .Values.config.core_model_config | indent 4 }} + {{ .Values.config.core_model_config | nindent 4 }} bot_config.toml: | - {{ .Values.config.core_bot_config | indent 4 }} + {{ .Values.config.core_bot_config | nindent 4 }} diff --git a/helm-chart/templates/core-scripts-configmap.yaml b/helm-chart/templates/core-scripts-configmap.yaml index 57394122..79c05d96 100644 --- a/helm-chart/templates/core-scripts-configmap.yaml +++ b/helm-chart/templates/core-scripts-configmap.yaml @@ -5,4 +5,4 @@ metadata: namespace: {{ .Release.Namespace }} data: volume-linker.sh: | - {{ .Files.Get "files/volume-linker.sh" | indent 4 }} + {{ .Files.Get "files/volume-linker.sh" | nindent 4 }} From 50140354cfc2cce13ffa0321137525ae2589d95a Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 02:32:03 +0800 Subject: [PATCH 28/58] =?UTF-8?q?core=E6=9C=8D=E5=8A=A1=E7=9A=84DNS?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=98=AF=E5=8A=A8=E6=80=81=E7=9A=84=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=9C=A8adapter=E6=9C=8D=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E6=8F=90=E5=89=8D?= =?UTF-8?q?=E7=A1=AE=E5=AE=9A=EF=BC=8C=E5=9B=A0=E6=AD=A4=E5=9C=A8=E9=83=A8?= =?UTF-8?q?=E7=BD=B2helm=20chart=E6=97=B6=E5=8A=A8=E6=80=81=E7=94=9F?= =?UTF-8?q?=E6=88=90adapter=E7=9A=84=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/files/adapter-cm-generator.py | 41 +++++++++++++++ helm-chart/files/adapter-pip-installer.sh | 5 ++ helm-chart/templates/adapter-configmap.yaml | 8 --- .../templates/core-scripts-configmap.yaml | 8 --- helm-chart/templates/core-statefulset.yaml | 2 +- .../templates/pre-adapter-cm-gen-job.yaml | 50 +++++++++++++++++++ .../templates/pre-adapter-cm-gen-rbac.yaml | 39 +++++++++++++++ helm-chart/templates/scripts-configmap.yaml | 15 ++++++ helm-chart/values.yaml | 6 --- 9 files changed, 151 insertions(+), 23 deletions(-) create mode 100644 helm-chart/files/adapter-cm-generator.py create mode 100644 helm-chart/files/adapter-pip-installer.sh delete mode 100644 helm-chart/templates/adapter-configmap.yaml delete mode 100644 helm-chart/templates/core-scripts-configmap.yaml create mode 100644 helm-chart/templates/pre-adapter-cm-gen-job.yaml create mode 100644 helm-chart/templates/pre-adapter-cm-gen-rbac.yaml create mode 100644 helm-chart/templates/scripts-configmap.yaml diff --git a/helm-chart/files/adapter-cm-generator.py b/helm-chart/files/adapter-cm-generator.py new file mode 100644 index 00000000..8a3637b0 --- /dev/null +++ b/helm-chart/files/adapter-cm-generator.py @@ -0,0 +1,41 @@ +#!/bin/python3 +# 这个脚本的作用是在部署helm chart时动态生成adapter的配置文件,保存在configmap中 +# 需要动态生成的原因是core服务的DNS名称是动态的,无法在adapter服务的配置文件中提前确定 +# 一些与k8s现有资源冲突的配置也会在这里重置 + +import os +import toml +import base64 +from kubernetes import client, config + +config.load_incluster_config() +v1 = client.CoreV1Api() + +# 读取部署的关键信息 +namespace = os.getenv("NAMESPACE") +release_name = os.getenv("RELEASE_NAME") +data_b64 = os.getenv("DATA_B64") + +# 解析并覆盖关键配置 +# 这里被覆盖的配置应当在helm chart中针对对应的k8s资源来灵活修改 +data = toml.loads(base64.b64decode(data_b64).decode("utf-8")) +data['napcat_server']['host'] = '0.0.0.0' +data['napcat_server']['port'] = 8095 +data['maibot_server']['host'] = f'{release_name}-maibot-core' # 根据release名称动态拼接core服务的DNS名称 +data['maibot_server']['port'] = 8000 + +# 创建/修改configmap +cm_name = f'{release_name}-maibot-adapter' +cm = client.V1ConfigMap( + metadata=client.V1ObjectMeta(name=cm_name), + data={'config.toml': toml.dumps(data)} +) +try: + v1.create_namespaced_config_map(namespace, cm) + print(f"ConfigMap `{cm_name}` created successfully") +except client.exceptions.ApiException as e: + if e.status == 409: # 已存在,更新 + v1.replace_namespaced_config_map(cm_name, namespace, cm) + print(f"ConfigMap `{cm_name}` replaced successfully") + else: + raise diff --git a/helm-chart/files/adapter-pip-installer.sh b/helm-chart/files/adapter-pip-installer.sh new file mode 100644 index 00000000..47564820 --- /dev/null +++ b/helm-chart/files/adapter-pip-installer.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# 这个脚本的作用是安装必要的python包,为adapter-cm-generator.py脚本做准备 + +pip3 install -i https://mirrors.ustc.edu.cn/pypi/simple kubernetes toml +python3 adapter-cm-generator.py diff --git a/helm-chart/templates/adapter-configmap.yaml b/helm-chart/templates/adapter-configmap.yaml deleted file mode 100644 index ebc9e568..00000000 --- a/helm-chart/templates/adapter-configmap.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Release.Name }}-maibot-adapter - namespace: {{ .Release.Namespace }} -data: - config.toml: | - {{ .Values.config.adapter_config | nindent 4 }} diff --git a/helm-chart/templates/core-scripts-configmap.yaml b/helm-chart/templates/core-scripts-configmap.yaml deleted file mode 100644 index 79c05d96..00000000 --- a/helm-chart/templates/core-scripts-configmap.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Release.Name }}-maibot-core-scripts - namespace: {{ .Release.Namespace }} -data: - volume-linker.sh: | - {{ .Files.Get "files/volume-linker.sh" | nindent 4 }} diff --git a/helm-chart/templates/core-statefulset.yaml b/helm-chart/templates/core-statefulset.yaml index d6717a5b..42668d7b 100644 --- a/helm-chart/templates/core-statefulset.yaml +++ b/helm-chart/templates/core-statefulset.yaml @@ -70,7 +70,7 @@ spec: items: - key: volume-linker.sh path: volume-linker.sh - name: {{ .Release.Name }}-maibot-core-scripts + name: {{ .Release.Name }}-maibot-scripts name: scripts - configMap: items: diff --git a/helm-chart/templates/pre-adapter-cm-gen-job.yaml b/helm-chart/templates/pre-adapter-cm-gen-job.yaml new file mode 100644 index 00000000..a062735d --- /dev/null +++ b/helm-chart/templates/pre-adapter-cm-gen-job.yaml @@ -0,0 +1,50 @@ +# 动态生成adapter配置文件的configmap的job,仅会在部署时运行一次 +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ .Release.Name }}-adapter-cm-generator + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded +spec: + backoffLimit: 0 + template: + spec: + serviceAccountName: {{ .Release.Name }}-adapter-cm-generator + restartPolicy: Never + containers: + - name: python + image: python:slim + workingDir: /app + command: + - sh + args: + - adapter-pip-installer.sh + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: RELEASE_NAME + value: {{ .Release.Name }} + - name: DATA_B64 + value: {{ .Values.config.adapter_config | b64enc }} # 将配置文件编码为base64,从环境变量注入 + volumeMounts: + - mountPath: /app/adapter-pip-installer.sh + name: scripts + readOnly: true + subPath: adapter-pip-installer.sh + - mountPath: /app/adapter-cm-generator.py + name: scripts + readOnly: true + subPath: adapter-cm-generator.py + volumes: + - name: scripts + configMap: + name: {{ .Release.Name }}-maibot-scripts + items: + - key: adapter-pip-installer.sh + path: adapter-pip-installer.sh + - key: adapter-cm-generator.py + path: adapter-cm-generator.py diff --git a/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml b/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml new file mode 100644 index 00000000..786f2de9 --- /dev/null +++ b/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml @@ -0,0 +1,39 @@ +# 动态生成adapter配置文件的configmap所需要的rbac授权 +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Release.Name }}-adapter-cm-generator + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ .Release.Name }}-adapter-cm-gen-role + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded +rules: + - apiGroups: [""] + resources: ["configmaps"] + verbs: ["get", "list", "create", "update", "patch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ .Release.Name }}-adapter-cm-gen-role-binding + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded +subjects: + - kind: ServiceAccount + name: {{ .Release.Name }}-adapter-cm-generator + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: {{ .Release.Name }}-adapter-cm-gen-role + apiGroup: rbac.authorization.k8s.io diff --git a/helm-chart/templates/scripts-configmap.yaml b/helm-chart/templates/scripts-configmap.yaml new file mode 100644 index 00000000..6eb0c4db --- /dev/null +++ b/helm-chart/templates/scripts-configmap.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-maibot-scripts + namespace: {{ .Release.Namespace }} +data: + # pre-install hook + adapter-pip-installer.sh: | + {{ .Files.Get "files/adapter-pip-installer.sh" | nindent 4 }} + adapter-cm-generator.py: | + {{ .Files.Get "files/adapter-cm-generator.py" | nindent 4 }} + + # core + volume-linker.sh: | + {{ .Files.Get "files/volume-linker.sh" | nindent 4 }} diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index a160af63..b9ac3277 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -221,14 +221,8 @@ config: nickname = "" [napcat_server] # Napcat连接的ws服务设置 - host = "0.0.0.0" # Napcat设定的主机地址 - port = 8095 # Napcat设定的端口 heartbeat_interval = 30 # 与Napcat设置的心跳相同(按秒计) - [maibot_server] # 连接麦麦的ws服务设置 - host = "localhost" # 麦麦在.env文件中设置的主机地址,即HOST字段 - port = 8000 # 麦麦在.env文件中设置的端口,即PORT字段 - [chat] # 黑白名单功能 group_list_type = "whitelist" # 群组名单类型,可选为:whitelist, blacklist group_list = [] # 群组名单 From f2ef353cc088851c8fd4b5e02e00bb7209b5b0bf Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 02:35:11 +0800 Subject: [PATCH 29/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/pre-adapter-cm-gen-job.yaml | 4 ++-- helm-chart/templates/pre-adapter-cm-gen-rbac.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helm-chart/templates/pre-adapter-cm-gen-job.yaml b/helm-chart/templates/pre-adapter-cm-gen-job.yaml index a062735d..e714ce76 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-job.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-job.yaml @@ -2,7 +2,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: {{ .Release.Name }}-adapter-cm-generator + name: {{ .Release.Name }}-maibot-adapter-cm-generator namespace: {{ .Release.Namespace }} annotations: "helm.sh/hook": pre-install @@ -11,7 +11,7 @@ spec: backoffLimit: 0 template: spec: - serviceAccountName: {{ .Release.Name }}-adapter-cm-generator + serviceAccountName: {{ .Release.Name }}-maibot-adapter-cm-generator restartPolicy: Never containers: - name: python diff --git a/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml b/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml index 786f2de9..cad56079 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ .Release.Name }}-adapter-cm-generator + name: {{ .Release.Name }}-maibot-adapter-cm-generator namespace: {{ .Release.Namespace }} annotations: "helm.sh/hook": pre-install @@ -11,7 +11,7 @@ metadata: apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - name: {{ .Release.Name }}-adapter-cm-gen-role + name: {{ .Release.Name }}-maibot-adapter-cm-gen-role namespace: {{ .Release.Namespace }} annotations: "helm.sh/hook": pre-install @@ -24,7 +24,7 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: {{ .Release.Name }}-adapter-cm-gen-role-binding + name: {{ .Release.Name }}-maibot-adapter-cm-gen-role-binding namespace: {{ .Release.Namespace }} annotations: "helm.sh/hook": pre-install From 37d3427698128a59aa7115f04bd8d2adcd72b550 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 02:36:29 +0800 Subject: [PATCH 30/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/pre-adapter-cm-gen-rbac.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml b/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml index cad56079..53c8e8b5 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml @@ -31,9 +31,9 @@ metadata: "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded subjects: - kind: ServiceAccount - name: {{ .Release.Name }}-adapter-cm-generator + name: {{ .Release.Name }}-maibot-adapter-cm-generator namespace: {{ .Release.Namespace }} roleRef: kind: Role - name: {{ .Release.Name }}-adapter-cm-gen-role + name: {{ .Release.Name }}-maibot-adapter-cm-gen-role apiGroup: rbac.authorization.k8s.io From 1eb5c4c56b0e518d8b4ba776c6b9494f41c81073 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 02:41:39 +0800 Subject: [PATCH 31/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=9A=84=E8=BF=90=E8=A1=8C=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/pre-adapter-cm-gen-job.yaml | 2 +- helm-chart/templates/pre-adapter-cm-gen-rbac.yaml | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/helm-chart/templates/pre-adapter-cm-gen-job.yaml b/helm-chart/templates/pre-adapter-cm-gen-job.yaml index e714ce76..2337f859 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-job.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-job.yaml @@ -5,7 +5,7 @@ metadata: name: {{ .Release.Name }}-maibot-adapter-cm-generator namespace: {{ .Release.Namespace }} annotations: - "helm.sh/hook": pre-install + "helm.sh/hook": post-install "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: backoffLimit: 0 diff --git a/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml b/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml index 53c8e8b5..69fefbef 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-rbac.yaml @@ -4,18 +4,12 @@ kind: ServiceAccount metadata: name: {{ .Release.Name }}-maibot-adapter-cm-generator namespace: {{ .Release.Namespace }} - annotations: - "helm.sh/hook": pre-install - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: {{ .Release.Name }}-maibot-adapter-cm-gen-role namespace: {{ .Release.Namespace }} - annotations: - "helm.sh/hook": pre-install - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded rules: - apiGroups: [""] resources: ["configmaps"] @@ -26,9 +20,6 @@ kind: RoleBinding metadata: name: {{ .Release.Name }}-maibot-adapter-cm-gen-role-binding namespace: {{ .Release.Namespace }} - annotations: - "helm.sh/hook": pre-install - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded subjects: - kind: ServiceAccount name: {{ .Release.Name }}-maibot-adapter-cm-generator From 3624e5e63d2110476669bda5ea4f4ad7859dcb47 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 02:45:21 +0800 Subject: [PATCH 32/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3values=E5=86=85?= =?UTF-8?q?=E7=9A=84=E8=B5=84=E6=BA=90=E9=99=90=E5=88=B6=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/values.yaml | 60 +++++++++++------------------------------- 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index b9ac3277..0acdfb35 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -14,16 +14,10 @@ adapter: pullPolicy: IfNotPresent pullSecrets: [ ] - resources: - limits: - cpu: - memory: - requests: - cpu: - memory: + resources: { } - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] # 配置adapter的napcat websocket service # adapter会启动一个websocket服务端,用于与napcat通信 @@ -49,16 +43,10 @@ core: pullPolicy: IfNotPresent pullSecrets: [ ] - resources: - limits: - cpu: - memory: - requests: - cpu: - memory: + resources: { } - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] persistence: storageClass: @@ -82,16 +70,10 @@ statistics_dashboard: pullPolicy: IfNotPresent pullSecrets: [ ] - resources: - limits: - cpu: - memory: - requests: - cpu: - memory: + resources: { } - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] service: type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的服务端口映射到物理节点的端口 @@ -128,16 +110,10 @@ napcat: pullPolicy: IfNotPresent pullSecrets: [ ] - resources: - limits: - cpu: - memory: - requests: - cpu: - memory: + resources: { } - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] # napcat进程的权限,默认不是特权用户 permission: @@ -180,16 +156,10 @@ sqlite_web: pullPolicy: IfNotPresent pullSecrets: [ ] - resources: - limits: - cpu: - memory: - requests: - cpu: - memory: + resources: { } - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] # 配置sqlite-web面板的service # !!!默认不使用NodePort。如果使用NodePort暴露到公网,请自行使用中间件鉴权!!! From 0f82ebf53e430d46c042cafc9bc59105d8d512ea Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 02:48:36 +0800 Subject: [PATCH 33/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E7=9A=84=E7=B1=BB=E5=9E=8B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/napcat-statefulset.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm-chart/templates/napcat-statefulset.yaml b/helm-chart/templates/napcat-statefulset.yaml index c7f78f63..0c9b6296 100644 --- a/helm-chart/templates/napcat-statefulset.yaml +++ b/helm-chart/templates/napcat-statefulset.yaml @@ -21,9 +21,9 @@ spec: - name: napcat env: - name: NAPCAT_GID - value: {{ .Values.napcat.permission.gid }} + value: "{{ .Values.napcat.permission.gid }}" - name: NAPCAT_UID - value: {{ .Values.napcat.permission.uid }} + value: "{{ .Values.napcat.permission.uid }}" - name: TZ value: Asia/Shanghai image: {{ .Values.napcat.image.repository }}:{{ .Values.napcat.image.tag }} From 93778370bfa6992f512bbc585bf6006da88a3cf3 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 02:52:18 +0800 Subject: [PATCH 34/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E9=99=90=E5=88=B6=E7=9A=84=E7=B1=BB=E5=9E=8B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-statefulset.yaml | 2 +- helm-chart/templates/core-statefulset.yaml | 2 +- helm-chart/templates/napcat-statefulset.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helm-chart/templates/adapter-statefulset.yaml b/helm-chart/templates/adapter-statefulset.yaml index 7d6df8b4..311c6d1e 100644 --- a/helm-chart/templates/adapter-statefulset.yaml +++ b/helm-chart/templates/adapter-statefulset.yaml @@ -27,7 +27,7 @@ spec: - containerPort: 8095 name: napcat-ws protocol: TCP - resources: {{ .Values.adapter.resources }} + resources: {{ .Values.adapter.resources | default nil }} volumeMounts: - mountPath: /adapters/data name: data diff --git a/helm-chart/templates/core-statefulset.yaml b/helm-chart/templates/core-statefulset.yaml index 42668d7b..7a1b55d4 100644 --- a/helm-chart/templates/core-statefulset.yaml +++ b/helm-chart/templates/core-statefulset.yaml @@ -35,7 +35,7 @@ spec: - containerPort: 8000 name: adapter-ws protocol: TCP - resources: {{ .Values.core.resources }} + resources: {{ .Values.core.resources | default nil }} volumeMounts: - mountPath: /MaiMBot/data name: data diff --git a/helm-chart/templates/napcat-statefulset.yaml b/helm-chart/templates/napcat-statefulset.yaml index 0c9b6296..51be029f 100644 --- a/helm-chart/templates/napcat-statefulset.yaml +++ b/helm-chart/templates/napcat-statefulset.yaml @@ -42,7 +42,7 @@ spec: - containerPort: 6099 name: webui protocol: TCP - resources: {{ .Values.napcat.resources }} + resources: {{ .Values.napcat.resources | default nil }} volumeMounts: - mountPath: /app/napcat/config name: napcat From 4c5c7137e78c44c5a869b5326a67059b213e314b Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 02:58:21 +0800 Subject: [PATCH 35/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-service.yaml | 2 +- helm-chart/templates/adapter-statefulset.yaml | 6 +++--- helm-chart/templates/core-statefulset.yaml | 6 +++--- helm-chart/templates/napcat-ingress.yaml | 2 +- helm-chart/templates/napcat-service.yaml | 2 +- helm-chart/templates/napcat-statefulset.yaml | 6 +++--- helm-chart/templates/sqlite-web-ingress.yaml | 2 +- helm-chart/templates/sqlite-web-service.yaml | 2 +- helm-chart/templates/sqlite-web-statefulset.yaml | 6 +++--- helm-chart/templates/statistics-deployment.yaml | 6 +++--- helm-chart/templates/statistics-ingress.yaml | 2 +- helm-chart/templates/statistics-service.yaml | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/helm-chart/templates/adapter-service.yaml b/helm-chart/templates/adapter-service.yaml index af306103..4df2d31d 100644 --- a/helm-chart/templates/adapter-service.yaml +++ b/helm-chart/templates/adapter-service.yaml @@ -12,7 +12,7 @@ spec: protocol: TCP targetPort: 8095 {{- if eq .Values.adapter.service.type "nodePort" }} - nodePort: {{ .Values.adapter.service.nodePort }} + nodePort: {{ .Values.adapter.service.nodePort | default nil }} {{- end }} selector: app: {{ .Release.Name }}-maibot-adapter diff --git a/helm-chart/templates/adapter-statefulset.yaml b/helm-chart/templates/adapter-statefulset.yaml index 311c6d1e..998819ae 100644 --- a/helm-chart/templates/adapter-statefulset.yaml +++ b/helm-chart/templates/adapter-statefulset.yaml @@ -35,9 +35,9 @@ spec: name: config readOnly: true subPath: config.toml - imagePullSecrets: {{ .Values.adapter.image.pullSecrets }} - nodeSelector: {{ .Values.adapter.nodeSelector }} - tolerations: {{ .Values.adapter.tolerations }} + imagePullSecrets: {{ .Values.adapter.image.pullSecrets | default nil }} + nodeSelector: {{ .Values.adapter.nodeSelector | default nil }} + tolerations: {{ .Values.adapter.tolerations | default nil }} volumes: - name: data persistentVolumeClaim: diff --git a/helm-chart/templates/core-statefulset.yaml b/helm-chart/templates/core-statefulset.yaml index 7a1b55d4..56f73581 100644 --- a/helm-chart/templates/core-statefulset.yaml +++ b/helm-chart/templates/core-statefulset.yaml @@ -59,9 +59,9 @@ spec: - mountPath: /MaiMBot/statistics name: statistics {{- end }} - imagePullSecrets: {{ .Values.core.image.pullSecrets }} - nodeSelector: {{ .Values.core.nodeSelector }} - tolerations: {{ .Values.core.tolerations }} + imagePullSecrets: {{ .Values.core.image.pullSecrets | default nil }} + nodeSelector: {{ .Values.core.nodeSelector | default nil }} + tolerations: {{ .Values.core.tolerations | default nil }} volumes: - name: data persistentVolumeClaim: diff --git a/helm-chart/templates/napcat-ingress.yaml b/helm-chart/templates/napcat-ingress.yaml index 9c590895..2343ca9c 100644 --- a/helm-chart/templates/napcat-ingress.yaml +++ b/helm-chart/templates/napcat-ingress.yaml @@ -4,7 +4,7 @@ kind: Ingress metadata: name: {{ .Release.Name }}-maibot-napcat namespace: {{ .Release.Namespace }} - annotations: {{ .Values.napcat.ingress.annotations }} + annotations: {{ .Values.napcat.ingress.annotations | default nil }} labels: app: {{ .Release.Name }}-maibot-napcat spec: diff --git a/helm-chart/templates/napcat-service.yaml b/helm-chart/templates/napcat-service.yaml index a3dc0c8d..245513d6 100644 --- a/helm-chart/templates/napcat-service.yaml +++ b/helm-chart/templates/napcat-service.yaml @@ -13,7 +13,7 @@ spec: protocol: TCP targetPort: 6099 {{- if eq .Values.napcat.service.type "nodePort" }} - nodePort: {{ .Values.napcat.service.nodePort }} + nodePort: {{ .Values.napcat.service.nodePort | default nil }} {{- end }} selector: app: {{ .Release.Name }}-maibot-napcat diff --git a/helm-chart/templates/napcat-statefulset.yaml b/helm-chart/templates/napcat-statefulset.yaml index 51be029f..7969d388 100644 --- a/helm-chart/templates/napcat-statefulset.yaml +++ b/helm-chart/templates/napcat-statefulset.yaml @@ -50,9 +50,9 @@ spec: - mountPath: /app/.config/QQ name: napcat subPath: data - imagePullSecrets: {{ .Values.napcat.image.pullSecrets }} - nodeSelector: {{ .Values.napcat.nodeSelector }} - tolerations: {{ .Values.napcat.tolerations }} + imagePullSecrets: {{ .Values.napcat.image.pullSecrets | default nil }} + nodeSelector: {{ .Values.napcat.nodeSelector | default nil }} + tolerations: {{ .Values.napcat.tolerations | default nil }} volumes: - name: napcat persistentVolumeClaim: diff --git a/helm-chart/templates/sqlite-web-ingress.yaml b/helm-chart/templates/sqlite-web-ingress.yaml index 967c9999..0bd6a3c4 100644 --- a/helm-chart/templates/sqlite-web-ingress.yaml +++ b/helm-chart/templates/sqlite-web-ingress.yaml @@ -4,7 +4,7 @@ kind: Ingress metadata: name: {{ .Release.Name }}-maibot-sqlite-web namespace: {{ .Release.Namespace }} - annotations: {{ .Values.sqlite_web.ingress.annotations }} + annotations: {{ .Values.sqlite_web.ingress.annotations | default nil }} labels: app: {{ .Release.Name }}-maibot-sqlite-web spec: diff --git a/helm-chart/templates/sqlite-web-service.yaml b/helm-chart/templates/sqlite-web-service.yaml index 4212a5a8..f07c8184 100644 --- a/helm-chart/templates/sqlite-web-service.yaml +++ b/helm-chart/templates/sqlite-web-service.yaml @@ -13,7 +13,7 @@ spec: protocol: TCP targetPort: 8080 {{- if eq .Values.sqlite_web.service.type "nodePort" }} - nodePort: {{ .Values.sqlite_web.service.nodePort }} + nodePort: {{ .Values.sqlite_web.service.nodePort | default nil }} {{- end }} selector: app: {{ .Release.Name }}-maibot-sqlite-web diff --git a/helm-chart/templates/sqlite-web-statefulset.yaml b/helm-chart/templates/sqlite-web-statefulset.yaml index 121d11cf..f4bd762a 100644 --- a/helm-chart/templates/sqlite-web-statefulset.yaml +++ b/helm-chart/templates/sqlite-web-statefulset.yaml @@ -42,9 +42,9 @@ spec: volumeMounts: - mountPath: /data/MaiMBot name: data - imagePullSecrets: {{ .Values.sqlite_web.image.pullSecrets }} - nodeSelector: {{ .Values.sqlite_web.nodeSelector }} - tolerations: {{ .Values.sqlite_web.tolerations }} + imagePullSecrets: {{ .Values.sqlite_web.image.pullSecrets | default nil }} + nodeSelector: {{ .Values.sqlite_web.nodeSelector | default nil }} + tolerations: {{ .Values.sqlite_web.tolerations | default nil }} volumes: - name: data persistentVolumeClaim: diff --git a/helm-chart/templates/statistics-deployment.yaml b/helm-chart/templates/statistics-deployment.yaml index 808257b6..9fed86ab 100644 --- a/helm-chart/templates/statistics-deployment.yaml +++ b/helm-chart/templates/statistics-deployment.yaml @@ -39,9 +39,9 @@ spec: - mountPath: /usr/share/nginx/html name: statistics readOnly: true - imagePullSecrets: {{ .Values.statistics_dashboard.image.pullSecrets }} - nodeSelector: {{ .Values.statistics_dashboard.nodeSelector }} - tolerations: {{ .Values.core.tolerations }} + imagePullSecrets: {{ .Values.statistics_dashboard.image.pullSecrets | default nil }} + nodeSelector: {{ .Values.statistics_dashboard.nodeSelector | default nil }} + tolerations: {{ .Values.core.tolerations | default nil }} volumes: - name: statistics persistentVolumeClaim: diff --git a/helm-chart/templates/statistics-ingress.yaml b/helm-chart/templates/statistics-ingress.yaml index c7756647..67c8e037 100644 --- a/helm-chart/templates/statistics-ingress.yaml +++ b/helm-chart/templates/statistics-ingress.yaml @@ -4,7 +4,7 @@ kind: Ingress metadata: name: {{ .Release.Name }}-maibot-statistics-dashboard namespace: {{ .Release.Namespace }} - annotations: {{ .Values.statistics_dashboard.ingress.annotations }} + annotations: {{ .Values.statistics_dashboard.ingress.annotations | default nil }} labels: app: {{ .Release.Name }}-maibot-statistics-dashboard spec: diff --git a/helm-chart/templates/statistics-service.yaml b/helm-chart/templates/statistics-service.yaml index 86d0d628..811d3516 100644 --- a/helm-chart/templates/statistics-service.yaml +++ b/helm-chart/templates/statistics-service.yaml @@ -13,7 +13,7 @@ spec: protocol: TCP targetPort: 80 {{- if eq .Values.statistics_dashboard.service.type "nodePort" }} - nodePort: {{ .Values.statistics_dashboard.service.nodePort }} + nodePort: {{ .Values.statistics_dashboard.service.nodePort | default nil }} {{- end }} selector: app: {{ .Release.Name }}-maibot-statistics-dashboard From 59a6b8a623fcf4cf41019cbfc3997bca0060794c Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 03:02:05 +0800 Subject: [PATCH 36/58] =?UTF-8?q?=E5=8F=96=E6=B6=88python=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E7=BC=93=E5=86=B2=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/pre-adapter-cm-gen-job.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helm-chart/templates/pre-adapter-cm-gen-job.yaml b/helm-chart/templates/pre-adapter-cm-gen-job.yaml index 2337f859..9b109f16 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-job.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-job.yaml @@ -22,6 +22,8 @@ spec: args: - adapter-pip-installer.sh env: + - name: PYTHONUNBUFFERED + value: "1" - name: NAMESPACE valueFrom: fieldRef: From 9f34a25076867315f009d0d54beff0ef5b7b3f08 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 03:07:47 +0800 Subject: [PATCH 37/58] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=AE=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/files/adapter-cm-generator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helm-chart/files/adapter-cm-generator.py b/helm-chart/files/adapter-cm-generator.py index 8a3637b0..468d4226 100644 --- a/helm-chart/files/adapter-cm-generator.py +++ b/helm-chart/files/adapter-cm-generator.py @@ -19,8 +19,12 @@ data_b64 = os.getenv("DATA_B64") # 解析并覆盖关键配置 # 这里被覆盖的配置应当在helm chart中针对对应的k8s资源来灵活修改 data = toml.loads(base64.b64decode(data_b64).decode("utf-8")) +if data.get('napcat_server', None) is None: + data['napcat_server'] = {} data['napcat_server']['host'] = '0.0.0.0' data['napcat_server']['port'] = 8095 +if data.get('maibot_server', None) is None: + data['maibot_server'] = {} data['maibot_server']['host'] = f'{release_name}-maibot-core' # 根据release名称动态拼接core服务的DNS名称 data['maibot_server']['port'] = 8000 From 58930f63d232ea06e9d05b1052c1541e91c2a7b5 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 03:15:59 +0800 Subject: [PATCH 38/58] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E7=BB=9F=E8=AE=A1=E7=9C=8B=E6=9D=BF=E6=97=B6=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/files/volume-linker.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helm-chart/files/volume-linker.sh b/helm-chart/files/volume-linker.sh index 944a6e1e..414b9889 100644 --- a/helm-chart/files/volume-linker.sh +++ b/helm-chart/files/volume-linker.sh @@ -24,7 +24,12 @@ if [ -f /MaiMBot/statistics/index.html ] then echo "[VolumeLinker] '/MaiMBot/statistics/index.html' exists." else - touch /MaiMBot/statistics/index.html + if [ -d /MaiMBot/statistics ] + then + touch /MaiMBot/statistics/index.html + else + echo "[VolumeLinker] Statistics volume disabled." + fi fi # 删除空的插件目录,准备创建软链接 From e28b9f9a4704fc87bd6cbeadf0d45d0ec05e7ee3 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 03:20:23 +0800 Subject: [PATCH 39/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-service.yaml | 2 +- helm-chart/templates/napcat-service.yaml | 2 +- helm-chart/templates/sqlite-web-service.yaml | 2 +- helm-chart/templates/statistics-service.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helm-chart/templates/adapter-service.yaml b/helm-chart/templates/adapter-service.yaml index 4df2d31d..86c39246 100644 --- a/helm-chart/templates/adapter-service.yaml +++ b/helm-chart/templates/adapter-service.yaml @@ -11,7 +11,7 @@ spec: port: {{ .Values.adapter.service.port }} protocol: TCP targetPort: 8095 - {{- if eq .Values.adapter.service.type "nodePort" }} + {{- if eq .Values.adapter.service.type "NodePort" }} nodePort: {{ .Values.adapter.service.nodePort | default nil }} {{- end }} selector: diff --git a/helm-chart/templates/napcat-service.yaml b/helm-chart/templates/napcat-service.yaml index 245513d6..ec06b231 100644 --- a/helm-chart/templates/napcat-service.yaml +++ b/helm-chart/templates/napcat-service.yaml @@ -12,7 +12,7 @@ spec: port: {{ .Values.napcat.service.port }} protocol: TCP targetPort: 6099 - {{- if eq .Values.napcat.service.type "nodePort" }} + {{- if eq .Values.napcat.service.type "NodePort" }} nodePort: {{ .Values.napcat.service.nodePort | default nil }} {{- end }} selector: diff --git a/helm-chart/templates/sqlite-web-service.yaml b/helm-chart/templates/sqlite-web-service.yaml index f07c8184..9c9559a9 100644 --- a/helm-chart/templates/sqlite-web-service.yaml +++ b/helm-chart/templates/sqlite-web-service.yaml @@ -12,7 +12,7 @@ spec: port: {{ .Values.sqlite_web.service.port }} protocol: TCP targetPort: 8080 - {{- if eq .Values.sqlite_web.service.type "nodePort" }} + {{- if eq .Values.sqlite_web.service.type "NodePort" }} nodePort: {{ .Values.sqlite_web.service.nodePort | default nil }} {{- end }} selector: diff --git a/helm-chart/templates/statistics-service.yaml b/helm-chart/templates/statistics-service.yaml index 811d3516..c1750894 100644 --- a/helm-chart/templates/statistics-service.yaml +++ b/helm-chart/templates/statistics-service.yaml @@ -12,7 +12,7 @@ spec: port: {{ .Values.statistics_dashboard.service.port }} protocol: TCP targetPort: 80 - {{- if eq .Values.statistics_dashboard.service.type "nodePort" }} + {{- if eq .Values.statistics_dashboard.service.type "NodePort" }} nodePort: {{ .Values.statistics_dashboard.service.nodePort | default nil }} {{- end }} selector: From e63a024fb1dfeeb9cb6ec8f2e2369ab786194742 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 03:29:39 +0800 Subject: [PATCH 40/58] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E9=99=90=E5=88=B6=E7=9A=84=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/sqlite-web-statefulset.yaml | 2 +- helm-chart/templates/statistics-deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/helm-chart/templates/sqlite-web-statefulset.yaml b/helm-chart/templates/sqlite-web-statefulset.yaml index f4bd762a..80ef7c53 100644 --- a/helm-chart/templates/sqlite-web-statefulset.yaml +++ b/helm-chart/templates/sqlite-web-statefulset.yaml @@ -38,7 +38,7 @@ spec: - containerPort: 8080 name: webui protocol: TCP - resources: {{ .Values.sqlite_web.resources }} + resources: {{ .Values.sqlite_web.resources | default nil }} volumeMounts: - mountPath: /data/MaiMBot name: data diff --git a/helm-chart/templates/statistics-deployment.yaml b/helm-chart/templates/statistics-deployment.yaml index 9fed86ab..95a3f4e5 100644 --- a/helm-chart/templates/statistics-deployment.yaml +++ b/helm-chart/templates/statistics-deployment.yaml @@ -34,7 +34,7 @@ spec: - containerPort: 80 name: dashboard protocol: TCP - resources: {{ .Values.statistics_dashboard.resources }} + resources: {{ .Values.statistics_dashboard.resources | default nil }} volumeMounts: - mountPath: /usr/share/nginx/html name: statistics From a4a63abe5c30575bead7d69cbecb2368e0d394ba Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 03:34:14 +0800 Subject: [PATCH 41/58] =?UTF-8?q?fix:=20PVC=E4=BA=8C=E6=AC=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-pvc.yaml | 2 ++ helm-chart/templates/core-pvc.yaml | 2 ++ helm-chart/templates/napcat-pvc.yaml | 2 ++ helm-chart/templates/statistics-pvc.yaml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/helm-chart/templates/adapter-pvc.yaml b/helm-chart/templates/adapter-pvc.yaml index 288ca9b3..a424cdaf 100644 --- a/helm-chart/templates/adapter-pvc.yaml +++ b/helm-chart/templates/adapter-pvc.yaml @@ -8,4 +8,6 @@ spec: resources: requests: storage: {{ .Values.adapter.persistence.size }} + {{- if .Values.adapter.persistence.storageClass }} storageClassName: {{ .Values.adapter.persistence.storageClass | default nil }} + {{- end }} diff --git a/helm-chart/templates/core-pvc.yaml b/helm-chart/templates/core-pvc.yaml index 3c7508cd..38667d38 100644 --- a/helm-chart/templates/core-pvc.yaml +++ b/helm-chart/templates/core-pvc.yaml @@ -8,4 +8,6 @@ spec: resources: requests: storage: {{ .Values.core.persistence.size }} + {{- if .Values.adapter.persistence.storageClass }} storageClassName: {{ .Values.core.persistence.storageClass | default nil }} + {{- end }} diff --git a/helm-chart/templates/napcat-pvc.yaml b/helm-chart/templates/napcat-pvc.yaml index b1a008b3..f2fdec4e 100644 --- a/helm-chart/templates/napcat-pvc.yaml +++ b/helm-chart/templates/napcat-pvc.yaml @@ -9,5 +9,7 @@ spec: resources: requests: storage: {{ .Values.napcat.persistence.size }} + {{- if .Values.adapter.persistence.storageClass }} storageClassName: {{ .Values.napcat.persistence.storageClass | default nil }} + {{- end }} {{- end }} diff --git a/helm-chart/templates/statistics-pvc.yaml b/helm-chart/templates/statistics-pvc.yaml index 783614ab..f1a25a5f 100644 --- a/helm-chart/templates/statistics-pvc.yaml +++ b/helm-chart/templates/statistics-pvc.yaml @@ -9,5 +9,7 @@ spec: resources: requests: storage: {{ .Values.statistics_dashboard.persistence.size }} + {{- if .Values.adapter.persistence.storageClass }} storageClassName: {{ .Values.statistics_dashboard.persistence.storageClass | default nil }} + {{- end }} {{- end }} From 9d3404f9323147f2884299b589f5e249740487ff Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 03:37:44 +0800 Subject: [PATCH 42/58] =?UTF-8?q?fix:=20PVC=E5=90=8D=E7=A7=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-statefulset.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/templates/core-statefulset.yaml b/helm-chart/templates/core-statefulset.yaml index 56f73581..29016726 100644 --- a/helm-chart/templates/core-statefulset.yaml +++ b/helm-chart/templates/core-statefulset.yaml @@ -85,5 +85,5 @@ spec: {{- if .Values.statistics_dashboard.enabled }} - name: statistics persistentVolumeClaim: - claimName: {{ .Release.Name }}-maibot-statistics + claimName: {{ .Release.Name }}-maibot-statistics-dashboard {{- end }} From 8f158f8a59b010cfbae275bbb82ec2352d8ca341 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 03:39:49 +0800 Subject: [PATCH 43/58] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E4=B9=9F=E5=90=8C=E6=AD=A5=E7=94=9F=E6=88=90=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/pre-adapter-cm-gen-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/templates/pre-adapter-cm-gen-job.yaml b/helm-chart/templates/pre-adapter-cm-gen-job.yaml index 9b109f16..b6372c22 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-job.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-job.yaml @@ -5,7 +5,7 @@ metadata: name: {{ .Release.Name }}-maibot-adapter-cm-generator namespace: {{ .Release.Namespace }} annotations: - "helm.sh/hook": post-install + "helm.sh/hook": post-install,post-upgrade "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: backoffLimit: 0 From f933b045b8632a38d437a0b2ed3e5b57fb151a19 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 04:00:13 +0800 Subject: [PATCH 44/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3values=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-statefulset.yaml | 20 +++++++++++++++---- helm-chart/templates/core-statefulset.yaml | 20 +++++++++++++++---- helm-chart/templates/napcat-ingress.yaml | 5 ++++- helm-chart/templates/napcat-statefulset.yaml | 20 +++++++++++++++---- helm-chart/templates/sqlite-web-ingress.yaml | 5 ++++- .../templates/sqlite-web-statefulset.yaml | 20 +++++++++++++++---- .../templates/statistics-deployment.yaml | 20 +++++++++++++++---- helm-chart/templates/statistics-ingress.yaml | 5 ++++- 8 files changed, 92 insertions(+), 23 deletions(-) diff --git a/helm-chart/templates/adapter-statefulset.yaml b/helm-chart/templates/adapter-statefulset.yaml index 998819ae..19c7bdac 100644 --- a/helm-chart/templates/adapter-statefulset.yaml +++ b/helm-chart/templates/adapter-statefulset.yaml @@ -27,7 +27,10 @@ spec: - containerPort: 8095 name: napcat-ws protocol: TCP - resources: {{ .Values.adapter.resources | default nil }} + {{- if .Values.adapter.resources }} + resources: + {{ toYaml .Values.adapter.resources | nindent 12 }} + {{- end }} volumeMounts: - mountPath: /adapters/data name: data @@ -35,9 +38,18 @@ spec: name: config readOnly: true subPath: config.toml - imagePullSecrets: {{ .Values.adapter.image.pullSecrets | default nil }} - nodeSelector: {{ .Values.adapter.nodeSelector | default nil }} - tolerations: {{ .Values.adapter.tolerations | default nil }} + {{- if .Values.adapter.image.pullSecrets }} + imagePullSecrets: + {{ toYaml .Values.adapter.image.pullSecrets | nindent 8 }} + {{- end }} + {{- if .Values.adapter.nodeSelector }} + nodeSelector: + {{ toYaml .Values.adapter.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.adapter.tolerations }} + tolerations: + {{ toYaml .Values.adapter.tolerations | nindent 8 }} + {{- end }} volumes: - name: data persistentVolumeClaim: diff --git a/helm-chart/templates/core-statefulset.yaml b/helm-chart/templates/core-statefulset.yaml index 29016726..9b360c68 100644 --- a/helm-chart/templates/core-statefulset.yaml +++ b/helm-chart/templates/core-statefulset.yaml @@ -35,7 +35,10 @@ spec: - containerPort: 8000 name: adapter-ws protocol: TCP - resources: {{ .Values.core.resources | default nil }} + {{- if .Values.core.resources }} + resources: + {{ toYaml .Values.core.resources | nindent 12 }} + {{- end }} volumeMounts: - mountPath: /MaiMBot/data name: data @@ -59,9 +62,18 @@ spec: - mountPath: /MaiMBot/statistics name: statistics {{- end }} - imagePullSecrets: {{ .Values.core.image.pullSecrets | default nil }} - nodeSelector: {{ .Values.core.nodeSelector | default nil }} - tolerations: {{ .Values.core.tolerations | default nil }} + {{- 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: diff --git a/helm-chart/templates/napcat-ingress.yaml b/helm-chart/templates/napcat-ingress.yaml index 2343ca9c..e46243a2 100644 --- a/helm-chart/templates/napcat-ingress.yaml +++ b/helm-chart/templates/napcat-ingress.yaml @@ -4,7 +4,10 @@ kind: Ingress metadata: name: {{ .Release.Name }}-maibot-napcat namespace: {{ .Release.Namespace }} - annotations: {{ .Values.napcat.ingress.annotations | default nil }} + {{- if .Values.napcat.ingress.annotations }} + annotations: + {{ toYaml .Values.napcat.ingress.annotations | nindent 4 }} + {{- end }} labels: app: {{ .Release.Name }}-maibot-napcat spec: diff --git a/helm-chart/templates/napcat-statefulset.yaml b/helm-chart/templates/napcat-statefulset.yaml index 7969d388..138845f5 100644 --- a/helm-chart/templates/napcat-statefulset.yaml +++ b/helm-chart/templates/napcat-statefulset.yaml @@ -42,7 +42,10 @@ spec: - containerPort: 6099 name: webui protocol: TCP - resources: {{ .Values.napcat.resources | default nil }} + {{- if .Values.napcat.resources }} + resources: + {{ toYaml .Values.napcat.resources | nindent 12 }} + {{- end }} volumeMounts: - mountPath: /app/napcat/config name: napcat @@ -50,9 +53,18 @@ spec: - mountPath: /app/.config/QQ name: napcat subPath: data - imagePullSecrets: {{ .Values.napcat.image.pullSecrets | default nil }} - nodeSelector: {{ .Values.napcat.nodeSelector | default nil }} - tolerations: {{ .Values.napcat.tolerations | default nil }} + {{- if .Values.napcat.image.pullSecrets }} + imagePullSecrets: + {{ toYaml .Values.napcat.image.pullSecrets | nindent 8 }} + {{- end }} + {{- if .Values.napcat.nodeSelector }} + nodeSelector: + {{ toYaml .Values.napcat.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.napcat.tolerations }} + tolerations: + {{ toYaml .Values.napcat.tolerations | nindent 8 }} + {{- end }} volumes: - name: napcat persistentVolumeClaim: diff --git a/helm-chart/templates/sqlite-web-ingress.yaml b/helm-chart/templates/sqlite-web-ingress.yaml index 0bd6a3c4..fe14e744 100644 --- a/helm-chart/templates/sqlite-web-ingress.yaml +++ b/helm-chart/templates/sqlite-web-ingress.yaml @@ -4,7 +4,10 @@ kind: Ingress metadata: name: {{ .Release.Name }}-maibot-sqlite-web namespace: {{ .Release.Namespace }} - annotations: {{ .Values.sqlite_web.ingress.annotations | default nil }} + {{- if .Values.sqlite_web.ingress.annotations }} + annotations: + {{ toYaml .Values.sqlite_web.ingress.annotations | nindent 4 }} + {{- end }} labels: app: {{ .Release.Name }}-maibot-sqlite-web spec: diff --git a/helm-chart/templates/sqlite-web-statefulset.yaml b/helm-chart/templates/sqlite-web-statefulset.yaml index 80ef7c53..b2c9cc47 100644 --- a/helm-chart/templates/sqlite-web-statefulset.yaml +++ b/helm-chart/templates/sqlite-web-statefulset.yaml @@ -38,13 +38,25 @@ spec: - containerPort: 8080 name: webui protocol: TCP - resources: {{ .Values.sqlite_web.resources | default nil }} + {{- if .Values.sqlite_web.resources }} + resources: + {{ toYaml .Values.sqlite_web.resources | nindent 12 }} + {{- end }} volumeMounts: - mountPath: /data/MaiMBot name: data - imagePullSecrets: {{ .Values.sqlite_web.image.pullSecrets | default nil }} - nodeSelector: {{ .Values.sqlite_web.nodeSelector | default nil }} - tolerations: {{ .Values.sqlite_web.tolerations | default nil }} + {{- if .Values.sqlite_web.image.pullSecrets }} + imagePullSecrets: + {{ toYaml .Values.sqlite_web.image.pullSecrets | nindent 8 }} + {{- end }} + {{- if .Values.sqlite_web.nodeSelector }} + nodeSelector: + {{ toYaml .Values.sqlite_web.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.sqlite_web.tolerations }} + tolerations: + {{ toYaml .Values.sqlite_web.tolerations | nindent 8 }} + {{- end }} volumes: - name: data persistentVolumeClaim: diff --git a/helm-chart/templates/statistics-deployment.yaml b/helm-chart/templates/statistics-deployment.yaml index 95a3f4e5..94e7e2c7 100644 --- a/helm-chart/templates/statistics-deployment.yaml +++ b/helm-chart/templates/statistics-deployment.yaml @@ -34,14 +34,26 @@ spec: - containerPort: 80 name: dashboard protocol: TCP - resources: {{ .Values.statistics_dashboard.resources | default nil }} + {{- if .Values.statistics_dashboard.resources }} + resources: + {{ toYaml .Values.statistics_dashboard.resources | nindent 12 }} + {{- end }} volumeMounts: - mountPath: /usr/share/nginx/html name: statistics readOnly: true - imagePullSecrets: {{ .Values.statistics_dashboard.image.pullSecrets | default nil }} - nodeSelector: {{ .Values.statistics_dashboard.nodeSelector | default nil }} - tolerations: {{ .Values.core.tolerations | default nil }} + {{- if .Values.statistics_dashboard.image.pullSecrets }} + imagePullSecrets: + {{ toYaml .Values.statistics_dashboard.image.pullSecrets | nindent 8 }} + {{- end }} + {{- if .Values.statistics_dashboard.nodeSelector }} + nodeSelector: + {{ toYaml .Values.statistics_dashboard.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.statistics_dashboard.tolerations }} + tolerations: + {{ toYaml .Values.statistics_dashboard.tolerations | nindent 8 }} + {{- end }} volumes: - name: statistics persistentVolumeClaim: diff --git a/helm-chart/templates/statistics-ingress.yaml b/helm-chart/templates/statistics-ingress.yaml index 67c8e037..70c18353 100644 --- a/helm-chart/templates/statistics-ingress.yaml +++ b/helm-chart/templates/statistics-ingress.yaml @@ -4,7 +4,10 @@ kind: Ingress metadata: name: {{ .Release.Name }}-maibot-statistics-dashboard namespace: {{ .Release.Namespace }} - annotations: {{ .Values.statistics_dashboard.ingress.annotations | default nil }} + {{- if .Values.statistics_dashboard.ingress.annotations }} + annotations: + {{ toYaml .Values.statistics_dashboard.ingress.annotations | nindent 4 }} + {{- end }} labels: app: {{ .Release.Name }}-maibot-statistics-dashboard spec: From e2c3a2683a66973db2c43bacfb3f80435afacedc Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 04:37:02 +0800 Subject: [PATCH 45/58] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3values=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/adapter-pvc.yaml | 5 ++++- helm-chart/templates/core-pvc.yaml | 5 ++++- helm-chart/templates/napcat-pvc.yaml | 5 ++++- helm-chart/templates/statistics-pvc.yaml | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/helm-chart/templates/adapter-pvc.yaml b/helm-chart/templates/adapter-pvc.yaml index a424cdaf..61778630 100644 --- a/helm-chart/templates/adapter-pvc.yaml +++ b/helm-chart/templates/adapter-pvc.yaml @@ -4,7 +4,10 @@ metadata: name: {{ .Release.Name }}-maibot-adapter namespace: {{ .Release.Namespace }} spec: - accessModes: {{ .Values.adapter.persistence.accessModes }} + {{- if .Values.adapter.persistence.accessModes }} + accessModes: + {{ toYaml .Values.adapter.persistence.accessModes | nindent 4 }} + {{- end }} resources: requests: storage: {{ .Values.adapter.persistence.size }} diff --git a/helm-chart/templates/core-pvc.yaml b/helm-chart/templates/core-pvc.yaml index 38667d38..cf2a1146 100644 --- a/helm-chart/templates/core-pvc.yaml +++ b/helm-chart/templates/core-pvc.yaml @@ -4,7 +4,10 @@ metadata: name: {{ .Release.Name }}-maibot-core namespace: {{ .Release.Namespace }} spec: - accessModes: {{ .Values.core.persistence.accessModes }} + {{- if .Values.core.persistence.accessModes }} + accessModes: + {{ toYaml .Values.core.persistence.accessModes | nindent 4 }} + {{- end }} resources: requests: storage: {{ .Values.core.persistence.size }} diff --git a/helm-chart/templates/napcat-pvc.yaml b/helm-chart/templates/napcat-pvc.yaml index f2fdec4e..7a5bd9b9 100644 --- a/helm-chart/templates/napcat-pvc.yaml +++ b/helm-chart/templates/napcat-pvc.yaml @@ -5,7 +5,10 @@ metadata: name: {{ .Release.Name }}-maibot-napcat namespace: {{ .Release.Namespace }} spec: - accessModes: {{ .Values.napcat.persistence.accessModes }} + {{- if .Values.napcat.persistence.accessModes }} + accessModes: + {{ toYaml .Values.napcat.persistence.accessModes | nindent 4 }} + {{- end }} resources: requests: storage: {{ .Values.napcat.persistence.size }} diff --git a/helm-chart/templates/statistics-pvc.yaml b/helm-chart/templates/statistics-pvc.yaml index f1a25a5f..9e5a86fd 100644 --- a/helm-chart/templates/statistics-pvc.yaml +++ b/helm-chart/templates/statistics-pvc.yaml @@ -5,7 +5,10 @@ metadata: name: {{ .Release.Name }}-maibot-statistics-dashboard namespace: {{ .Release.Namespace }} spec: - accessModes: {{ .Values.statistics_dashboard.persistence.accessModes }} + {{- if .Values.statistics_dashboard.persistence.accessModes }} + accessModes: + {{ toYaml .Values.statistics_dashboard.persistence.accessModes | nindent 4 }} + {{- end }} resources: requests: storage: {{ .Values.statistics_dashboard.persistence.size }} From 7084f403777895b7cd55a3b2a1350b979cfd6fc4 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 12:16:47 +0800 Subject: [PATCH 46/58] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Helm=20Chart=E7=9A=84?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/README.md | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 helm-chart/README.md diff --git a/helm-chart/README.md b/helm-chart/README.md new file mode 100644 index 00000000..cc2898ac --- /dev/null +++ b/helm-chart/README.md @@ -0,0 +1,78 @@ +# MaiBot Helm Chart + +这是麦麦的Helm Chart,可以方便地将麦麦部署在Kubernetes集群中。 + +当前Helm Chart对应的麦麦版本可以在`Chart.yaml`中查看`appVersion`项。 + +## Values项说明 + +`values.yaml`分为几个大部分。 + +1. EULA & PRIVACY: 用户必须同意这里的协议才能成功部署麦麦。 + +2. `adapter`: 麦麦的Adapter的部署配置。 + +3. `core`: 麦麦本体的部署配置。 + +4. `statistics_dashboard`: 麦麦的运行统计看板部署配置。 + + 麦麦每隔一段时间会自动输出html格式的运行统计报告,此统计报告可以部署为看板。 + + 出于隐私考虑,默认禁用。 + +5. `napcat`: Napcat的部署配置。 + + 考虑到复用外部Napcat实例的情况,Napcat部署已被解耦。用户可选是否要部署Napcat。 + + 默认会捆绑部署Napcat。 + +6. `sqlite_web`: sqlite-web的部署配置。 + + 通过sqlite-web可以在网页上操作麦麦的数据库,方便调试。不部署对麦麦的运行无影响。 + + 此服务如果暴露在公网会十分危险,默认不会部署。 + +7. `config`: 这里填写麦麦各部分组件的运行配置文件。 + + 这里填写的配置文件需要严格遵守yaml文件的缩进格式。 + + - `adapter_config`: 对应adapter的`config.toml`。 + + 此配置文件中对于`host`和`port`的配置会被上面`adapter.service`中的配置覆盖,因此不需要改动。 + + - `core_model_config`: 对应core的`model_config.toml`。 + + - `core_bot_config`: 对应core的`bot_config.toml`。 + +## 部署说明 + +使用此Helm Chart的一些注意事项。 + +### 修改麦麦配置 + +麦麦的配置文件会通过ConfigMap资源注入各个组件内。 + +对于通过Helm Chart部署的麦麦,如果需要修改配置,不应该直接修改这些ConfigMap,否则下次Helm更新可能会覆盖掉所有配置。 + +最佳实践是重新配置Helm Chart的values,然后通过`helm upgrade`更新实例。 + +### 动态生成的ConfigMap + +adapter的ConfigMap是每次部署/更新Helm安装实例时动态生成的。 + +动态生成的原因: + +- core服务的DNS名称是动态的,无法在adapter服务的配置文件中提前确定。 +- 一些与k8s现有资源冲突的配置需要被重置。 + +因此,首次部署时,ConfigMap的生成会需要一些时间,部分Pod会无法启动,等待几分钟即可。 + +### 运行统计看板与core的挂载冲突 + +如果启用了运行统计看板,那么statistics_dashboard会与core共同挂载statistics_dashboard存储卷,用于同步html文件。 + +如果k8s集群有多个节点,且statistics_dashboard与core未调度到同一节点,那么就需要statistics_dashboard的PVC访问模式具备`ReadWriteMany`访问模式。 + +不是所有存储卷的底层存储都支持`ReadWriteMany`访问模式。 + +如果你的存储底层无法支持`ReadWriteMany`访问模式,你可以通过`nodeSelector`配置将statistics_dashboard与core调度到同一节点来避免问题。 From bc7e04f6e3787391992ba9bd3aa99b932e77e24b Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 12:23:34 +0800 Subject: [PATCH 47/58] =?UTF-8?q?core=E9=95=9C=E5=83=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index 0acdfb35..37294391 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -39,7 +39,7 @@ core: image: repository: sengokucola/maibot - tag: main-d919c34 + tag: main-a8ff08e pullPolicy: IfNotPresent pullSecrets: [ ] From 2f2fe3cbab01e2d53911b18ba143b6a9b4c61943 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 12:41:55 +0800 Subject: [PATCH 48/58] =?UTF-8?q?fix:=20=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E5=80=BC=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/core-pvc.yaml | 2 +- helm-chart/templates/napcat-pvc.yaml | 2 +- helm-chart/templates/statistics-pvc.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helm-chart/templates/core-pvc.yaml b/helm-chart/templates/core-pvc.yaml index cf2a1146..e7fe15c7 100644 --- a/helm-chart/templates/core-pvc.yaml +++ b/helm-chart/templates/core-pvc.yaml @@ -11,6 +11,6 @@ spec: resources: requests: storage: {{ .Values.core.persistence.size }} - {{- if .Values.adapter.persistence.storageClass }} + {{- if .Values.core.persistence.storageClass }} storageClassName: {{ .Values.core.persistence.storageClass | default nil }} {{- end }} diff --git a/helm-chart/templates/napcat-pvc.yaml b/helm-chart/templates/napcat-pvc.yaml index 7a5bd9b9..530eca72 100644 --- a/helm-chart/templates/napcat-pvc.yaml +++ b/helm-chart/templates/napcat-pvc.yaml @@ -12,7 +12,7 @@ spec: resources: requests: storage: {{ .Values.napcat.persistence.size }} - {{- if .Values.adapter.persistence.storageClass }} + {{- if .Values.napcat.persistence.storageClass }} storageClassName: {{ .Values.napcat.persistence.storageClass | default nil }} {{- end }} {{- end }} diff --git a/helm-chart/templates/statistics-pvc.yaml b/helm-chart/templates/statistics-pvc.yaml index 9e5a86fd..74b698ce 100644 --- a/helm-chart/templates/statistics-pvc.yaml +++ b/helm-chart/templates/statistics-pvc.yaml @@ -12,7 +12,7 @@ spec: resources: requests: storage: {{ .Values.statistics_dashboard.persistence.size }} - {{- if .Values.adapter.persistence.storageClass }} + {{- if .Values.statistics_dashboard.persistence.storageClass }} storageClassName: {{ .Values.statistics_dashboard.persistence.storageClass | default nil }} {{- end }} {{- end }} From f5162564df39fcbf3a83c42003c0a185135e62af Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 12:42:12 +0800 Subject: [PATCH 49/58] =?UTF-8?q?=E4=BC=98=E5=8C=96shell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/files/volume-linker.sh | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/helm-chart/files/volume-linker.sh b/helm-chart/files/volume-linker.sh index 414b9889..86882968 100644 --- a/helm-chart/files/volume-linker.sh +++ b/helm-chart/files/volume-linker.sh @@ -8,28 +8,13 @@ set -e echo "[VolumeLinker]Preparing volume..." # 初次启动,在存储卷中检查并创建关键文件和目录 -if [ -d /MaiMBot/data/plugins ] +mkdir -p /MaiMBot/data/plugins +mkdir -p /MaiMBot/data/logs +if [ ! -d "/MaiMBot/statistics" ] then - echo "[VolumeLinker] '/MaiMBot/data/plugins' exists." + echo "[VolumeLinker] Statistics volume disabled." else - mkdir /MaiMBot/data/plugins -fi -if [ -d /MaiMBot/data/logs ] -then - echo "[VolumeLinker] '/MaiMBot/data/logs' exists." -else - mkdir /MaiMBot/data/logs -fi -if [ -f /MaiMBot/statistics/index.html ] -then - echo "[VolumeLinker] '/MaiMBot/statistics/index.html' exists." -else - if [ -d /MaiMBot/statistics ] - then - touch /MaiMBot/statistics/index.html - else - echo "[VolumeLinker] Statistics volume disabled." - fi + touch /MaiMBot/statistics/index.html fi # 删除空的插件目录,准备创建软链接 From a58919d906fa3f08671d37592c08ea097bf51554 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Wed, 20 Aug 2025 12:51:43 +0800 Subject: [PATCH 50/58] =?UTF-8?q?fix:=20=E7=A6=81=E7=94=A8=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E7=9C=8B=E6=9D=BF=E9=80=A0=E6=88=90=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/files/volume-linker.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helm-chart/files/volume-linker.sh b/helm-chart/files/volume-linker.sh index 86882968..bd897537 100644 --- a/helm-chart/files/volume-linker.sh +++ b/helm-chart/files/volume-linker.sh @@ -23,7 +23,10 @@ rm -rf /MaiMBot/plugins # 创建软链接,从存储卷链接到实际位置 ln -s /MaiMBot/data/plugins /MaiMBot/plugins ln -s /MaiMBot/data/logs /MaiMBot/logs -ln -s /MaiMBot/statistics/index.html /MaiMBot/maibot_statistics.html +if [ -f "/MaiMBot/statistics/index.html" ] +then + ln -s /MaiMBot/statistics/index.html /MaiMBot/maibot_statistics.html +fi # 启动麦麦 echo "[VolumeLinker]Starting MaiBot..." From c8890ea8e4122c5f593df8d89f90399e1fbccf26 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Thu, 21 Aug 2025 12:00:22 +0800 Subject: [PATCH 51/58] =?UTF-8?q?=E6=9E=84=E5=BB=BAadapter-cm-generator?= =?UTF-8?q?=E7=9A=84=E9=95=9C=E5=83=8F=EF=BC=8C=E6=8F=90=E5=8D=87=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/.helmignore | 1 + helm-chart/adapter-cm-generator/Dockerfile | 10 +++++++ .../adapter-cm-generator.py | 0 .../adapter-cm-generator/requirements.txt | 2 ++ helm-chart/files/adapter-pip-installer.sh | 5 ---- .../templates/pre-adapter-cm-gen-job.yaml | 26 ++----------------- helm-chart/templates/scripts-configmap.yaml | 6 ----- helm-chart/values.yaml | 9 +++++++ 8 files changed, 24 insertions(+), 35 deletions(-) create mode 100644 helm-chart/.helmignore create mode 100644 helm-chart/adapter-cm-generator/Dockerfile rename helm-chart/{files => adapter-cm-generator}/adapter-cm-generator.py (100%) create mode 100644 helm-chart/adapter-cm-generator/requirements.txt delete mode 100644 helm-chart/files/adapter-pip-installer.sh diff --git a/helm-chart/.helmignore b/helm-chart/.helmignore new file mode 100644 index 00000000..015ae876 --- /dev/null +++ b/helm-chart/.helmignore @@ -0,0 +1 @@ +adapter-cm-generator \ No newline at end of file diff --git a/helm-chart/adapter-cm-generator/Dockerfile b/helm-chart/adapter-cm-generator/Dockerfile new file mode 100644 index 00000000..7c6c802f --- /dev/null +++ b/helm-chart/adapter-cm-generator/Dockerfile @@ -0,0 +1,10 @@ +# 此镜像用于在部署helm chart时动态生成adapter的配置文件 +FROM python:slim + +WORKDIR /app + +COPY . /app + +RUN pip3 install --no-cache-dir -i https://mirrors.ustc.edu.cn/pypi/simple -r requirements.txt + +ENTRYPOINT ["python3", "adapter-cm-generator.py"] diff --git a/helm-chart/files/adapter-cm-generator.py b/helm-chart/adapter-cm-generator/adapter-cm-generator.py similarity index 100% rename from helm-chart/files/adapter-cm-generator.py rename to helm-chart/adapter-cm-generator/adapter-cm-generator.py diff --git a/helm-chart/adapter-cm-generator/requirements.txt b/helm-chart/adapter-cm-generator/requirements.txt new file mode 100644 index 00000000..50e16366 --- /dev/null +++ b/helm-chart/adapter-cm-generator/requirements.txt @@ -0,0 +1,2 @@ +toml +kubernetes \ No newline at end of file diff --git a/helm-chart/files/adapter-pip-installer.sh b/helm-chart/files/adapter-pip-installer.sh deleted file mode 100644 index 47564820..00000000 --- a/helm-chart/files/adapter-pip-installer.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# 这个脚本的作用是安装必要的python包,为adapter-cm-generator.py脚本做准备 - -pip3 install -i https://mirrors.ustc.edu.cn/pypi/simple kubernetes toml -python3 adapter-cm-generator.py diff --git a/helm-chart/templates/pre-adapter-cm-gen-job.yaml b/helm-chart/templates/pre-adapter-cm-gen-job.yaml index b6372c22..14bc6154 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-job.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-job.yaml @@ -14,13 +14,9 @@ spec: serviceAccountName: {{ .Release.Name }}-maibot-adapter-cm-generator restartPolicy: Never containers: - - name: python - image: python:slim + - name: adapter-cm-generator + image: {{ .Values.adapter.cm_generator.image.repository }}:{{ .Values.adapter.cm_generator.image.tag }} workingDir: /app - command: - - sh - args: - - adapter-pip-installer.sh env: - name: PYTHONUNBUFFERED value: "1" @@ -32,21 +28,3 @@ spec: value: {{ .Release.Name }} - name: DATA_B64 value: {{ .Values.config.adapter_config | b64enc }} # 将配置文件编码为base64,从环境变量注入 - volumeMounts: - - mountPath: /app/adapter-pip-installer.sh - name: scripts - readOnly: true - subPath: adapter-pip-installer.sh - - mountPath: /app/adapter-cm-generator.py - name: scripts - readOnly: true - subPath: adapter-cm-generator.py - volumes: - - name: scripts - configMap: - name: {{ .Release.Name }}-maibot-scripts - items: - - key: adapter-pip-installer.sh - path: adapter-pip-installer.sh - - key: adapter-cm-generator.py - path: adapter-cm-generator.py diff --git a/helm-chart/templates/scripts-configmap.yaml b/helm-chart/templates/scripts-configmap.yaml index 6eb0c4db..aa6fa11f 100644 --- a/helm-chart/templates/scripts-configmap.yaml +++ b/helm-chart/templates/scripts-configmap.yaml @@ -4,12 +4,6 @@ metadata: name: {{ .Release.Name }}-maibot-scripts namespace: {{ .Release.Namespace }} data: - # pre-install hook - adapter-pip-installer.sh: | - {{ .Files.Get "files/adapter-pip-installer.sh" | nindent 4 }} - adapter-cm-generator.py: | - {{ .Files.Get "files/adapter-cm-generator.py" | nindent 4 }} - # core volume-linker.sh: | {{ .Files.Get "files/volume-linker.sh" | nindent 4 }} diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml index 37294391..5f127089 100644 --- a/helm-chart/values.yaml +++ b/helm-chart/values.yaml @@ -34,6 +34,15 @@ adapter: - ReadWriteOnce size: 1Gi + # adapter的动态生成configmap的Job的配置 + cm_generator: + image: + repository: reg.mikumikumi.xyz/maibot/adapter-cm-generator + tag: 0.10.0-alpha.0 + pullPolicy: IfNotPresent + pullSecrets: [ ] + + # 麦麦本体的部署配置 core: From be189707715ef0dfc6e9d6e632311a976276af76 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Thu, 21 Aug 2025 13:13:12 +0800 Subject: [PATCH 52/58] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96Helm=20Chart?= =?UTF-8?q?=E6=89=93=E5=8C=85=E5=92=8C=E5=8F=91=E5=B8=83=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/.gitlab-ci.yml | 36 ++++++++++++++++++++++++++++++++++++ helm-chart/.helmignore | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 helm-chart/.gitlab-ci.yml diff --git a/helm-chart/.gitlab-ci.yml b/helm-chart/.gitlab-ci.yml new file mode 100644 index 00000000..fec489e9 --- /dev/null +++ b/helm-chart/.gitlab-ci.yml @@ -0,0 +1,36 @@ +stages: + - build + - package + +# 将Helm Chart版本作为tag,构建并推送镜像 +build-adapter-cm-generator: + stage: build + image: reg.mikumikumi.xyz/base/kaniko-builder:latest + rules: + - changes: + - helm-chart/files/** + - helm-chart/templates/** + - helm-chart/Chart.yaml + - helm-chart/values.yaml + variables: + BUILD_CONTEXT: helm-chart/adapter-cm-generator + BUILD_DESTINATION: reg.mikumikumi.xyz/maibot/adapter-cm-generator + script: + - export BUILD_CONTEXT=helm-chart/adapter-cm-generator + - export TMP_DST=reg.mikumikumi.xyz/maibot/adapter-cm-generator + - export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep version | cut -d' ' -f2) + - export BUILD_ARGS="--destination ${TMP_DST}:${CHART_VERSION} --destination ${TMP_DST}:latest" + - build + +# 打包并推送helm chart +package-helm-chart: + stage: package + image: reg.mikumikumi.xyz/mirror/helm:latest + rules: + - changes: + - helm-chart/adapter-cm-generator/** + script: + - export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep version | cut -d' ' -f2) + - helm registry login reg.mikumikumi.xyz --username ${HARBOR_USERNAME} --password ${HARBOR_PASSWORD} + - helm package helm-chart + - helm push maibot-${CHART_VERSION}.tgz oci://reg.mikumikumi.xyz/maibot diff --git a/helm-chart/.helmignore b/helm-chart/.helmignore index 015ae876..8cb2bba7 100644 --- a/helm-chart/.helmignore +++ b/helm-chart/.helmignore @@ -1 +1,2 @@ -adapter-cm-generator \ No newline at end of file +adapter-cm-generator +.gitlab-ci.yml \ No newline at end of file From bce8a82f2a28ed09745b65bebe03fa9508d44d92 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Thu, 21 Aug 2025 13:15:01 +0800 Subject: [PATCH 53/58] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A9=BA=E8=A1=8C?= =?UTF-8?q?=EF=BC=8C=E7=AC=A6=E5=90=88POSIX=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/Chart.yaml b/helm-chart/Chart.yaml index aaa8a215..9c908f64 100644 --- a/helm-chart/Chart.yaml +++ b/helm-chart/Chart.yaml @@ -3,4 +3,4 @@ name: maibot description: "Maimai Bot, a cyber friend dedicated to group chats" type: application version: 0.10.0-alpha.0 -appVersion: 0.10.0-alpha \ No newline at end of file +appVersion: 0.10.0-alpha From 11113512103abe06428691002b2dc967adf785e3 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Thu, 21 Aug 2025 14:25:24 +0800 Subject: [PATCH 54/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9CI=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/.gitlab-ci.yml b/helm-chart/.gitlab-ci.yml index fec489e9..e63c14fb 100644 --- a/helm-chart/.gitlab-ci.yml +++ b/helm-chart/.gitlab-ci.yml @@ -31,6 +31,6 @@ package-helm-chart: - helm-chart/adapter-cm-generator/** script: - export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep version | cut -d' ' -f2) - - helm registry login reg.mikumikumi.xyz --username ${HARBOR_USERNAME} --password ${HARBOR_PASSWORD} + - helm registry login reg.mikumikumi.xyz --username ${CI_REGISTRY_USER} --password ${CI_REGISTRY_PASSWORD} - helm package helm-chart - helm push maibot-${CHART_VERSION}.tgz oci://reg.mikumikumi.xyz/maibot From bc513dc88c3942c4140bc2b4f279aec1501e26f4 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Thu, 21 Aug 2025 15:33:59 +0800 Subject: [PATCH 55/58] =?UTF-8?q?fix:=20CI=E6=96=87=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/.gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/helm-chart/.gitlab-ci.yml b/helm-chart/.gitlab-ci.yml index e63c14fb..346f9250 100644 --- a/helm-chart/.gitlab-ci.yml +++ b/helm-chart/.gitlab-ci.yml @@ -8,10 +8,7 @@ build-adapter-cm-generator: image: reg.mikumikumi.xyz/base/kaniko-builder:latest rules: - changes: - - helm-chart/files/** - - helm-chart/templates/** - - helm-chart/Chart.yaml - - helm-chart/values.yaml + - helm-chart/adapter-cm-generator/** variables: BUILD_CONTEXT: helm-chart/adapter-cm-generator BUILD_DESTINATION: reg.mikumikumi.xyz/maibot/adapter-cm-generator @@ -28,7 +25,10 @@ package-helm-chart: image: reg.mikumikumi.xyz/mirror/helm:latest rules: - changes: - - helm-chart/adapter-cm-generator/** + - helm-chart/files/** + - helm-chart/templates/** + - helm-chart/Chart.yaml + - helm-chart/values.yaml script: - export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep version | cut -d' ' -f2) - helm registry login reg.mikumikumi.xyz --username ${CI_REGISTRY_USER} --password ${CI_REGISTRY_PASSWORD} From a065da1613170159ed5758cd3584703b28d56839 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Thu, 21 Aug 2025 15:38:36 +0800 Subject: [PATCH 56/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9job=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E6=AC=A1=E6=95=B0=E4=B8=BA2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/templates/pre-adapter-cm-gen-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-chart/templates/pre-adapter-cm-gen-job.yaml b/helm-chart/templates/pre-adapter-cm-gen-job.yaml index 14bc6154..f9a6efdc 100644 --- a/helm-chart/templates/pre-adapter-cm-gen-job.yaml +++ b/helm-chart/templates/pre-adapter-cm-gen-job.yaml @@ -8,7 +8,7 @@ metadata: "helm.sh/hook": post-install,post-upgrade "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: - backoffLimit: 0 + backoffLimit: 2 template: spec: serviceAccountName: {{ .Release.Name }}-maibot-adapter-cm-generator From cb188f62e158aebfe909453306f79a7350446eb1 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Thu, 21 Aug 2025 15:42:08 +0800 Subject: [PATCH 57/58] =?UTF-8?q?=E4=BF=AE=E6=94=B9CI=E4=B8=AD=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=87=BA=E7=8E=B0=E7=9A=84=E8=BF=87=E6=BB=A4=E6=AD=A7?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/.gitlab-ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/helm-chart/.gitlab-ci.yml b/helm-chart/.gitlab-ci.yml index 346f9250..5a5a2f73 100644 --- a/helm-chart/.gitlab-ci.yml +++ b/helm-chart/.gitlab-ci.yml @@ -9,13 +9,10 @@ build-adapter-cm-generator: rules: - changes: - helm-chart/adapter-cm-generator/** - variables: - BUILD_CONTEXT: helm-chart/adapter-cm-generator - BUILD_DESTINATION: reg.mikumikumi.xyz/maibot/adapter-cm-generator script: - export BUILD_CONTEXT=helm-chart/adapter-cm-generator - export TMP_DST=reg.mikumikumi.xyz/maibot/adapter-cm-generator - - export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep version | cut -d' ' -f2) + - export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep '^version:' | cut -d' ' -f2) - export BUILD_ARGS="--destination ${TMP_DST}:${CHART_VERSION} --destination ${TMP_DST}:latest" - build @@ -30,7 +27,7 @@ package-helm-chart: - helm-chart/Chart.yaml - helm-chart/values.yaml script: - - export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep version | cut -d' ' -f2) + - export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep '^version:' | cut -d' ' -f2) - helm registry login reg.mikumikumi.xyz --username ${CI_REGISTRY_USER} --password ${CI_REGISTRY_PASSWORD} - helm package helm-chart - helm push maibot-${CHART_VERSION}.tgz oci://reg.mikumikumi.xyz/maibot From 4efebed10aad977155d3d9e0c24bc6e14e1260ab Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Thu, 21 Aug 2025 15:44:36 +0800 Subject: [PATCH 58/58] =?UTF-8?q?=E4=BC=98=E5=8C=96Python=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/adapter-cm-generator/adapter-cm-generator.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/helm-chart/adapter-cm-generator/adapter-cm-generator.py b/helm-chart/adapter-cm-generator/adapter-cm-generator.py index 468d4226..d2370daf 100644 --- a/helm-chart/adapter-cm-generator/adapter-cm-generator.py +++ b/helm-chart/adapter-cm-generator/adapter-cm-generator.py @@ -19,12 +19,10 @@ data_b64 = os.getenv("DATA_B64") # 解析并覆盖关键配置 # 这里被覆盖的配置应当在helm chart中针对对应的k8s资源来灵活修改 data = toml.loads(base64.b64decode(data_b64).decode("utf-8")) -if data.get('napcat_server', None) is None: - data['napcat_server'] = {} +data.setdefault('napcat_server', {}) data['napcat_server']['host'] = '0.0.0.0' data['napcat_server']['port'] = 8095 -if data.get('maibot_server', None) is None: - data['maibot_server'] = {} +data.setdefault('maibot_server', {}) data['maibot_server']['host'] = f'{release_name}-maibot-core' # 根据release名称动态拼接core服务的DNS名称 data['maibot_server']['port'] = 8000