In general, data is not persistently stored in a container. When a container is destroyed, data stored in it is lost. In the rapidly developing Internet environment, data loss is a disaster to an online production environment. Kubernetes clusters in Enterprise Distributed Application Service (EDAS) support Apsara File Storage NAS (NAS) and Persistent Volume Claim (PVC). This way, application instance data can be persistently stored and shared among instances. This way, multiple instances can read the data.

Prerequisites

Configure persistent storage when you create an application

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. In the upper part of the page, select a namespace. In the upper-left corner of the Applications page, click Create Application.
  3. In the Basic Information step, specify Cluster Type and Application Runtime Environment, and click Next.
    Parameter Description
    Cluster Type Select Kubernetes Clusters.
    Application Runtime Environment Select an application runtime environment based on the type of the hosted application.
    • Java
      • Custom: Select this option if you want to use a custom image to deploy the application in a Kubernetes cluster.
      • Java: Select this option if you want to use a universal JAR package to deploy the application as a Dubbo or a Spring Boot application. You can specify the Java Environment parameter after you select this option.
      • Tomcat: Select this option if you want to use a universal WAR package to deploy the application as a Dubbo or a Spring application. You can specify the Java Environment and Container Version parameters after you select this option.
      • EDAS-Container (HSF): Select this option if you want to use a WAR or FatJar package to deploy the application as a High-Speed Service Framework (HSF) application. You can specify the Java Environment, Pandora Version, and Ali-Tomcat Version parameters after you select this option.
    • PHP: Select this option if you want to run this application as a PHP application on Apache HTTP Server.
    • Node.js, C ++, Go, and Other Languages: Select this option if you want to use a custom image to deploy the application in a Kubernetes cluster. The configuration process for multi-language applications is not described in this topic. For more information, see Use custom images to deploy applications of different programming languages in Kubernetes clusters.
  4. In the Configurations step, configure the environment information, basic information, deployment method, and resource parameters for the application, and click Next.
  5. On the Advanced Settings tab, click Persistent Storage and set persistent storage information.
    Configure persistent storage
    Parameter Description
    Apsara File Storage NAS
    Note When you use the NAS service, make sure that your clusters have the FlexVolume component installed. For ASK clusters, make sure that the NAS mount directory exists. NAS is billed based on actual usage. For more information, see NAS Pricing.
    Storage Type The default value is Apsara File Storage NAS, which cannot be changed.
    Storage Service Type The default value is SSD (Performance-type), which cannot be changed.
    Select NAS
    • Buy New NAS: Select a NAS mount directory and a local mount directory. A single region supports up to 10 NAS file systems. When this number in a single region exceeds 10, your attempt to create more NAS file systems fails. To create more NAS file systems, submit a ticket.
    • Use Existing NAS: Select an existing NAS file system. You can create up to two mount targets. Only compliant NAS file systems appear in the drop-down list.
    Mount Directory Set the NAS Mount Directory and Mount Directory in Container parameters.
    PVC Mount
    Note PVC mounts that you configure by modifying YAML files are not displayed. These configurations can be retained only during deployment. We recommend that you use EDAS to configure PVC mounts when you deploy applications.
    Select PVC Select a PVC from the drop-down list. If no PVC is available, create a PVC. For more information, see Create a PVC.
    Mount Configuration Set Mount Directory and Mount Mode.
  6. Click Create Application.
  7. In the Creation Completed step, confirm the settings in Basic Information, Configurations, and Advanced Settings, and click Create Application.
    In the upper part of the Application Overview page, click View Details. On the Change List page, you can view the change process. Wait a few minutes until the application is deployed. After the change process is complete, view the running status of the instances in the Basic Information section of the Application Overview page. If the pod that runs the application is in the running state, the application is deployed.

Configure persistent storage when you update an application

You can configure a NAS file system and PVC mounts for persistent storage when you create an application, or configure or update the NAS file system and PVC mounts when you deploy an application.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. On the Applications page, select a namespace in the upper part, and select Container Service or Serverless Kubernetes Cluster from the Cluster Type drop-down list. Then, find the application that you want to deploy, and click the application name.
  3. On the Application Overview or Basic Information page, choose Deploy > Deploy in the upper-right corner.
  4. On the Select Deployment Mode page, select a deployment mode and click Start Deployment in the upper-right corner of the specified deployment mode section.
  5. Set the parameters for the application environment and deployment package, click Persistent Storage, complete the configuration, and then click OK.
    Configure persistent storage
    Parameter Description
    Apsara File Storage NAS
    Note When you use the NAS service, make sure that your clusters have the FlexVolume component installed. For ASK clusters, make sure that the NAS mount directory exists. NAS is billed based on actual usage. For more information, see NAS Pricing.
    Storage Type The default value is Apsara File Storage NAS, which cannot be changed.
    Storage Service Type The default value is SSD (Performance-type), which cannot be changed.
    Select NAS
    • Buy New NAS: Select a NAS mount directory and a local mount directory. A single region supports up to 10 NAS file systems. When this number in a single region exceeds 10, your attempt to create more NAS file systems fails. To create more NAS file systems, submit a ticket.
    • Use Existing NAS: Select an existing NAS file system. You can create up to two mount targets. Only compliant NAS file systems appear in the drop-down list.
    Mount Directory Set the NAS Mount Directory and Mount Directory in Container parameters.
    PVC Mount
    Note PVC mounts that you configure by modifying YAML files are not displayed. These configurations can be retained only during deployment. We recommend that you use EDAS to configure PVC mounts when you deploy applications.
    Select PVC Select a PVC from the drop-down list. If no PVC is available, create a PVC. For more information, see Create a PVC.
    Mount Configuration Set Mount Directory and Mount Mode.
    Notice The application is restarted after you click OK. We recommend that you perform this operation during off-peak hours.

Verify the result

Linux, UNIX, and macOS

  • Method 1: Run the following command on the application instance to check whether the application contains NAS mount information. We recommend that you use this method.
    cat /proc/mount | grep nfs

    If the following information appears, the NAS file system is mounted.

    NAS file system mounted
  • Method 2: Use WebShell to read and write files and check whether the NAS file system is mounted.

    Example:

    Prepare application instances A and B and mount the NAS file system to the two application instances. Run the write command echo "hello" > tmp.txt on Instance A and the read command cat tmp.txt on Instance B. If Instance B can read hello that is written to Instance A, the NAS file system is mounted.

Windows

  • Recommended. In the NAS console, check whether the instance IP address of the application appears in the Client mounted dialog box of the mount target.
    Notice In the Client mounted dialog box, only the IP addresses of the clients that use the NAS file system within the last minute are displayed.
    1. Log on to the NAS console.
    2. Click the created file system. On the page that appears, click Mounting Use in the left-side navigation pane. On the Mount Target page, click Client mounted in the Operations column.
    3. In the Client mounted dialog box, check whether the instance IP address of the application appears. Then, log on to the EDAS console and check the pod IP address of the application.

      If the IP addresses are the same, the NAS file system is mounted.

  • In the EDAS console, view the change status on the change process details page. If the change status is Succeeded, the application is deployed and the NAS file system is mounted.

Remove persistent storage

If you no longer need persistent storage, you can redeploy the application to remove the NAS file system and PVC.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. On the Applications page, select a namespace in the upper part, and select Container Service or Serverless Kubernetes Cluster from the Cluster Type drop-down list. Then, find the application that you want to deploy, and click the application name.
  3. On the Application Overview or Basic Information page, choose Deploy > Deploy in the upper-right corner.
  4. On the Select Deployment Mode page, select a deployment mode and click Start Deployment in the upper-right corner of the specified deployment mode section.
  5. Set the parameters for the application environment and deployment package, click Persistent Storage, unmount the NAS file system, and then click OK.
    Notice The application is restarted after you click OK. We recommend that you perform this operation during off-peak hours.
    After you unmount the NAS file system in the EDAS console, the data stored in it is retained.

FAQ

  • How do I view the content in a NAS file system?

    To view information in the NAS file system, you must mount the NAS file system to an Elastic Compute Service (ECS) instance or a container. For more information, see Mount an NFS file system on an ECS Windows instance or Recommended mount methods.

  • Can the destination directory specified for log files be the same as that specified for the NAS file system?

    No, the destination directory specified for log files cannot be the same as that specified for the NAS file system.