在CentOS上監控和收集Kubernetes(k8s)集群的日志,通常需要使用專門的監控和日志收集工具。以下是一些常用的方法和工具:
Prometheus
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/prometheus
helm install grafana grafana/grafana
kubectl get servicemonitor -n monitoring
查看監控項目。每個監控項目下有很多監控子項,如prometheus-kube-prometheus-apiserver
監控Kubernetes API Server的性能和健康狀態。Cockpit
yum install cockpit
systemctl start cockpit
systemctl enable cockpit
firewall-cmd --permanent --zone=public --add-service=cockpit
firewall-cmd --reload
http://<your-server-ip>:9090
。ELK Stack(Elasticsearch, Logstash, Kibana)
helm repo add elastic https://helm.elastic.co
helm repo update
helm install elasticsearch elastic/elasticsearch
helm install logstash elastic/logstash
helm install kibana elastic/kibana
EFK Stack(Elasticsearch, Fluentd, Kibana)
helm repo add fluentd https://helm.fluentd.org
helm repo update
helm install fluentd fluentd/fluentd
helm install elasticsearch elastic/elasticsearch
helm install kibana elastic/kibana
通過上述方法,可以在CentOS上有效地監控Kubernetes集群的狀態和收集日志,從而更好地進行運維和管理。