All Products
Search
Document Center

Platform For AI:Mount storage to services (advanced)

Last Updated:Sep 06, 2023

This topic describes the following types of external storage that you can mount to service instances: Object Storage Service (OSS), Apsara File Storage NAS (NAS), Git repositories, Docker images, and emptyDir volumes.

Background information

Elastic Algorithm Service (EAS) allows you to mount the following types of external storage: OSS, NAS, Git repositories, Docker images, and emptyDir volumes. In the runtime of a service, you can mount the specific storage to one or more instances of a service. You can mount one or more types of external storage based on your business requirements. To mount external storage, add the storage field in the service configuration file. The field is used to specify the storage type, the path of the storage that you want to mount, and the path on service instances to which you want to mount the storage.

Mount an OSS bucket

To mount an OSS bucket, you must authorize EAS to read the specified path of the OSS bucket on the Elastic Algorithm Service page of the Machine Learning Platform for AI (PAI) console. For more information, see Activate and grant permissions on required Alibaba Cloud services.

  • Sample configurations in the service configuration file:

    {
      "name": "service_name",
      "storage": [
            {
                "mount_path": "/data_oss",
                "oss": {
                    "endpoint": "oss-cn-shanghai-internal.aliyuncs.com",
                    "path": "oss://bucket/path/"
                }
            }
        ]
    }
  • Parameters

    Parameter

    Description

    mount_path

    The path on service instances to which you want to mount the storage.

    oss.endpoint

    The internal endpoint of OSS in the region where the service instances reside. The internal endpoint contains -internal.

    oss.path

    The path of the OSS bucket to be mounted. The path must start with oss://.

Note

You can mount an OSS bucket to service instances only in dedicated resource groups.

Mount a NAS file system

You can mount a NAS file system that resides in the same region as service instances. To mount the NAS file system, you must use the internal domain name of a mount target in the NAS file system and connect service instances to the virtual private cloud (VPC) in which the NAS file system resides. For more information about how to configure the network connection, see Configure network connectivity.

  • Sample configurations in the service configuration file:

    {
        "name": "service_name",
        "storage": [
            {
                "mount_path": "/data_nas",
                "nfs": {
                    "path": "/",
                    "readOnly": false,
                    "server": "xxx.cn-shanghai.nas.aliyuncs.com"
                }
            }
        ]
    }
                            
  • Parameters

    Parameter

    Description

    mount_path

    The path on service instances to which you want to mount the storage.

    nfs.path

    The path of the NAS file system to be mounted.

    nfs.readOnly

    Specifies whether to access the storage that you want to mount in the read-only mode.

    nfs.server

    The domain name of the mount target.

Mount a Git repository

If a Git repository is mounted to service instances and EAS accesses the Git repository in the read-only mode, code in the Git repository can be pulled during the startup of service instances. The mounted Git repository is not updated automatically. If the code in the source Git repository changes, you must restart service instances to pull the latest code.

  • Sample configurations in the service configuration file:

    {
      "name": "service_name",
      "storage": [
        {
          "mount_path": "/data_git",
          "git": {
            "repo": "https://codeup.aliyun.com/xxx/eas/aitest.git",
            "username": "username",
            "password": "password or access token"
          }
        }
      ]
    }
  • Parameters

    Parameter

    Required

    Description

    mount_path

    Yes

    The path on service instances to which you want to mount the storage.

    git.repo

    Yes

    The HTTPS address of the Git repository to be mounted. The Git protocol is not supported.

    git.username

    No

    The username that is used to log on to the private Git repository.

    git.password

    No

    The password that is used to log on to the private Git repository.

    git.branch

    No

    The branch of the Git repository from which you want to pull code. Default value: master.

    git.commit

    No

    The commit ID of the Git repository from which you want to pull code.

Mount a Docker image

You cannot directly mount a Docker image to service instances. You must copy the files in the path of the Docker image to a local shared volume and mount the shared volume to service instances. If the data amount in the specified path is large, more local storage is consumed and the period used to start service instances is extended. If you want to use this feature, we recommend that you take these factors into consideration.

  • {
        "name": "service_name",
        "storage": [
            {
                "image": {
                    "image": "registry-vpc.cn-shanghai.aliyuncs.com/eas/test_image:v1",
                    "path": "/path/to/mount/"
                },
                "mount_path": "/data_image"
            }
        ]
    }
    Note

    You can mount a Docker image that resides in the same region as service instances. To mount the image, you must use the internal address of the image. If the image is from a private image repository, you can set the dockerAuth parameter to specify the authentication information used to access the private image repository. For more information about the description of the dockerAuth parameter, see Deploy a model service by using a custom image.

  • Parameters

    Parameter

    Description

    mount_path

    The path on service instances to which you want to mount the storage.

    image.image

    The internal address of the image.

    image.path

    The path of the image that you want to mount to service instances.

Mount an emptyDir volume

You can mount an emptyDir volume to your service instances to meet the following requirements: Running service instances can read data from and write data into a local disk, and the data written into the local disk can be retained even after service instances restart due to exceptions.

  • Sample configurations in the service configuration file:

    {
        "name": "service_name",
        "storage": [
            {
                "empty_dir": {},
                "mount_path": "/data_image"
            }
        ]
    }
  • Parameters

    Parameter

    Description

    mount_path

    The path on service instances to which you want to mount the storage.

    empty_dir

    The map object that specifies an emptyDir volume. The value must be left empty. You cannot configure other properties in this parameter.

Configure the shared memory

The following sample configurations show how to configure the shared memory.

{
    "name": "service_name",
    "storage": [
        {
            "empty_dir": {
              "medium": "memory",
              "size_limit": 20
            },
            "mount_path": "/dev/shm"
        }
    ]
}

Parameters:

  • medium: Set this parameter to memory.

  • mount_path: Set this parameter to /dev/shm.

  • size_limit: Specify the upper limit on the shared memory size. Unit: GB.

Complete configuration example

In the following sample complete configurations, an OSS bucket, NAS file system, Git repository, image, and emptyDir volume are mounted to a service instance.

{
    "name": "service_name",
    "model_path": "http://path/to/model",
    "processor": "pmml",
    "storage": [
        {
            "mount_path": "/data_oss1",
            "oss": {
                "endpoint": "oss-cn-shanghai-internal.aliyuncs.com",
                "path": "oss://bucket1/path/"
            }
        },
        {
            "mount_path": "/data_oss2",
            "oss": {
                "endpoint": "oss-cn-shanghai-internal.aliyuncs.com",
                "path": "oss://bucket2/path/"
            }
        },
        {
            "mount_path": "/data_nfs1",
            "nfs": {
                "path": "/",
                "readOnly": false,
                "server": "xxx.cn-shanghai.nas.aliyuncs.com"
            }
        },
        {
            "mount_path": "/data_nfs2",
            "nfs": {
                "path": "/",
                "readOnly": true,
                "server": "yyy.cn-shanghai.nas.aliyuncs.com"
            }
        },
        {
            "image": {
                "image": "registry-vpc.cn-shanghai.aliyuncs.com/eas/test_image:v1",
                "path": "/path/to/mount/"
            },
            "mount_path": "/data_image"
        },
        {
            "empty_dir": {
              "medium": "memory",
              "size_limit": 20
            },
            "mount_path": "/dev/shm"
        },
        {
            "mount_path": "/data_git",
            "git": {
                "repo": "https://codeup.aliyun.com/xxx/eas/aitest.git",
                "username": "username",
                "password": "password or access token"
            }
         }
    ],
    "metadata": {
        "cpu": 1,
        "instance": 1,
        "resource": "eas-r-xxx"
    }
}