Using Persistent Storage in Virtual Kubernetes Services (VKS)
When a Virtual Kubernetes Services (VKS) cluster is provisioned, the corresponding persistent storage resources can be created at the same time according to the user’s request. These storage resources are presented as Kubernetes PersistentVolumes (PVs), which in VKS can be provisioned statically or dynamically. Because VKS hides the complexity of the storage backend details, users only need to create PersistentVolumeClaims (PVCs) as needed and mount them to the appropriate directories inside the Container. For more information about Kubernetes storage, see Kubernetes Storage.
All user accounts share the same PVs that are statically created by the system. PVCs bound to these statically provisioned PVs can be used to share data across different resource objects. Dynamically provisioned PVs are limited to 10 GiB and cannot be expanded. We therefore recommend using statically provisioned PVs as the primary option, and reserving dynamically provisioned PVs for small, temporary workloads.
Static Provisioning
-
When a user creates a
namespacein VKS, the system automatically creates the following three PVCs for that namespace. Thus the user does not need to create these PVCs mannually.- pvc-capacity-userdata: read/write (directories and files within the current cluster).
- pvc-capacity-share: read-only (all directories and files under the company account).
- pvc-capacity-app: read-only (directories and files for the enabled applications).
To list the storage:
kubectl get pvc -n test
-
If the user needs to provision additional storages, he or she can contact customer service to create a PV, using the following menifest file:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: your-pvc-name
spec:
volumeName: your-pv-name
accessModes:
- ReadWriteManyTipWhen using the manifest above, replace
your-pvc-nameandyour-pv-namewith the actualy names of the PVC and PV.
Dynamic Provisioning
To obtain the StorageClass:
kubectl get storageClass

Example
# Dynamic storage PVC for `VKS`
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: your-pvc-name
namespace: your-namespace
spec:
storageClassName: your-storage-class # StorageClass name obtained in the previous step
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
Using PVCs in Pods
Mount the PVC to the specified directory in the Container. For statically provisioned PVs, set the value of claimName to 'pvc-capacity-userdata' (read/write, used by VKS). For dynamically provisioned PVs (up to 10 GiB), enter the name of the PVC that is created above.
Example
# Use storage in a Pod
template:
metadata:
labels:
app: your-label
spec:
containers:
- name: your-container-name
image: your-image # Replace with your image name
command: your-command
ports:
- containerPort: your-port-num
volumeMounts:
- name: data-volume
mountPath: /mnt/test # Directory in the container where storage is mounted
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: pvc-capacity-userdata # For dynamic provisioning, this is the name of the PVC that is created above