-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
en deploy astrbot kubernetes
Warning
You can deploy AstrBot in a high-availability setup using Kubernetes (K8s), allowing it to automatically recover from failures.
Due to the current use of an SQLite database, this deployment does not support horizontal scaling with multiple replicas. Additionally, if using the Sidecar mode, pay special attention to the persistence of NapCat's login state.
The following tutorial assumes that you have kubectl installed and configured, and that you can connect to your K8s cluster.
Before you begin, make sure your Kubernetes cluster meets the following conditions:
-
Default StorageClass: Used to dynamically create
PersistentVolumeClaim(PVC). You can check this withkubectl get sc. If you don't have one, you need to manually create aPersistentVolume(PV) or install a corresponding storage plugin (e.g.,nfs-client-provisioner). -
Network Access: Ensure that your cluster nodes can pull images from
docker.ioor your specified image repository.
We offer two deployment options:
- Integrated Deployment (Sidecar Mode): Deploy AstrBot and NapCat in the same Pod. Recommended for personal QQ accounts.
- Standalone Deployment: Deploy only AstrBot. Suitable for other platforms or if you want to manage NapCat independently.
This method is located in the k8s/astrbot_with_napcat directory.
# 1. Create namespace
kubectl apply -f k8s/astrbot_with_napcat/00-namespace.yaml
# 2. Create Persistent Volume Claim
# Note: astrbot-data-shared-pvc requires ReadWriteMany (RWX) access mode.
# If your cluster does not support RWX, you need to configure shared storage such as NFS and modify the storageClassName in 01-pvc.yaml.
kubectl apply -f k8s/astrbot_with_napcat/01-pvc.yaml
# 3. Deploy the application
kubectl apply -f k8s/astrbot_with_napcat/02-deployment.yaml-
Option A: NodePort
kubectl apply -f k8s/astrbot_with_napcat/03-service-nodeport.yaml
The service will be exposed via the node IP and a port automatically assigned by Kubernetes. You can find the port with the following command:
kubectl get svc -n astrbot-ns
In the output, find the
PORT(S)column forastrbot-webui-svcandnapcat-web-svc. The format is<internal-port>:<NodePort>/TCP. For example, if you see8080:30185/TCP, the access address ishttp://<NodeIP>:30185. -
Option B: LoadBalancer
If your cluster supports
LoadBalancertype services (usually provided in K8s services from cloud providers), you can use this method.kubectl apply -f k8s/astrbot_with_napcat/04-service-loadbalancer.yaml
After execution, check the assigned external IP (EXTERNAL-IP) with
kubectl get svc -n astrbot-ns.
Since AstrBot and NapCat are in the same Pod, they can communicate directly via localhost.
-
Add a message platform in AstrBot:
- Go to the AstrBot WebUI, select
Platform->Add. -
Select Message Platform Category:
aiocqhttp -
Bot Name:
napcat(or custom) -
Reverse Websocket Host:
0.0.0.0 -
Reverse Websocket Port:
6199 - Save the configuration.
- Go to the AstrBot WebUI, select
-
Configure Websocket Client in NapCat:
- Go to the NapCat WebUI, select
Settings->Reverse WS->Add. - Enable: On
-
URL:
ws://localhost:6199/ws -
Message Format:
Array - Save the configuration.
- Go to the NapCat WebUI, select
This method is located in the k8s/astrbot directory.
# 1. Create namespace
kubectl apply -f k8s/astrbot/00-namespace.yaml
# 2. Create Persistent Volume Claim
kubectl apply -f k8s/astrbot/01-pvc.yaml
# 3. Deploy the application
kubectl apply -f k8s/astrbot/02-deployment.yaml-
Option A: NodePort
kubectl apply -f k8s/astrbot/03-service-nodeport.yaml
The service will be exposed via the node IP and a port automatically assigned by Kubernetes. You can find the port with the following command:
kubectl get svc -n astrbot-standalone-ns
In the output, find the
PORT(S)column forastrbot-webui-svc. The format is<internal-port>:<NodePort>/TCP. For example, if you see8080:30185/TCP, the access address ishttp://<NodeIP>:30185. -
Option B: LoadBalancer
kubectl apply -f k8s/astrbot/04-service-loadbalancer.yaml
After execution, check the assigned external IP (EXTERNAL-IP) with
kubectl get svc -n astrbot-standalone-ns.
If you have difficulty pulling the soulter/astrbot:latest or mlikiowa/napcat-docker:latest images, you can manually edit the corresponding 02-deployment.yaml file and replace the image field with a domestic mirror address, for example:
# Example:
# image: soulter/astrbot:latest
# Replace with:
image: m.daocloud.io/docker.io/soulter/astrbot:latestIf you need to use the sandbox code executor, you need to mount the Docker socket file into the Pod.
Edit the 02-deployment.yaml file and add volumes and volumeMounts under spec.template.spec:
-
Add the following to the
volumeMountslist of theastrbotcontainer:- name: docker-sock mountPath: /var/run/docker.sock
-
Add the following to the
spec.template.spec.volumeslist:- name: docker-sock hostPath: path: /var/run/docker.sock type: Socket
Warning
Mounting the Docker socket into a Pod poses a security risk. Please ensure you understand the implications.
-
Sidecar Deployment Mode:
# View AstrBot logs kubectl logs -f -n astrbot-ns deployment/astrbot-stack -c astrbot # View NapCat logs kubectl logs -f -n astrbot-ns deployment/astrbot-stack -c napcat
-
Standalone Deployment Mode:
kubectl logs -f -n astrbot-standalone-ns deployment/astrbot-standalone
After deploying and exposing the service, you can access the AstrBot admin panel through the corresponding IP and port.
New users must use the random password printed in the startup logs for the first login. Use the username shown in the logs (usually
astrbot) and change it after logging in.
- 首页
- 文档入口
- Top Level
- community events
- deploy
- dev
- others
- platform
- 接入 OneBot v11 协议实现
- 接入钉钉 DingTalk
- 接入 Discord
- 接入 Kook
- 接入飞书
- 接入 LINE
- 接入 Matrix
- 接入 Mattermost
- 接入 Misskey 平台
- 接入 QQ 官方机器人平台
- 通过 QQ官方机器人 接入 QQ (Webhook)
- 通过 QQ官方机器人 接入 QQ (Websockets)
- 接入 Satori 协议
- 接入 server-satori (基于 Koishi)
- 接入 Slack
- 接入消息平台
- 接入 Telegram
- 接入 VoceChat
- AstrBot 接入企业微信
- 接入企业微信智能机器人平台
- AstrBot 接入微信公众平台
- 接入个人微信
- providers
- use
- Home
- Docs Entry
- Top Level
- config
- deploy
- Deploy AstrBot on 1Panel
- Deploy AstrBot on BT Panel
- Deploy AstrBot on CasaOS
- Deploy AstrBot from Source Code
- Community-Provided Deployment Methods
- Deploy via Compshare
- Deploy with AstrBot Desktop Client
- Deploy AstrBot with Docker
- Deploy AstrBot with Kubernetes
- Deploy AstrBot with AstrBot Launcher
- Other Deployments
- Package Manager Deployment (uv)
- Installation via System Package Manager
- Preface
- dev
- AstrBot Configuration File
- AstrBot HTTP API
- Developing a Platform Adapter
- plugin
- AI
- Text to Image
- Handling Message Events
- Plugin Configuration
- Plugin Internationalization
- Plugin Pages
- Sending Messages
- Session Control
- Minimal Example
- Plugin Storage
- AstrBot Plugin Development Guide 🌠
- Publishing Plugins to the Plugin Marketplace
- ospp
- others
- platform
- Connect OneBot v11 Protocol Implementations
- Connect to DingTalk
- Connecting to Discord
- Connect to KOOK
- Connecting to Lark
- Connecting to LINE
- Connecting to Matrix
- Connecting to Mattermost
- Connecting to Misskey Platform
- Connect QQ Official Bot
- Connect QQ via QQ Official Bot (Webhook)
- Connect QQ via QQ Official Bot (Websockets)
- Connect to Satori Protocol
- Connect server-satori (Koishi)
- Connecting to Slack
- Messaging Platforms
- Connecting to Telegram
- Connect to VoceChat
- Connect AstrBot to WeCom
- Connect to WeCom AI Bot Platform
- Connect AstrBot to WeChat Official Account Platform
- Connect Personal WeChat
- providers
- Connect 302.AI
- Agent Runners
- Built-in Agent Runner
- Connect to Coze
- Connect to Alibaba Cloud Bailian Application
- Connect to DeerFlow
- Connect to Dify
- Connect AIHubMix
- coze
- dashscope
- dify
- 大语言模型提供商
- NewAPI
- Connect PPIO Cloud
- Connect LM Studio to Use DeepSeek-R1 and Other Models
- Integrating Ollama
- Connecting to SiliconFlow
- Connecting Model Services
- Connecting to TokenPony
- use
- Agent Runner
- Agent Sandbox Environment ⛵️
- astrbot sandbox
- Docker-based Code Interpreter
- Built-in Commands
- Computer Use
- Context Compression
- Custom Rules
- Function Calling
- AstrBot Knowledge Base
- MCP
- AstrBot Star
- Proactive Capabilities
- Anthropic Skills
- Agent Handoff and SubAgent
- Unified Webhook Mode
- Web Search
- WebUI