This topic describes how to configure an Apsara File Storage NAS file system and its
dependent resources. This topic also shows you how to run the fun nas
command to manage NAS files after the configuration.
Background information
- Use the
NasConfig: Auto
property to configure a NAS file system and its dependent Virtual Private Cloud (VPC) resources.You can store large-scale and fixed resources in NAS when you use Function Compute. After you configure a NAS file system and its dependent resources, the functions of a specified service can access the NAS file system in the same way as they access an on-premises file system. This way, you can use Function Compute to efficiently develop a serverless application that depends on large-scale resources.
However, the complex configurations of the NAS file system increase the difficulty in using Function Compute. To simplify the NAS configuration process, the
NasConfig: Auto
property is added to Funcraft. You can use this property to configure a NAS file system and its dependent VPC resources. - Run the
fun nas
command to manage NAS files and upload on-premises NAS files.After you configure the NAS file system, you must upload on-premises files to the NAS file system. You can use one of the following methods to upload on-premises files to the NAS file system:- Buy an Elastic Compute Service (ECS) instance, mount the NAS file system, and use an FTP server or a file hosting service to upload files to the NAS file system.
- Use Data Transport to migrate Object Storage Service (OSS) resources to the NAS file system. For more information, see Background information.
- Use Function Compute to develop a serverless application to manage NAS files. For more information, see Guidelines for Function Compute Development - Develop an Application to Manage NAS Files.
- Run the
fun nas
command to manage NAS files and upload on-premises NAS files.Thefun nas
command provides an upgraded version of the third method to resolve the following issues:- A service must be manually deployed.
- Directories cannot be uploaded.
- Files larger than 6 MB in size cannot be uploaded.
Features of the fun nas command
fun nas
command:fun nas -h
Expected output:Usage: fun nas [options] [command]
Operate your remote NAS file system locally.
Options:
-h, --help display help for command
Commands:
info Print nas config information, such as local temp directory of NAS.
init For each service with NAS config, create local NAS folder and deploy fun nas server service.
sync Synchronize the local NAS directory with the remote NAS file system.
ls List contents of remote NAS directory
rm Remove remote NAS file.
cp copy local file/folder to remote NAS
help [command] display help for command
Configure a NAS file system
This section describes how to configure a NAS file system in two ways. Your functions can access specified NAS resources after the configuration. We recommend that you use Method 2 to configure a NAS file system.
Method 1
Use the NAS console and the VPC console to configure a NAS file system and its dependent resources.
Method 2
Use the template.yml file and the fun deploy
command to configure a NAS file system and its dependent resources.
References
You can run the following commands to view the features of the fun nas
command.
NasConfig: Auto
property:ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
nasDemo:
Type: 'Aliyun::Serverless::Service'
Properties:
NasConfig: Auto
- Run the following command in the root directory to initialize the configurations:
fun nas init
Expected output:start fun nas init... Waiting for service fun-nas-NasDemo to be deployed... ... ... using 'VpcConfig: Auto', Fun will try to generate related vpc resources automatically ... ... generated auto VpcConfig done: {"vpcId":"vpc-bp1pcr7o8ksmgojt4****","vswitchIds":["vsw-bp13qdw9qe1i2it4y****"],"securityGroupId":"sg-bp161u0547x0lq5k****"} using 'NasConfig: Auto', Fun will try to generate related nas file system automatically ... ... generated auto NasConfig done: {"UserId":100**,"GroupId":100**,"MountPoints":[{"ServerAddr":"****c4a6d9-gry74.cn-hangzhou.nas.aliyuncs.com:/fun-nas-NasDemo","MountDir":"/mnt/auto"}]} Checking if nas directories /mnt/auto/fun-nas-NasDemo exists, if not, it will be created automatically Checking nas directories done ["/mnt/auto/fun-nas-NasDemo"] ... ... service fun-nas-NasDemo deploy success Fun nas init Success Tips for next step ====================== $ fun nas info # Show NAS info $ fun nas ls # List NAS files $ fun nas sync # Synchronize files to nas $ fun deploy # Deploy Resources
Note After you run thefun nas init
command, a NAS file system and its dependent VPC resources are created. If you modify the NAS or VPC configuration, you need only to run thefun nas init
orfun vpc init
command to initialize the configurations. - Run the following command in the root directory to view the NAS directory:
fun nas info
Expected output:Local NAS folder of service NasDemo includes: /NasDemo/.fun/nas/auto-default/NasDemo
- Run the following command in the root directory to synchronize the information about
on-premises NAS resources. If the on-premises NAS resources are modified, you need
only to run the following command again:
fun nas sync
Expected output:Starting upload /NasDemo/.fun/nas/auto-default/NasDemo to nas://NasDemo:/mnt/auto/ NAS path checking... zipping /NasDemo/.fun/nas/auto-default/NasDemo /NasDemo/.fun/nas/auto-default/.NasDemo.zip - zipped generate tmpDir: /NasDemo/.fun/nas/auto-default/.fun_nas_tmp/42658c92eef63f2b3b13e5f46315ee7d Split zip file to 1 small files Uploading... Upload /NasDemo/.fun/nas/auto-default/NasDemo to /mnt/auto/ done!
- Run one of the following commands in the root directory to view NAS files:
- Use
fun nas ls nas://ServiceName/Path
to display the files pointed by the NAS path in a service. Run the following command to view the NAS files:
Expected output:fun nas ls -a nas://NasDemo/mnt/auto
total 10 drwxr-xr-x 4 user10003 10003 4096 Aug 4 11:38 . drwxr-xr-x 1 root root 4096 Aug 4 11:37 .. drwxr-xr-x 4 user10003 10003 4096 Aug 4 11:38 .fun_nas_tmp -rw-r--r-- 1 user10003 10003 19 Aug 4 11:38 test drwxr-xr-x 2 user10003 10003 4096 Aug 4 11:38 testDir
- If the template.yml file declares only one service, you can use the
fun nas ls nas:///Path
command by removing the ServiceName parameter. Run the following command to view the NAS files:fun nas ls -a nas://mnt/auto
- Use