'create AWS volumes with copies of volumes in all other subnet for EKS auto scaling
I have an application that is running in EKS, this application require certain data that need to be in PVC.
In my AWS node group we have configured it to scale it in all the subnets available in that VPC. There is no issues with the node group but we can add the AWS volumes to the node in only one subnet. Every time we terminate a node it is getting started in some other subnet in that VPC and since the AWS volume is not available in the region so it is not getting bonded to that node.
Is there a way where we can create a volumes and make its copy/snapshot to be available in all the subnets of that VPC so the K8 should be able to connect to the volumes according to the node.
My yaml file:
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: vernemq-storage-passwd
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Retain
mountOptions:
- debug
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: vernemq-passwd-pv
spec:
accessModes:
- ReadWriteMany
awsElasticBlockStore:
fsType: xfs
volumeID: aws://ap-south-1c/vol-<volume-id>
capacity:
storage: 5Gi
persistentVolumeReclaimPolicy: Retain
storageClassName: vernemq-storage-passwd
volumeMode: Filesystem
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: vernemq-passwd-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
storageClassName: vernemq-storage-passwd
volumeMode: Filesystem
volumeName: vernemq-passwd-pv
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: vernemq
spec:
replicas: 1
selector:
matchLabels:
app: vernemq
serviceName: vernemq
template:
metadata:
labels:
app: vernemq
spec:
serviceAccountName: vernemq
containers:
- name: vernemq
image: vernemq/vernemq:latest
imagePullPolicy: Always
env:
- name: DOCKER_VERNEMQ_ACCEPT_EULA
value: "yes"
- name: DOCKER_VERNEMQ_ALLOW_ANONYMOUS
value: "off"
- name: DOCKER_VERNEMQ_VMQ_PASSWD__PASSWORD_FILE
value: "/etc/vernemq/vmq.passwd"
volumeMounts:
- mountPath: /etc/vernemq-passwd
name: vernemq-passwd
readOnly: true
volumes:
- name: vernemq-passwd
persistentVolumeClaim:
claimName: vernemq-passwd-pvc
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
