# kubectl apply -f grafana-volume.yaml persistentvolume/grafana created persistentvolumeclaim/grafana created # kubectl apply -f grafana-deployment.yaml deployment.apps/grafana configured
查看 pod 状态:
1 2 3 4
# kubectl get po -n monitoring NAME READY STATUS RESTARTS AGE ... grafana-6668cd66cb-ff8kg 0/1 ContainerCreating 0 2m32s
进一步查看描述信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# kubectl describe po grafana-6668cd66cb-ff8kg -n monitoring Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 3m57s default-scheduler Successfully assigned monitoring/grafana-6668cd66cb-ff8kg to k8s-node2 Warning FailedMount 3m54s kubelet, k8s-node2 MountVolume.SetUp failed for volume "grafana" : mount failed: exit status 32 Mounting command: systemd-run Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/fc4d98ef-0b80-4570-a487-4ded9133eb58/volumes/kubernetes.io~nfs/grafana --scope -- mount -t nfs 172.16.64.233:/data/nfs /var/lib/kubelet/pods/fc4d98ef-0b80-4570-a487-4ded9133eb58/volumes/kubernetes.io~nfs/grafana Output: Running scope as unit run-54024.scope. mount: wrong fs type, bad option, bad superblock on 172.16.64.233:/data/nfs, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try dmesg | tail or so. Warning FailedMount 3m53s kubelet, k8s-node2 MountVolume.SetUp failed for volume "grafana" : mount failed: exit status 32
说明是 mount 失败了。原因是我们需要在每个节点,都要安装 NFS 客户端。在生产环境下,如何批量操作 terminal 终端?请参考:批量操作Shell终端
在每个node下面都安装好NFS客户端以后,删除掉出错的 pod。
查看 pod:
1 2 3
kubectl get po -n monitoring NAME READY STATUS RESTARTS AGE grafana-6668cd66cb-jrnjv 0/1 CrashLoopBackOff 4 2m53s
没有正常启动,我们再看一下这个 Pod 的日志:
1 2 3 4
# kubectl logs grafana-6668cd66cb-jrnjv -n monitoring GF_PATHS_DATA='/var/lib/grafana' is not writable. You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later mkdir: cannot create directory '/var/lib/grafana/plugins': Permission denied