I have packed the software to a container. I need to put the container to cluster by Azure Container Service. The software have outputs of an directory /src/data/
, I want to access the content of the whole directory.
After searching, I have to solution.
I need to access and manage my output directory on Azure cluster. In other words, I need a savior.
You can get the volumes mounted on the pod using the output of kubectl describe pod which has the Mounts section in each container's spec . You can then exec into the pod using kubectl exec and the cd to the directory you want to write data to.
First, find out your pvc's mountPath. Your data sits there. Second, you can access it from the pod that uses the PersistentVolumeClaim. Fire up a terminal on the pod and use your favourite tools like ls and df to list files or see stats of the volume usage.
Persistent volumes are independent of the lifecycle of the pod that uses it, meaning that even if the pod shuts down, the data in the volume is not erased. They are defined by an API object, which captures the implementation details of storage such as NFS file shares, or specific cloud storage systems.
Applies to: AKS on Azure Stack HCI, AKS runtime on Windows Server 2019 Datacenter A persistent volume represents a piece of storage that has been provisioned for use with Kubernetes pods. A persistent volume can be used by one or more pods and is meant for long-term storage. It's also independent of pod or node lifecycle.
These data volumes can use Azure Disks or Azure Files. In this blog we will be discussing about how to mount Azure Files as Kubernetes volume. You can either mount volume directly to pod or can mount using Persistent volume and Persistent volume claim
But Volumes like emptyDir, hostPath — that are defined and created as part of the pod life-cycle only exist until the pod is deleted. So there is this concept called as persistent volume, which can be mapped to cloud providers storage like azuredisk, NFS, ISCSI, Azure files etc..
Storage options for applications in Azure Kubernetes Service (AKS) 1 Volumes. Kubernetes typically treats individual pods as ephemeral, disposable resources. Applications have different approaches available to them for ... 2 Persistent volumes. 3 Storage classes. 4 Persistent volume claims. 5 Next steps.
As I've explained here and here, in general, if you can interact with the cluster using kubectl
, you can create a pod/container, mount the PVC inside, and use the container's tools to, e.g., ls
the contents. If you need more advanced editing tools, replace the container image busybox
with a custom one.
Create the inspector pod
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: pvc-inspector
spec:
containers:
- image: busybox
name: pvc-inspector
command: ["tail"]
args: ["-f", "/dev/null"]
volumeMounts:
- mountPath: /pvc
name: pvc-mount
volumes:
- name: pvc-mount
persistentVolumeClaim:
claimName: YOUR_CLAIM_NAME_HERE
EOF
Inspect the contents
kubectl exec -it pvc-inspector -- sh
$ ls /pvc
Clean Up
kubectl delete pod pvc-inspector
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With