FSX can be integrated with Elastic File Storage (EFS) and serves as a high-availability, POSIX-compliant file system client for EFS. Through this client, EFS storage can be mounted to a Linux system, enabling the storage to function as a local file system on the Linux system for data storage and management. This topic introduces how to use static EFS PersistentVolumes (PV) by using the FSX client.
- The csi-fsx and fsx-service add-ons have been installed and upgraded to the latest version. For details, see Upgrading add-ons.
- (Optional) You have obtained the AK/SK required for creating a key. This key will be used to mount EFS storage. For information about how to get the AK and SK, see Obtaining API access keys. To use a temporary token for authentication, you need to implement the logic for refreshing tokens.
- (Optional) The kubectl tool has been installed locally and connected to the target cluster via kubectl. For details, see Connecting to clusters.
- To use a temporary token for authentication, you need to implement the logic for refreshing tokens.
- StatefulSets require exclusive access to a volume, and do not support a manually created PersistentVolumeClaim (PVC).
- The FSX client currently supports only the x86_64 architecture. The client is currently not available on Windows and macOS. For details about supported environments, see Supported environments.
Creating through the console
- In the left navigation bar, click Cluster. Click the name of the target cluster to go to the cluster management page.
- In the left navigation bar on the cluster management page, click Storage > PersistentVolume.
- Click Create PersistentVolume and configure parameters on the page that appears.
- In the left navigation bar on the cluster management page, click Storage > PersistentVolumeClaim.
- Click Create PersistentVolumeClaim and configure parameters on the page that appears.
Step 3: Create an application and mount the PV
After the EFS PV is created, add the PV to a workload that will use the PV. Supported workloads include Deployment, StatefulSet, Job, CronJob, and DaemonSet.
You can add a PV to a workload when creating it or updating it. For details, see Workloads. Creating through kubectl
Step 1: (Optional) Create a policy
tip
- If you use the AK and SK of the root user, you can skip this step.
- To dynamically refresh temporary tokens, see AssumeRole.
The following is a JSON example for creating an EFS policy:
- Create a YAML document for the Secret. The following vke-efs-fsx-secret.yaml file serves as an example:
Description
You can use the echo -n "${ak}" | base64 command to perform Base64 encoding on items such as the AK and SK. Note that you need to replace ${ak} with your actual value. For example, if ${ak} is demo, the encoding command is echo -n "demo" | base64, which produces the encoded result ZGVtbw==.
- Run the following command to create the Secret.
- Create a YAML document for the PV. The following vke-efs-fsx-static-pv.yaml file serves as an example:
- Run the following command to create the PV.
- Create a YAML document for the PVC. The following vke-efs-fsx-static-pvc.yaml file serves as an example:
- Run the following command to create the PVC.
- Run the following command to view the result of the static association between the PVC and PV.
- If the response is similar to the following one, the binding is successful.
Step 5: Create an application and mount the PV
- Create a YAML document for the Deployment. The following vke-efs-fsx-static-deployment.yaml file serves as an example:
- Run the following command to create the Deployment.
After creating a workload and mounting a PV to it as described in the preceding steps, you can verify the volume mounting status and persistent storage via the following methods.
- Run the following command to check whether the PV is mounted to the specified path in the pod.
- The expected response is as follows.
- Check the mount path in the pod to view the data in the PV.
- The expected response is as follows.
- Check the mount path of the PV in the newly created pod.
- The expected result is as follows. You can see that the file written to the PV still exists and is not deleted along with the pod. This indicates that persistent storage of data is achieved.