Kubernetes upgrade of pod with PersistentVolumeClaim in ReadWriteOnce accessMode

4/3/2019

I have postgres pod using a PersistentVolumeClaim for the database storage, in mode ReadWriteOnce.

To upgrade the pod using Helm is tricky because the new pod is blocked until the old pod releases the claim, and Helm won't remove the old pod until the new pod is ready.

How does one normally handle this problem? I can't seem to find documentation on this anywhere, and I would think that this is a common problem.

This is my pvc:

apiVersion: v1                                                                  
kind: PersistentVolumeClaim                                                     
metadata:                                                                       
    name: pgdata-claim                                                          
spec:                                                                           
    accessModes:                                                                
        - ReadWriteOnce                                                         
    storageClassName: standard                                                  
    resources:                                                                  
        requests:                                                               
            storage: 20Gi                                                       
    selector:                                                                   
        matchLabels:                                                            
            app: postgres                                                       
-- Michael Soulier
kubernetes
kubernetes-helm

1 Answer

4/5/2019

In case when you are using ReadWriteOnce mode, my proposal is to use "StatefulSet" with "volumeClaimTemplates" it was tested successfully (however without helm).

As an example please take a look for this:

https://kubernetes.io/blog/2019/04/04/kubernetes-1.14-local-persistent-volumes-ga/

Please share with the results and your findings.

-- Hanx
Source: StackOverflow