Deploy WuKongIM multi-node cluster in Kubernetes cluster, providing high availability, disaster recovery capability and load balancing.
Deployment Features
Advantages:
- High availability and strong disaster recovery capability
- Supports online scaling
- Real-time automatic backup between multiple replicas
- Load balancing without manual configuration
- Fast scaling
Applicable scenarios:
- Applications with high data security requirements
- Large applications
- Enterprise production environments
Note: WuKongIM currently supports hot scaling but does not support hot shrinking!
Prerequisites
- Kubernetes cluster 1.19+
- kubectl configured and able to access cluster
- Helm 3.0+
- At least 3 worker nodes, each with 4GB+ memory and 2 CPU cores
Deployment Steps
1. Add Helm Repository
helm repo add wukongim https://wukongim.github.io/helm/
2. Update Helm Repository
3. Search Available Charts
helm search repo wukongim
4. Deploy WuKongIM Multi-Node Cluster
# Multi-node deployment (replica count is 3)
helm install wkim wukongim/wukongim \
-n wukongim \
--create-namespace \
--version 0.1.0 \
--set replicaCount=3
Optional parameters:
replicaCount=3: Number of replicas (default is 2)
externalIP=<IP_ADDRESS>: External IP address
5. Check Installation Status
helm status wkim -n wukongim
6. Verify Deployment
# Check Pod status
kubectl get pods -n wukongim
# Check service status
kubectl get svc -n wukongim
# Check cluster status
kubectl port-forward svc/wkim-wukongim 5001:5001 -n wukongim &
curl http://localhost:5001/cluster/nodes
Access Services
Port Forward Access
# API service
kubectl port-forward svc/wkim-wukongim 5001:5001 -n wukongim
# WebSocket service
kubectl port-forward svc/wkim-wukongim 5200:5200 -n wukongim
# Demo interface
kubectl port-forward svc/wkim-wukongim 5172:5172 -n wukongim
# Management interface
kubectl port-forward svc/wkim-wukongim 5300:5300 -n wukongim
Access URLs
Configuration Options
Common Helm Parameters
# Complete configuration example
helm install wkim wukongim/wukongim \
-n wukongim \
--create-namespace \
--version 0.1.0 \
--set replicaCount=3 \
--set image.tag=v2.0.0 \
--set service.type=LoadBalancer \
--set persistence.enabled=true \
--set persistence.size=50Gi \
--set resources.requests.memory=4Gi \
--set resources.requests.cpu=2000m
Main Configuration Parameters
| Parameter | Description | Default Value |
|---|
replicaCount | Number of replicas | 2 |
image.tag | Image version | latest |
service.type | Service type | ClusterIP |
persistence.enabled | Enable persistent storage | true |
persistence.size | Storage size | 10Gi |
externalIP | External IP address | "" |
Scaling Operations
Scale Cluster
# Scale to 5 replicas
helm upgrade wkim wukongim/wukongim \
-n wukongim \
--version 0.1.0 \
--set replicaCount=5
Verify Scaling
# Check Pod count
kubectl get pods -n wukongim
# Check cluster status
kubectl port-forward svc/wkim-wukongim 5001:5001 -n wukongim &
curl http://localhost:5001/cluster/nodes
# View cluster node information
curl http://localhost:5001/cluster/nodes | jq '.'
Troubleshooting
Common Issues
Pod startup failure:
# Check Pod status
kubectl get pods -n wukongim
# View detailed information
kubectl describe pod <pod-name> -n wukongim
# View logs
kubectl logs <pod-name> -n wukongim
Cluster nodes cannot communicate:
# Check network connectivity
kubectl exec -it <pod-name> -n wukongim -- ping <other-pod-ip>
# Check cluster ports
kubectl exec -it <pod-name> -n wukongim -- netstat -tulpn | grep 11110
# View cluster status
kubectl logs <pod-name> -n wukongim | grep cluster
Service inaccessible:
# Check service status
kubectl get svc -n wukongim
# Check endpoints
kubectl get endpoints -n wukongim
# Test service connectivity
kubectl exec -it <pod-name> -n wukongim -- wget -qO- http://localhost:5001/health
Log Viewing
# View real-time logs
kubectl logs -f deployment/wkim-wukongim -n wukongim
# View all replica logs
kubectl logs -l app.kubernetes.io/name=wukongim -n wukongim
# View historical logs
kubectl logs deployment/wkim-wukongim -n wukongim --previous
Upgrade and Maintenance
Version Upgrade
# Update Helm repository
helm repo update
# Search for new versions
helm search repo wukongim
# Upgrade to new version
helm upgrade wkim wukongim/wukongim \
-n wukongim \
--version <new_version>
Data Backup
# Create data snapshot
kubectl exec -n wukongim deployment/wkim-wukongim -- \
tar czf /tmp/backup-$(date +%Y%m%d).tar.gz /data
# Copy backup file to local
kubectl cp wukongim/<pod-name>:/tmp/backup-$(date +%Y%m%d).tar.gz \
./wukongim-backup-$(date +%Y%m%d).tar.gz
Uninstall
# Uninstall WuKongIM
helm uninstall wkim -n wukongim
# Delete namespace (optional)
kubectl delete namespace wukongim
Next Steps