How can update existing aws ec2 volume id in persistent volume yaml file

Viewed 27

I have created the aws ec2 volume using storageclass, persistentvolume, persistentvolumeclaim due to some AZ problem my ec2 instance moved to some other AZ. I have created snapshot from the existing volume and created new volume in the instance created AZ.

The problem I cannot able to update the newly created volume in my persistentvolume yaml

error: persistentvolumes "jenkins-pv" is invalid

How to update existing volume id in the PV yaml?

Below are my yaml files

storageclass yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: jenkins-sc
parameters:
  fsType: ext4
  type: gp2
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer

PersistentVolumeClaim yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pvc
  namespace: dev
  finalizers:
  - kubernetes.io/pvc-protection
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 8Gi
  storageClassName: jenkins-sc

PersistentVolume yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    kubernetes.io/createdby: aws-ebs-dynamic-provisioner
    pv.kubernetes.io/bound-by-controller: "yes"
    pv.kubernetes.io/provisioned-by: kubernetes.io/aws-ebs
  finalizers:
  - kubernetes.io/pv-protection
  labels:
    failure-domain.beta.kubernetes.io/region: us-east-2
    failure-domain.beta.kubernetes.io/zone: us-east-2b
  name: jenkins-pv
spec:
  accessModes:
  - ReadWriteOnce
  awsElasticBlockStore:
    fsType: ext4
    volumeID: aws://us-east-2b/vol-0c999673840f0836e
  capacity:
    storage: 8Gi
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: jenkins-pvc
    namespace: dev
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: failure-domain.beta.kubernetes.io/zone
          operator: In
          values:
          - us-east-2b
        - key: failure-domain.beta.kubernetes.io/region
          operator: In
          values:
          - us-east-2
  persistentVolumeReclaimPolicy: Retain
  storageClassName: jenkins-sc
  volumeMode: Filesystem
0 Answers
Related