Kubernetes – ReplicationController和永久磁盘

我遇到了一个Kubernetes相关的问题。 我刚刚从一个Podconfiguration移动到一个Ruby on Rails应用程序的一个ReplicationController控制器,我使用持久性磁盘的Rails窗格。 当我尝试应用ReplicationController时,会出现以下错误:

The ReplicationController "cartelhouse-ror" is invalid. spec.template.spec.volumes[0].gcePersistentDisk.readOnly: Invalid value: false: must be true for replicated pods > 1; GCE PD can only be mounted on multiple machines if it is read-only

这是否意味着在使用ReplicationController时无法使用永久性磁盘(R / W),或者有其他方法吗?

如果不是,我如何扩展和/或将滚动更新应用到Podconfiguration?

Podconfiguration:

 apiVersion: v1 kind: Pod metadata: name: appname labels: name: appname spec: containers: - image: gcr.io/proj/appname:tag name: appname env: - name: POSTGRES_PASSWORD # Change this - must match postgres.yaml password. value: pazzzzwd - name: POSTGRES_USER value: rails ports: - containerPort: 80 name: appname volumeMounts: # Name must match the volume name below. - name: appname-disk-per-sto # Mount path within the container. mountPath: /var/www/html volumes: - name: appname-disk-per-sto gcePersistentDisk: # This GCE persistent disk must already exist. pdName: appname-disk-per-sto fsType: ext4 

ReplicationControllerconfiguration:

 apiVersion: v1 kind: ReplicationController metadata: labels: name: appname name: appname spec: replicas: 2 selector: name: appname template: metadata: labels: name: appname spec: containers: - image: gcr.io/proj/app:tag name: appname env: - name: POSTGRES_PASSWORD # Change this - must match postgres.yaml password. value: pazzzzwd - name: POSTGRES_USER value: rails ports: - containerPort: 80 name: appname volumeMounts: # Name must match the volume name below. - name: appname-disk-per-sto # Mount path within the container. mountPath: /var/www/html volumes: - name: appname-disk-per-sto gcePersistentDisk: # This GCE persistent disk must already exist. pdName: appname-disk-per-sto fsType: ext4 

您无法使用当前Kubernetes实现此function – 请参阅复制的Pod的独立存储 。 这将在v1.3中实现PetSets 。

问题不在于Kubernetes,而在于共享的块设备和文件系统不能同时安装到多个主机上。 https://unix.stackexchange.com/questions/68790/can-the-same-ext4-disk-be-mounted-from-two-hosts-one-readonly

您可以尝试使用声明: http : //kubernetes.io/docs/user-guide/persistent-volumes/

或者另一个文件系统,例如nfs: http : //kubernetes.io/docs/user-guide/volumes/