Tencent Kubernetes Engine (TKE) is a container management service with high scalability and performance. It provides a variety of application release methods and continuous delivery capabilities and supports microservice architectures. It can solve environment-related issues in the process of development, testing, and OPS and help you reduce costs and improve efficiency.
Businesses using containers usually involve shared access by multiple containers to a high number of configuration files, model files, log data, and attachments in such scenarios as business application deployment, DevOps, machine learning, and auto-scaling. Especially, in scenarios like machine learning, intelligent recommendation, and log data processing, in addition to basic data sharing, shared storage is also required to provide services that feature high throughput, high IOPS, and low latency and can sustain high concurrent requests. CFS can provide such services after simple configuration and mount to containers, making it particularly suitable for use in conjunction with TKE. This document describes how to use CFS on TKE.
You have already created a TKE cluster. If you haven't done so, please create one first as instructed in Deploying TKE.
Before mounting, please make sure that
nfs-common has already been installed in the system. The installation method is as follows:
sudo yum install nfs-utils
sudo apt-get install nfs-common
Run the following command to create a PesistentVolume (PV) of CFS type.
apiVersion: v1 kind: PersistentVolume metadata: name: cfs spec: capacity: storage: 10Gi volumeMode: Filesystem accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain mountOptions: - hard - nfsvers=4 nfs: path: / server: 10.0.1.41
- nfs.server: mount point IP of the CFS file system obtained above. The file system IP is 10.0.1.41 in this example.
- nfs.path: root directory or subdirectory of the CFS file system. The root directory is used in this example.
Then, create a PersistentVolumeClaim (PVC) and bind it to the PV.
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: cfsclaim spec: accessModes: - ReadWriteMany volumeMode: Filesystem storageClassName: "" resources: requests: storage: 10Gi
Create a pod to declare that this volume is used for mounting.
kind: Pod apiVersion: v1 metadata: name: mypod spec: containers: - name: myfrontend image: nginx volumeMounts: - mountPath: "/var/www/html" name: mypd volumes: - name: mypd persistentVolumeClaim: claimName: cfsclaim
After the above steps are completed, you can use the file system in the newly created pod.