在CentOS上监控Kubernetes(k8s)状态有多种方法,以下是一些常用的工具和步骤:
Cockpit是CentOS 8(CentOS 7也可以使用)内置的一款基于Web的可视化管理工具,可以监控服务器资源、网络配置、用户管理、防火墙管理等。
安装步骤:
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
。Prometheus是一个开源的监控系统,具有多维数据收集和查询功能,而Grafana则用于数据的可视化展示。
安装步骤:
kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/master/bundle.yaml
创建prometheus.yaml
文件,内容如下:
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: my-prometheus
spec:
replicas: 2
serviceAccountName: prometheus-k8s
serviceMonitorSelector: {}
resources:
requests:
memory: 400Mi
ruleSelector:
matchLabels:
prometheus: k8s
alerting:
alertmanagers:
- namespace: monitoring
name: alertmanager-main
port: web
storage:
storageClassName: default
volumeClaimTemplate:
spec:
resources:
requests:
storage: 10Gi
ingress:
enabled: false
应用配置:
kubectl apply -f prometheus.yaml
kubectl apply -f https://raw.githubusercontent.com/coreos/kube-prometheus/master/manifests/grafana/grafana.yaml
配置Grafana连接Prometheus:在Grafana界面中添加Prometheus数据源,填入Prometheus的服务地址(如http://my-prometheus.monitoring.svc.cluster.local)。
部署Grafana Dashboard:导入现成的Grafana仪表盘来展示K8S监控数据,如Node监控、Pod监控、服务监控等。
Kindling是一个用于观测Kubernetes应用网络连接状态的工具,可以与Grafana结合使用。
安装步骤:
kubectl apply -f ./kindling.yaml
kubectl -n kindling get pod
对于需要监控NVIDIA GPU设备的用户,可以安装NVIDIA设备插件。
安装步骤:
以上方法可以帮助您在CentOS上有效地监控Kubernetes集群的状态和性能。根据您的具体需求,可以选择适合的工具进行监控。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:centos k8s如何监控状态