Azure managed disks are getting deleted when the AKS instance is deleted

Shreyas Arani 266 Reputation points
2021-05-06T14:13:16.227+00:00

Hi my azure managed disks are getting deleted when I delete my AKS instance because these azure disks are getting created under node resource group of the AKS instance. When I delete my aks instance the node resource group is deleted and all resources like disks etc under this node resource group are getting deleted.
Basically I am using this azure disks as persistance volumes. So I need to retain the disks even if my aks instance is deleted. Is there any way to retain the disks??
Please answer my query.

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,103 questions
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
631 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. prmanhas-MSFT 17,901 Reputation points Microsoft Employee
    2021-05-07T11:22:07.35+00:00

    @Shreyas Arani Apologies for the delay in response and all the inconvenience caused because of the issue.

    If these are dynamic PVCs then they will be removed with the infrastructure resource group at the time of removing AKS cluster as the infra resource group is deleted during AKS delete. You can refer to this for more information.

    Volumes defined and created as part of the pod lifecycle only exist until you delete the pod. Pods often expect their storage to remain if a pod is rescheduled on a different host during a maintenance event, especially in Stateful Sets. A persistent volume (PV) is a storage resource created and managed by the Kubernetes API that can exist beyond the lifetime of an individual pod. More information here.

    So to extend the life span of the PVCs beyond the life span of the AKS cluster:

    • In case of dynamic disk PVCs back up and restore the disks. More info here
    • Or you can use statically provisioned Disk PVCs in a different resource group and mount it as volume as mentioned here.

    Hope it helps!!!

    Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.