简介
🧲 相关资料
一: 启用 KubeSphere 日志系统
1.1 集群配置中心开启日志
IP 和端口号都没有引号
es:
basicAuth:
enabled: true (true开启、false关闭)
password: es密码
username: es账号
data:
volumeSize: 20Gi
elkPrefix: logstash
externalElasticsearchPort: 9200 (改成你的es端口号)
externalElasticsearchUrl: 192.168.x.x
logging:
containerruntime: docker
enabled: true (false 关闭)
logsidecar:
enabled: true
replicas: 2
# 查看安装进度
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
1.2 开启项目日志
- 项目 --> 日志收集 --> 启用项目日志
1.3 查看日志状态
❌安装遇到报错
elasticsearch-logging-data.kubesphere-logging-system.svc’, err=4): Domain name not found
# 编辑kubesphere-system 配置
kubectl edit cc -n kubesphere-system ks-installer
- 删除标红的部分
- 重启并重新加载installer
# 查看configmap相关配置
kubectl get configmap kubesphere-config -n kubesphere-system -o yaml
# 如果有错误进行编辑configMap配置
kubectl edit configmap kubesphere-config -n kubesphere-system -o yaml
# 重启并重新加载installer
kubectl rollout restart deploy -n kubesphere-system ks-installer
- 不对的地址改成自己相应的服务地址
二: 卸载 KubeSphere 日志系统
2.1 关闭总日志开关
将 CRD ClusterConfiguration 配置文件中 ks-installer 参数的logging.enabled
字段的值从 true 改为 false。
2.2 卸载日志收集器
仅禁用日志收集:
kubectl delete inputs.logging.kubesphere.io -n kubesphere-logging-system tail
# 运行此命令后,默认情况下仍可查看 Kubernetes 提供的容器最近日志。但是,容器历史记录日志将被清除,您无法再浏览它们。
2.3 卸载es日志系统
卸载包括 Elasticsearch 的日志系统,请执行以下操作:
❗❗❗
此操作可能导致审计、事件和服务网格的异常。
kubectl delete crd fluentbitconfigs.logging.kubesphere.io
kubectl delete crd fluentbits.logging.kubesphere.io
kubectl delete crd inputs.logging.kubesphere.io
kubectl delete crd outputs.logging.kubesphere.io
kubectl delete crd parsers.logging.kubesphere.io
kubectl delete deployments.apps -n kubesphere-logging-system fluentbit-operator
helm uninstall elasticsearch-logging --namespace kubesphere-logging-system
2.4 删除系统日志依赖
- 运行以下命令:
kubectl delete deployment logsidecar-injector-deploy -n kubesphere-logging-system
kubectl delete ns kubesphere-logging-system
成功卸载
❌ 如果遇到卸载报错
kubesphere-logging-system because it is being terminated
删除 KubeSphere 中一直卡在 Terminating 的 Namespace
# 查看kubectl 日志
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
# 查看命名空间状态
kubectl get ns
查看kubesphere-system的namespace描述
kubectl get ns kubesphere-system -o json > kubesphere-system.json
编辑json文件,删除spec字段的内存,因为k8s集群时需要认证的。打开编辑kubesphere-system.json
"spec": {
"finalizers": [
"kubernetes"
]
},
#更改为:
"spec": {},