【发布时间】:2016-06-01 20:57:15
【问题描述】:
我正在尝试在 Kubernetes 中创建一个 Cassandra 集群。我想使用awsElasticBlockStore 使数据持久化。因此,我为相应的复制控制器编写了如下 YAML 文件:
apiVersion: v1
kind: ReplicationController
metadata:
name: cassandra-rc
spec:
# Question: How can I do this?
replicas: 2
selector:
name: cassandra
template:
metadata:
labels:
name: cassandra
spec:
containers:
- resources:
limits :
cpu: 1.0
image: cassandra:2.2.6
name: cassandra
ports:
- containerPort: 7000
name: comm
- containerPort: 9042
name: cql
- containerPort: 9160
name: thrift
volumeMounts:
- name: cassandra-persistent-storage
mountPath: /cassandra_data
volumes:
- name: cassandra-persistent-storage
awsElasticBlockStore:
volumeID: aws://ap-northeast-1c/vol-xxxxxxxx
fsType: ext4
但是,使用此配置只能正确启动一个 pod。
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
cassandra-rc-xxxxx 0/1 ContainerCreating 0 5m
cassandra-rc-yyyyy 1/1 Running 0 5m
当我运行 $ kubectl describe pod cassandra-rc-xxxxx 时,我看到如下错误:
同步 pod 时出错,跳过:无法附加 EBS 磁盘“aws://ap-northeast-1c/vol-xxxxxxxx”:附加 EBS 卷时出错:VolumeInUse:vol-xxxxxxxx 已附加到实例
这是可以理解的,因为 ELB Volume 只能从一个节点挂载。因此,只有一个 pod 可以成功挂载卷并启动,而其他 pod 则失败。
有什么好的解决办法吗?我需要为每个 Pod 创建多个 Replication Controller 吗?
【问题讨论】:
标签: amazon-web-services kubernetes amazon-ebs