问题:kubectl get po -n kubesphere-logging-system
容器组状态显示 Error

分析:Curator 是定时清理 es index 的 CronJob 组件。一般 Curator出错都和 es 集群状态异常有关(kubesphere 日志服务也会受到影响)。先查看 curator 的日志:
kubectl logs -n kubesphere-logging-system <YOUR_CURATOR_POD>
这里看到提示 elasticsearch connection 错误:


进入 es pod 查看集群状态:
kubectl exec -it -n kubesphere-logging-system elasticsearch-logging-data-0 /bin/sh
检查集群健康:
# index status
curl localhost:9200/_cat/indices?v
# cluster health
curl localhost:9200/_cluster/health?pretty
# shard status
curl localhost:9200/_cat/shards?v
发现无法获取 index 信息,集群状态是 yellow,且存在大量 unassigned shards:

这说明分片数量大于节点数量。此时需要扩容 es 数据节点,使节点数量大于等于分片数 + 1:
kubectl scale -n kubesphere-logging-system sts elasticsearch-logging-data --replicas=<N+1>
另外,要检查 es cluster 的 setting,我的有问题的环境还发现,分片规则里错误地排除了 elasticsearch-logging-data-0
curl localhost:9200/_cluster/settings

curl -XPUT 'localhost:9200/_cluster/settings' -d '{"transient":{"cluster.routing.allocation.enable":"all","cluster.routing.allocation.exclude._name":""}}'