Kubernetes: How Can I Set The Number Of Replicas More Than 1 Using AwsElasticBlockStore?
I'm trying to create a Cassandra cluster in Kubernetes. I want to use
awsElasticBlockStore to make the data persistent. As a result, I've written a YAML file like following for the corresponding Replication Controller:
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
However, only one pod can be properly launched with this configuration.
$ kubectl get pods NAME READY STATUS RESTARTS AGE cassandra-rc-xxxxx 0/1 ContainerCreating 0 5m cassandra-rc-yyyyy 1/1 Running 0 5m
When I run
$ kubectl describe pod cassandra-rc-xxxxx, I see an error like following:
Error syncing pod, skipping: Could not attach EBS Disk "aws://ap-northeast-1c/vol-xxxxxxxx": Error attaching EBS volume: VolumeInUse: vol-xxxxxxxx is already attached to an instance
It's understandable because an ELB Volume can be mounted from only one node. So only one pod can successfully mount the volume and bootup, while others just fail.
Is there any good solution for this? Do I need to create multiple Replication Controllers for each pod?
You are correct, one EBS volume can only be mounted on a single EC2 at a given time. To solve you have the following options:
- Use multiple EBS volumes with multiple Replication Controllers
- Use a distributed file system (e.g. Gluster) and avoid EBS issue
- Follow along with PetSet (https://github.com/kubernetes/kubernetes/issues/260)
- → AWS SDK with Lumen
- → Using AWS Certificate with a parked domain for a shopify store
- → laravel or AWS don't detect my https
- → S3 putObject callback not returning expected objects
- → Amazon S3 image hosting with Shopify
- → Redirection to https not working using AWS Elastic Beanstalk
- → Shopify app showing request blocked by an extension
- → AWS Iam commands, Working correct in terminal and not working in Laravel/PHP AWS SDK
- → Violates the following Content Security Policy directive: *** in Shopify
- → AWS S3 cannot delete objects in bucket via PHP SDK
- → Laravel s3 multiple buckets
- → AWS IoT private.pem.key doesn't exist
- → Supervise queue in laravel 5.1