pvc storage capacity update

12/15/2020

I am trying to update the pvc (persistent volume claim) size and trying to set it in pvc status.capacity.storage field. After running yaml command I can see the update in annotation but not in status.capacity.storage field.

I have updated using below code:

memorySize := resource.NewQuantity(int64(volumeExpansionStatus.Size)*1024*1024*1024, resource.BinarySI)
pvc.Status.Capacity[v1.ResourceStorage] = *memorySize
kube.UpdatePersistentVolumeClaim(ctx, pvc)

Below is the log after execution:

Status:PersistentVolumeClaimStatus{Phase:Bound,AccessModes:ReadWriteOnce,Capacity:ResourceList{storage: {{42949672960 0} {<nil>} BinarySI},},Conditions:[]PersistentVolumeClaimCondition{},}

Below is the log before execution:

Status:PersistentVolumeClaimStatus{Phase:Bound,AccessModes:ReadWriteOnce,Capacity:ResourceList{storage: {{21474836480 0} {<nil>} 20Gi BinarySI},},Conditions:[]PersistentVolumeClaimCondition{},},}

As you can see the difference 20Gi is missing in updated field. How can I get this value as no field available for it?

-- RAW
cloud
go
kubernetes

0 Answers