0

I have an application that is run as a service in Azure aks (kubernetes) cluster. This application pulls data from a database and puts it in a file.

As I understand I first need to create a docker image and push it to Azure aks registry. Once this is done I need to create a pod and run this application as a service.

The question that I have is -

a) What Azure or docker option I need to use to store data so that it does not get deleted (removed) if pod is crashed or deleted or rescheduled on another node and data remains available in a file once the file is created.

b) Searching on internet, it appears I can use Azure persistent disk or file storage by creating it statically or dynamically using kubectl command. However the part that I do not understand is - after creating the persistent storage using kubectl apply -f how to I make use of azure disk storage ?

Do I need to modify dockerfile and specify a mount path (volume?) and also specify the mount path in application (e.g. /mnt/app-data) where application can write data to file.

While there might be standard mechanism to store the data in aks cluster I am somewhat new to it and looking forward to expert's advice how to create and use storage in Azure ( aks cluster to be precise ) for an application to write data to it.

0

Persisting data in Kubernetes (regardless of whether it is AKS or another implementation), will require you to look at using persistent volumes. This is a concept in Kubernetes, which is then backed by specific storage resources in your provider of choice, for example in Azure this is Azure Disk or Azure Files.

First off, I would recommend you do evaluate your app and determine if you actually need to store data persistently in your pod. Being stateless makes your life significantly easier when working with Kubernetes from a resilience and DR perspective. Could you make your database (run outside of AKS) the source of truth and have the application download the data each time it runs, for example?

If you do need to store this data then you need to look at attaching a persistent volume to your pods, and specifying this as a volume in your Docker file. There is a good walk through of how storage works and how to set it up here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.