Updated on 2024-05-23 GMT+08:00

Storage

Overview

There are multiple storage volume types that can be used by the pods scheduled to CCI. In this section, you can

  • Storage volume types used by the pods scheduled to CCI.
  • Typical scenarios of a hostPath volume and how to use it.

Storage Volume Types

There are various storage volume types on the CCE cluster console.

The following table lists the storage volume types.

Volume Type

Supported by CCI

Remarks

hostPath

No

CCI underlying clusters are used by all users so using the hostPath volumes presents many security risks. As a result, hostPath volumes are unavailable.

ConfigMap

Yes

-

Secret

Yes

-

emptyDir

Yes

Subpaths are not supported when an emptyDir volume is mounted.

DownwardAPI

Yes

-

Projected

Yes

If a serviceAccountToken source is configured, the token in the corresponding service-account-token secret is injected into the pod scheduled to CCI. The token is valid for a long time and has no audience. This means the settings of expirationSeconds and audience do not take effect.

PersistentVolumeClaims

Yes

Only SFS and SFS Turbo are supported, with StorageClass set to CSI.

How to Use HostPath

Scenario

A HostPath volume can be used for storage when CCE or other Kubernetes clusters are used. However, CCI underlying clusters are used by all users so using hostPath volumes presents many security risks. As a result, hostPath volumes are unavailable. When a pod with a hostPath volume mounted is scheduled to CCI, the pods will be rejected. If HostPath configured in spec.volumes for a pod cannot be changed, you can configure annotations to allow the pod to be scheduled to CCI. During the bursting verification, hostPath needs to be removed or replaced with localDir, emptyDir, or flexVolume.

Procedure

You can add annotations to Pod.Annotations to convert hostPath to localDir, emptyDir, or flexVolume.
  • Replace hostPath with localDir.
    "coordinator.cci.io/hostpath-replacement": '[{"name":"source-hostpath-volume","policyType":"replaceByLocalDir","localDir":{"sizeLimit":"1Gi"}}]
  • Replace hostPath with flexVolume.
    "coordinator.cci.io/hostpath-replacement": '[{"name":"source-hostpath-volume-1","policyType":"remove"},{"name":"source-hostpath-volume-2","policyType":"replaceByLocalDir","localDir":{"sizeLimit":"1Gi"}},{"name":"source-hostpath-volume-3","policyType":"replaceByEmptyDir","emptyDir":{"sizeLimit":"10Gi"}}]'

    EVS supports three specifications: common I/O, high I/O, and ultra-high I/O. Set volumeType based on service requirements.

    Table 1 EVS specifications

    EVS Specification

    Disk Type

    Application Scenario

    Scenario Example

    Common I/O

    sata

    SATA is used for backend storage. If an application processes only a few transactions but requires a large capacity and moderate read/write speed, you can store data on common I/O EVS disks.

    Development testing and enterprise office applications

    High I/O

    sas

    SAS is used for backend storage. If an application requires high performance, high read/write speed, and real-time data storage, you can store data on high I/O EVS disks.

    File system creation and distributed file sharing

    Ultra-high I/O

    ssd

    SSD is used for backend storage. If an application processes large volumes of data and requires high performance and high read/write speed, you can store data on ultra-high I/O EVS disks.

    NoSQL, relational databases, and data warehouses (such as Oracle RAC and SAP HANA)

  • Ignore all hostPath volumes.
    "coordinator.cci.io/hostpath-replacement": '[{"name":"source-hostpath-volume-1","policyType":"remove"},{"name":"source-hostpath-volume-2","policyType":"replaceByLocalDir","localDir":{"sizeLimit":"1Gi"}},{"name":"source-hostpath-volume-3","policyType":"replaceByEmptyDir","emptyDir":{"sizeLimit":"10Gi"}}]'
  • Replace each hostPath volume with a different storage type.
    "coordinator.cci.io/hostpath-replacement": '[{"name":"source-hostpath-volume-1","policyType":"remove"},{"name":"source-hostpath-volume-2","policyType":"replaceByLocalDir","localDir":{"sizeLimit":"1Gi"}},{"name":"source-hostpath-volume-3","policyType":"replaceByEmptyDir","emptyDir":{"sizeLimit":"10Gi"}}]'

    Example (a Deployment):

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      annotations:
        description: ''
      labels:
        virtual-kubelet.io/burst-to-cci: enforce
        appgroup: ''
        version: v1
      name: test
      namespace: default
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: test
          version: v1
      template:
        metadata:
          labels:
            app: test
            version: v1
          annotations:
            coordinator.cci.io/hostpath-replacement: '[{"name": "test-log2", "policyType": "remove"}, {"name": "test-log", "policyType": "replaceByEmptyDir", "emptyDir":{"sizeLimit":"10Gi"}}, {"name": "test-log1", "policyType": "replaceByLocalDir", "localDir":{"sizeLimit":"1Gi"}}]'
        spec:
          containers:
            - name: container-1
              image: nginx
              imagePullPolicy: IfNotPresent
              env:
                - name: PAAS_APP_NAME
                  value: test
                - name: PAAS_NAMESPACE
                  value: default
                - name: PAAS_PROJECT_ID
                  value: 0b52a6e40b00d3682f36c0005163a82c
              resources:
                requests:
                  cpu: 250m
                  memory: 512Mi
                limits:
                  cpu: 250m
                  memory: 512Mi
              volumeMounts:
                - name: test-log
                  mountPath: /tmp/log
                - name: test-log1
                  mountPath: /tmp/log1
                - name: test-log2
                  mountPath: /tmp/log2
          volumes:
          - hostPath:
              path: /var/paas/sys/log/virtual-kubelet
              type: ""
            name: test-log
          - hostPath:
              path: /var/paas/sys/log
              type: ""
            name: test-log1
          - hostPath:
              path: /var/paas/sys/log2
              type: ""
            name: test-log2