Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to inspect the content of persistent volume by kubernetes on azure cloud service

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.

  1. use Blob Storage on azure, but then after searching, I can't find the executable method.
  2. use Persistent Volume, but all the official documentation of azure and pages I found is about Persistent Volume itself, not about how to inspect it.

I need to access and manage my output directory on Azure cluster. In other words, I need a savior.

like image 943
张泽栋 Avatar asked Mar 28 '18 07:03

张泽栋


People also ask

How do I view volumes in Kubernetes?

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.

How do you check data in PVC Kubernetes?

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.

How does the persistent volume works in Kubernetes?

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.

What is persistent volume in Kubernetes?

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.

How to Mount Azure files as Kubernetes Volume?

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

What is a persistent volume in azure?

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..

What storage options are available for applications in azure Kubernetes Service (AKS)?

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.


1 Answers

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
like image 141
sauerburger Avatar answered Oct 21 '22 08:10

sauerburger