kubernetes - 看不到已安装卷的变化

标签 kubernetes persistent-volumes

我有一个带有特定挂载的部署(请参阅下面的 pod 描述)。

但是,每当我写入容器中的指定目录时,它都不会显示在主机文件夹中。

例如:

$ kubectl exec owncloud-68c956f65c-cpxp4 -- ls /var/www/html/data

admin
avatars
files_external
index.html
owncloud.db
owncloud.log

$ ls /disk1/owncloud
...nothing...

这是 pod 的完整描述:
Name:               owncloud-68c956f65c-cpxp4
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               k8s-worker-01/192.168.0.2
Start Time:         Mon, 27 May 2019 11:12:03 +0100
Labels:             app=owncloud
                    pod-template-hash=68c956f65c
Annotations:        <none>
Status:             Running
IP:                 10.40.0.4
Controlled By:      ReplicaSet/owncloud-68c956f65c
Containers:
  owncloud:
    Container ID:   docker://68d8d96833635927e0317b849a59539cd8f119231a3a41b3a7be4deb5914aa9c
    Image:          owncloud:latest
    Image ID:       docker-pullable://owncloud@sha256:173811cb4c40505401595a45c39a802b89fb476885b3f6e8fe327aae08d20fe8
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 27 May 2019 11:12:13 +0100
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-7b4bw (ro)
      /var/www/html/config from config (rw)
      /var/www/html/data from data (rw)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  config:
    Type:          HostPath (bare host directory volume)
    Path:          /home/pi/owncloud/owncloud_conf
    HostPathType:  Directory
  data:
    Type:          HostPath (bare host directory volume)
    Path:          /disk1/owncloud
    HostPathType:  Directory
  default-token-7b4bw:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-7b4bw
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

这里有什么问题?

Lorem ipsum dolor sit amet,consectetur adipiscing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua。 Ut enim ad minim veniam

最佳答案

根据交换的消息,目录 /disk1/owncloud位于 master node ,您问题中描述的 pod 显示使用的卷类型是 hostpath ,并且它被安排到另一个没有通知主机路径的节点( k8s-worker-01/192.168.0.2 )。

要解决这个问题,您应该考虑移动工作节点的挂载点(除非您想在主节点上运行 pod)并使用 pod affinity 的规则或 nodeSelector .

如果您想要一个弹性的存储解决方案(副本,不同节点之间的分布),我建议使用:

  • rook.io : 真的很棒,很好的文档,涵盖了存储的不同方面( block 、文件、对象和不同的后端......)
  • gluster-block : 是gluster存储的插件,这个是和heketi结合使用的。参见文档 k8s provisioning
  • 关于kubernetes - 看不到已安装卷的变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56324360/

    相关文章:

    kubernetes - 将 skaffold 配置文件绑定(bind)到集群

    kubernetes - 有状态集部署期间出现错误 "pod has unbound immediate PersistentVolumeClaim"

    kubernetes - 在 kubernetes 上运行本地制作的容器

    azure - AKS - 将插件 HTTP 应用程序路由与 nginx 重写规则结合起来?

    kubernetes - 如何在 Google Container Engine 上创建 kubernetes NFS 卷

    Kubernetes 更改挂载卷的权限

    architecture - 如何在 Kubernetes pod 中组织容器 "horizontally"?

    kubernetes - 在Okteto上的pod/部署之间共享PersistentVolumeClaims

    kubernetes - pvc删除后如何恢复pv(已发布)数据

    kubernetes - 在AWS上使用ReadWriteMany的Kubernetes PVC