Kubernetes stateful set are not using storage class to create persistance volume Kubernetes stateful set are not using storage class to create persistance volume kubernetes kubernetes

Kubernetes stateful set are not using storage class to create persistance volume


You need to create a storage that you are requesting with PersistentVolumeClaim.

Example of Volume types are available here.

A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.

A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g., can be mounted once read/write or many times read-only).

If you are on GCE, you can use gcePersistentDisk

A gcePersistentDisk volume mounts a Google Compute Engine (GCE) Persistent Disk into your Pod. Unlike emptyDir, which is erased when a Pod is removed, the contents of a PD are preserved and the volume is merely unmounted. This means that a PD can be pre-populated with data, and that data can be “handed off” between Pods.

You need to use the gcloud command to create a drive inside the GCE:

gcloud compute disks create --size=500GB --zone=us-central1-a my-data-disk

And using it inside a POD, like in the example below:

apiVersion: v1kind: Podmetadata:  name: test-pdspec:  containers:  - image: k8s.gcr.io/test-webserver    name: test-container    volumeMounts:    - mountPath: /test-pd      name: test-volume  volumes:  - name: test-volume    # This GCE PD must already exist.    gcePersistentDisk:      pdName: my-data-disk      fsType: ext4

If you prefer, you can setup your own nfs server and use it inside Kubernetes, an example on how to set it up, is available here.

You can also check the documentation on how to use volumes on AWS.

Hope this will be enough to help you.