We have success creating the pods, services and replication controllers according to our project requirements. Now we are planning to setup persistence storage in AWS using Kubernetes. I have created the YAML file to create an EBS volume in AWS, it's working fine as expected. I am able to claim volume and successfully mount to my pod (this is for single replica only).
But when I am trying to create more the one replica, my pods are not creating successfully. When I am trying to create volumes, it's creating in only one availability zone. If my pod is created in a different zone node, since my volume is already created in different zone, due to that my pod is not creating successfully. How to create volumes in different zones for same application? How to make it successful, along with replica? How to create my persistent volumes claims?
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mongo-pvc
labels:
type: amazonEBS
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: ReplicationController
metadata:
labels:
name: mongo-pp
name: mongo-controller-pp
spec:
replicas: 2
template:
metadata:
labels:
name: mongo-pp
spec:
containers:
- image: mongo
name: mongo-pp
ports:
- name: mongo-pp
containerPort: 27017
hostPort: 27017
volumeMounts:
- mountPath: "/opt/couchbase/var"
name: mypd1
volumes:
- name: mypd1
persistentVolumeClaim:
claimName: mongo-pvc