tencent cloud


Instructions for Other Storage Volumes

Last updated: 2022-04-18 14:56:06


    Volume types

    Volume TypeDescription
    Use temporary path /
    Use host path Mount the file directory of the host where the container resides to the path specified by the container (corresponding to HostPath in Kubernetes). You can also choose not to set the source path (corresponding to EmptyDir in Kubernetes). If the source path is not specified, the system mounts the temporary directory of the assigned host to the mount target of the container.Local disk volumes that have specified source paths are suitable for persisting data to the host where the container resides, whereas EmptyDir is suitable for temporary storage for containers.
    Use NFS disk Simply enter the NFS path. You can use Tencent Cloud's Cloud File Storage (CFS) or user-built NFS file storage. An NFS volume is suitable for persistent storage with frequent reads and writes in scenarios such as big data analysis, media processing, and content management.
    Use existing PersistentVolumeClaim Use the storage of the existing PersistentVolumeClaim to declare the storage for workloads, and automatically assign or create a PersistentVolume and mount it to the corresponding pod. This is suitable for stateful applications created by StatefulSet.
    Use ConfigMap A ConfigMap is mounted to a pod as a file system. You can mount the custom ConfigMap entries to a specific path. For more information, see ConfigMap Management.
    Use Secret A Secret is mounted to a pod as a file system. You can mount custom Secret entries to a specific path. For more information, see Secret Management.

    Notes on volumes

    • After creating a volume, you need to set the mount target of the container in the "Containers in the Pod" module.
    • Under the same service, the name of the volume and the set mount target must be unique.
    • When the source path of a local disk volume is empty, the system will assign a temporary directory /var/lib/kubelet/pods/pod_name/volumes/kubernetes.io~empty-dir, and the lifecycle of the volume using the temporary directory is the same as the lifecycle of the Pod.
    • If no permission is set for volume mount, the default setting will be read/write permission.

    Operation Guide for Volumes in the Console

    Creating a workload to mount a volume

    1. Log in to the TKE console and select Clusters in the left sidebar.
    2. On the Cluster Management page, click the ID of the cluster where you want to deploy a workload to go to the cluster management page.
    3. Under Workload, select a workload type to go to the corresponding information page.
      For example, select Workload -> DaemonSet to go to the DaemonSet page as shown in the following figure:
    4. Click Create to go to Create Workload page.
    5. Set the workload name, namespace and other information as instructed. In Volume, click Add Volume.
    6. Select a storage method for the volume. Use Tencent Cloud CBS is selected in this case.
    7. Configure the mount point in Mount Target under Containers in the Pod, as shown in the following figure:
      You can configure the mount point only after selecting Add Volume in Step 5.
    8. Set other options as needed and click Create Workload to finish the creation.

    Configurations for mounting different volumes

    This table shows the details of the use of different volumes. When you are creating a workload and have selected **Add Volume, you can refer to the following content to add the volume and set the mount point:

    Volume Mount Target
    Type Name Others Destination Path Sub-path Read and Write Permissions
    Temporary pathCustom/Specify this path as needed, for example, /cache. Mount only the sub-path or a single file in the selected volume, for example, /data or /test.txt. Select as needed.
  • Read-only: the container path volume can only be read and data modifications must be performed on the host.
  • Read and write: data can be read from and modifications can be saved to the container path volume.
  • Node pathSet the node path.
  • Node Path: the node path cannot be empty. For example, if the container needs to access Docker, the node path can be set to /var/lib/docker.
  • Check Type: TKE provides many check types such as NoChecks and DirectoryOrCreate. Read the description of each type in the console and select a check type as needed.
  • NFS diskNFS Path: enter the CFS address or user-built NFS address.
  • To create a file system, see Creating File Systems and Mount Targets.
  • is an example NFS path. To obtain the NFS path, please log in to the CFS console, click the ID of the target file system and find it in **Mount under Linux** on the **Mount Target Info** tab.
  • Existing PVCChoose a PVC as needed.
    Tencent Cloud CBSSelect a cloud disk as needed.
  • Select a ConfigMap: select a ConfigMap as needed.
  • Options: **All** and **Specific keys**.
  • Items: if you select **Specific keys**, you can mount it to a specific path by adding items. For example, if the mount point is /data/config and the sub-path is dev, the data will be stored under /data/config/dev.

    Using kubectl to Manipulate Volumes

    The following is a sample where which you can perform creation by using kubectl directly.

    Sample YAML for Mounting a Volume to a Pod

    apiVersion: v1
    kind: Pod
     name: test-pd
     - image: k8s.gcr.io/test-webserver
       name: test-container
       - mountPath: /cache
         name: cache-volume
     - name: cache-volume
       emptyDir: {}
    • spec.volumes: set the name, type, and parameters of the volume.
      • spec.volumes.emptyDir: set the temporary path
      • spec.volumes.hostPath: set the host path
      • spec.volumes.nfs: set the NFS disk
      • spec.volumes.persistentVolumeClaim: set the existing PersistentVolumeClaim.
    • spec.volumeClaimTemplates: if this declaration is used, PersistentVolumeClaim and PersistentVolume will be automatically created based on the content of the declaration
    • spec.containers.volumeMounts: enter the mount point of the volume.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support