0

I am using local persistant volumes in my Kubernetes cluster, I have currently two worker nodes in my cluster(node1, node2). So while creating local Peristant Volume I have added node affinity with these nodes.

  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - node1
          - node2

10 deployments are working using these PVs. Now, I want to add a new worker node to the cluster(node3). I tried to modify the Persistent Volume but I can't modify the nodeAffinity as this is showing "field is immutable". How should I proceed now? If I don't modify the PV, pods will not get scheduled on the new worker node?

How to tackle this situation?

Ankit Bansal
  • 111
  • 1
  • Could you please share more details about your PV capacity, your persistent volume claim and what version of kubernetes you are using? – Leo Jun 01 '22 at 15:28
  • Using v1.17, using Local PV with 50Gi, Using it for logs persistance only. Not for any Datasource like DB or something else – Ankit Bansal Jun 02 '22 at 06:53

1 Answers1

1

When a field is immutable, what you could do is delete the parent object, with the option cascade option set to orphan (used to be "false" in older versions / if "orphan" isn't recognized)

See kubectl docs.

Having your new configuration ready, delete the old object

kubectl delete deploy/example --cascade=orphan

Its child replicaset and pods should still exist. At which point, you can create the replacement deployment.

SYN
  • 1,751
  • 8
  • 14