我有一个NFS类型的持久卷,其中源服务器在本地运行。该NFS服务器正在使用GCP上的持久卷声明。一切运行正常,但是由于某种原因,我无法在Prometheus上监视PVC。只是没有出现。
问题:如何监视此类磁盘的使用情况?我是否需要安装一些驱动程序或配置自定义抓取工具?
以下是我尝试过的PromQL查询:
kubelet_volume_stats_capacity_bytes
kubelet_volume_stats_available_bytes
node_filesystem_size_bytes
注意:我可以在这里看到该卷,但只能看到它的容量,而不是用法。
kube_persistentvolume_capacity_bytes
以下是NFS服务器的配置文件:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nfs-server
spec:
replicas: 1
selector:
matchLabels:
role: nfs-server
template:
metadata:
labels:
role: nfs-server
spec:
containers:
- name: nfs-server
image: gcr.io/google_containers/volume-nfs:0.8
ports:
- name: nfs
containerPort: 2049
- name: mountd
containerPort: 20048
- name: rpcbind
containerPort: 111
securityContext:
privileged: true
volumeMounts:
- mountPath: /exports
name: nfs-pvc
volumes:
- name: nfs-pvc
gcePersistentDisk:
pdName: nfs-disk
fsType: ext4
这是PV配置:
Status: Bound
Claim: default/nfs-pvc
Reclaim Policy: Retain
Access Modes: RWX
VolumeMode: Filesystem
Capacity: 1000Gi
Node Affinity: <none>
Message:
Source:
Type: NFS (an NFS mount that lasts the lifetime of a pod)
Server: nfs-server.default.svc.cluster.local
Path: /
ReadOnly: false
这是PVC配置:
Name: nfs-pvc
Namespace: default
StorageClass:
Status: Bound
Volume: nfs-pv
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 1000Gi
Access Modes: RWX
VolumeMode: Filesystem
Mounted By: ...
答案 0 :(得分:0)
Volume Exporter 来救援,它可以通过以下方式轻松完成。
Volume exporter 是专门为这些需求而创建的,在 node exporter 中可能没有用(它基本上填补了存在的空白)
- name: volume-exporter
image: mnadeem/volume_exporter
imagePullPolicy: "Always"
args:
- --volume-dir=prometheus:/prometheus
- --volume-dir=appLog:/app/log
ports:
- name: metrics-volume
containerPort: 9888
volumeMounts:
- name: prometheus-data
mountPath: /prometheus
readOnly: true
- name: log-data-volume
mountPath: /app/log
readOnly: true
导出的指标
# HELP volume_bytes_free Free size of the volume/disk
# TYPE volume_bytes_free gauge
volume_bytes_free{volume_name="bin",volume_path="/bin"} 4.341569536e+10
volume_bytes_free{volume_name="etc",volume_path="/etc"} 4.341569536e+10
# HELP volume_bytes_total Total size of the volume/disk
# TYPE volume_bytes_total gauge
volume_bytes_total{volume_name="bin",volume_path="/bin"} 6.391887872e+10
volume_bytes_total{volume_name="etc",volume_path="/etc"} 6.391887872e+10
# HELP volume_bytes_used Used size of volume/disk
# TYPE volume_bytes_used gauge
volume_bytes_used{volume_name="bin",volume_path="/bin"} 2.050318336e+10
volume_bytes_used{volume_name="etc",volume_path="/etc"} 2.050318336e+10
# HELP volume_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which volume_exporter was built.
# TYPE volume_exporter_build_info gauge
volume_exporter_build_info{branch="",goversion="go1.15",revision="",version=""} 1
# HELP volume_percentage_used Percentage of volume/disk Utilization
# TYPE volume_percentage_used gauge
volume_percentage_used{volume_name="bin",volume_path="/bin"} 32.07688208958619
volume_percentage_used{volume_name="etc",volume_path="/etc"} 32.07688208958619
免责声明:我是业主