【问题标题】:Kubernetes: How can I set the number of replicas more than 1 using awsElasticBlockStore?Kubernetes:如何使用 awsElasticBlockStore 将副本数设置为 1 以上?
【发布时间】: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


    【解决方案1】:

    您是对的,一个 EBS 卷只能在给定时间安装在单个 EC2 上。为了解决你有以下选择:

    【讨论】:

    • 谢谢!我实际上已经为这个限制创建了多个复制控制器,到目前为止它们运行良好。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-29
    • 1970-01-01
    • 2018-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    相关资源
    最近更新 更多