如何在 "Docker for windows" 上在 Kubernetes 中创建 "PersistentVolumeClaim"

How to create "PersistentVolumeClaim" in Kubernetes on "Docker for windows"

在Vsphere中"Juju"安装kubernetes,我们创建pvc如下,

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: db-data
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: fast
  resources:
    requests:
      storage: 1Gi

storageClassName 设为 "fast"。存储 class 我们需要在 "Docker for windows" 安装中创建一个 "PersistentVolumeClaim"。

希望我找到了答案,

kubectl get storageclass 给出如下输出,

NAME                 PROVISIONER          AGE
hostpath (default)   docker.io/hostpath   22h

那么,我们可以用'hostpath'作为'storageClassName'

的值

A StorageClass provides a way for administrators to describe the “classes” of storage they offer. Different classes might map to quality-of-service levels, or to backup policies, or to arbitrary policies determined by the cluster administrators. Kubernetes itself is unopinionated about what classes represent. This concept is sometimes called “profiles” in other storage systems.

您可以参考 official documentation:

中的 vSphere 示例创建多个满足您需求的 StorageClasses

vSphere

Create a StorageClass with a user specified disk format.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: fast
provisioner: kubernetes.io/vsphere-volume
parameters:
  diskformat: zeroedthick

diskformat: thin, zeroedthick and eagerzeroedthick. Default: "thin".

Create a StorageClass with a disk format on a user specified datastore.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: fast
provisioner: kubernetes.io/vsphere-volume
parameters:
    diskformat: zeroedthick
    datastore: VSANDatastore

datastore: The user can also specify the datastore in the StorageClass. The volume will be created on the datastore specified in the storage class, which in this case is VSANDatastore. This field is optional. If the datastore is not specified, then the volume will be created on the datastore specified in the vSphere config file used to initialize the vSphere Cloud Provider.

Storage Policy Management inside kubernetes

Using existing vCenter SPBM policy

One of the most important features of vSphere for Storage Management is policy based Management. Storage Policy Based Management (SPBM) is a storage policy framework that provides a single unified control plane across a broad range of data services and storage solutions. SPBM enables vSphere administrators to overcome upfront storage provisioning challenges, such as capacity planning, differentiated service levels and managing capacity headroom.

The SPBM policies can be specified in the StorageClass using the storagePolicyName parameter.

Virtual SAN policy support inside Kubernetes

Vsphere Infrastructure (VI) Admins will have the ability to specify custom Virtual SAN Storage Capabilities during dynamic volume provisioning. You can now define storage requirements, such as performance and availability, in the form of storage capabilities during dynamic volume provisioning. The storage capability requirements are converted into a Virtual SAN policy which are then pushed down to the Virtual SAN layer when a persistent volume (virtual disk) is being created. The virtual disk is distributed across the Virtual SAN datastore to meet the requirements.

You can see Storage Policy Based Management for dynamic provisioning of volumes for more details on how to use storage policies for persistent volumes management.

There are few vSphere examples which you try out for persistent volume management inside Kubernetes for vSphere.