Kubernetes:我可以将同一 PV 的不同子路径挂载到同一容器的不同位置吗?
Kubernetes: Can I mount different subPaths from the same PV onto different locations of the same container?
我可以将同一个 PV 的不同子路径挂载到同一个容器的不同位置吗?
我 运行 我公司的 Kubernetes 集群上有几个 wordpress 实例。每个实例都有自己的持久性卷和容器。我的设置的唯一特点是我将 PV 的多个路径安装到容器的多个路径上。
自几周前我们将 Kubernetes 升级到当前版本以来,我的所有容器都运行良好。从此,地狱开始了。
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:25:46Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
重新启动 pod 时,如果它被安排到 运行 在不同的节点上,它会卡在 PodInitializing 并显示以下事件消息
Multi-Attach error for volume "pvc-ac6b35f3-7716-11e8-adda-b60483de6a40" Volume is already exclusively attached to one node and can't be attached to another
这是我的资源。
Ceph RBD PersistentVolume
包含两个目录和一个文件
html/
:包含 php 个文件的目录
logs/
: 包含日志文件的目录
container-data.txt
: 包含一些信息的文本文件
定义为:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rbd-wordpress-mysite
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
我的播客
kind: Deployment
apiVersion: apps/v1beta1
metadata:
name: wordpress-mysite
labels:
app: wordpress
namespace: unibz
spec:
template:
metadata:
name: wordpress-mysite
labels:
app: wordpress
namespace: unibz
spec:
containers:
- name: wordpress-mysite
image: myimage
volumeMounts:
- mountPath: "/root/container-data.txt"
name: wordpress-data
subPath: container-data.txt
- mountPath: "/var/www/html"
name: wordpress-data
subPath: html
- mountPath: "/var/log/apache2"
name: wordpress-data
subPath: logs
ports:
- containerPort: 80
name: wordpress-http
volumes:
- name: wordpress-data
persistentVolumeClaim:
claimName: rbd-wordpress-mysite
- name: wordpress-conf
configMap:
name: wordpress-conf
这种使用持久化的方式是不是错了?这可能是多重附加错误的原因吗?
看起来您正试图将相同的 PVC
附加到不同的 node
。
Access Modes
Claims use the same conventions as volumes when requesting storage with specific access modes
在你的 .yaml
我可以看到,你已经设置 accessModes: ReadWriteOnce
.
A PersistentVolume
can be mounted on a host in any way supported by the resource provider. As shown in the table below, providers will have different capabilities and each PV’s access modes are set to the specific modes supported by that particular volume. For example, NFS can support multiple read/write clients, but a specific NFS PV might be exported on the server as read-only. Each PV gets its own set of access modes describing that specific PV’s capabilities.
The access modes are:
ReadWriteOnce – the volume can be mounted as read-write by a single node
ReadOnlyMany – the volume can be mounted read-only by many nodes
ReadWriteMany – the volume can be mounted as read-write by many nodes
从有关 Persistent Volumes
的 Kubernetes 文档中,您可以了解到 CephFS 确实支持所有 accessModes
我可以将同一个 PV 的不同子路径挂载到同一个容器的不同位置吗?
我 运行 我公司的 Kubernetes 集群上有几个 wordpress 实例。每个实例都有自己的持久性卷和容器。我的设置的唯一特点是我将 PV 的多个路径安装到容器的多个路径上。
自几周前我们将 Kubernetes 升级到当前版本以来,我的所有容器都运行良好。从此,地狱开始了。
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:25:46Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
重新启动 pod 时,如果它被安排到 运行 在不同的节点上,它会卡在 PodInitializing 并显示以下事件消息
Multi-Attach error for volume "pvc-ac6b35f3-7716-11e8-adda-b60483de6a40" Volume is already exclusively attached to one node and can't be attached to another
这是我的资源。
Ceph RBD PersistentVolume
包含两个目录和一个文件
html/
:包含 php 个文件的目录logs/
: 包含日志文件的目录container-data.txt
: 包含一些信息的文本文件
定义为:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rbd-wordpress-mysite
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
我的播客
kind: Deployment
apiVersion: apps/v1beta1
metadata:
name: wordpress-mysite
labels:
app: wordpress
namespace: unibz
spec:
template:
metadata:
name: wordpress-mysite
labels:
app: wordpress
namespace: unibz
spec:
containers:
- name: wordpress-mysite
image: myimage
volumeMounts:
- mountPath: "/root/container-data.txt"
name: wordpress-data
subPath: container-data.txt
- mountPath: "/var/www/html"
name: wordpress-data
subPath: html
- mountPath: "/var/log/apache2"
name: wordpress-data
subPath: logs
ports:
- containerPort: 80
name: wordpress-http
volumes:
- name: wordpress-data
persistentVolumeClaim:
claimName: rbd-wordpress-mysite
- name: wordpress-conf
configMap:
name: wordpress-conf
这种使用持久化的方式是不是错了?这可能是多重附加错误的原因吗?
看起来您正试图将相同的 PVC
附加到不同的 node
。
Access Modes Claims use the same conventions as volumes when requesting storage with specific access modes
在你的 .yaml
我可以看到,你已经设置 accessModes: ReadWriteOnce
.
A
PersistentVolume
can be mounted on a host in any way supported by the resource provider. As shown in the table below, providers will have different capabilities and each PV’s access modes are set to the specific modes supported by that particular volume. For example, NFS can support multiple read/write clients, but a specific NFS PV might be exported on the server as read-only. Each PV gets its own set of access modes describing that specific PV’s capabilities.The access modes are:
ReadWriteOnce – the volume can be mounted as read-write by a single node
ReadOnlyMany – the volume can be mounted read-only by many nodes
ReadWriteMany – the volume can be mounted as read-write by many nodes
从有关 Persistent Volumes
的 Kubernetes 文档中,您可以了解到 CephFS 确实支持所有 accessModes