You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Minikube中PV/PVC主机与容器挂载目录不同步问题求助

问题:HostPath PV/PVC挂载后主机与容器内容不同步

我已创建Persistent Volume(PV)和Persistent Volume Claim(PVC),并通过Helm Chart完成挂载。从配置来看各组件关联正常,但修改主机HostPath目录的内容无法同步到容器,修改容器内挂载目录的内容也无法同步到主机。

已完成的检查

  • 确认PV存在及来源
  • 确认PVC存在
  • 确认Pod已使用PVC

检查PV是否存在:

$ kc get pv
NAME        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM             STORAGECLASS   REASON   AGE
wp-php-pv   2Gi        RWO            Retain           Bound    gaph/wp-php-pvc   standard                35m

检查PVC是否存在:

$ kc get pvc -n gaph
NAME         STATUS   VOLUME      CAPACITY   ACCESS MODES   STORAGECLASS   AGE
wp-php-pvc   Bound    wp-php-pv   2Gi        RWO            standard       35m

查看PVC关联的PV详情:

$ kc describe pv wp-php-pv -n gaph
Name:            wp-php-pv
Labels:          type=local
Annotations:     pv.kubernetes.io/bound-by-controller: yes
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:    standard
Status:          Bound
Claim:           gaph/wp-php-pvc
Reclaim Policy:  Retain
Access Modes:    RWO
VolumeMode:      Filesystem
Capacity:        2Gi
Node Affinity:   <none>
Message:         
Source:
    Type:          HostPath (bare host directory volume)
    Path:          /mnt/gaph/php-data
    HostPathType:  
Events:            <none>

检查Pod详情:

$ kc describe pod $WP_POD_NAME -n gaph
Name:             gaph-wp-php-698599cbff-x7hmd
Namespace:        gaph
Priority:         0
Service Account:  gaph-wp-php
Node:             minikube/192.168.49.2
Start Time:       Fri, 06 Jan 2023 15:42:07 +1300
Labels:           app.kubernetes.io/instance=gaph-wp
                  app.kubernetes.io/name=php
                  pod-template-hash=698599cbff
Annotations:      <none>
Status:           Running
IP:               172.17.0.4
IPs:
  IP:           172.17.0.4
Controlled By:  ReplicaSet/gaph-wp-php-698599cbff
Containers:
  php:
    Container ID:   docker://f72747594bcd5ae8bbf53b24fecf69f4776f1e7a351d01ef8cdd1e210ebb984e
    Image:          php:8.2-apache
    Image ID:       docker-pullable://php@sha256:739420c858b1f447490c55971416298699678203353ba13e47e4e57b8318c94f
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Fri, 06 Jan 2023 15:42:39 +1300
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Fri, 06 Jan 2023 15:42:08 +1300
      Finished:     Fri, 06 Jan 2023 15:42:38 +1300
    Ready:          True
    Restart Count:  1
    Liveness:       http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
    Readiness:      http-get http://:http/ delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-rm7xn (ro)
      /var/www/html from wp-php-pv (rw)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  wp-php-pv:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  wp-php-pvc
    ReadOnly:   false
  kube-api-access-rm7xn:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
...

检查容器内挂载目录:

通过kubectl exec ...执行命令:

/var/www/html# ls -al
total 8
drwxr-xr-x 2 root root 4096 Jan  6 02:47 .
drwxr-xr-x 1 root root 4096 Dec 21 05:06 ..
-rw-r--r-- 1 root root    0 Jan  6 02:47 hellosuperworld.html
-rw-r--r-- 1 root root    0 Jan  6 02:42 index.html

检查主机目录:

$ tree /mnt/gaph
/mnt/gaph
└── php-data
    └── index.php

环境为Ubuntu 22.04,请问还有哪些排查方向?


内容的提问来源于stack exchange,提问作者hey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 00:40:18