Overview
Kubernetes Engine (TKE) is a highly scalable high-performance container management service that provides multiple application release methods and continuous delivery capabilities, supports the micro-service architecture, solves environmental problems in user development, testing and Ops processes, and helps users lower the cost and improve efficiency.
For businesses using containers, such as business application deployment, DevOps, machine learning, auto-scaling and other scenes, there are usually a large number of configuration files, model files, log data, document attachments, etc. that need to be shared and accessed by multiple containers. Especially in the scenes of machine learning, intelligent recommendation and log data processing, in addition to basic data sharing, it is required that shared storage can provide services with high concurrent access, high throughput, high IOPS and low latency. Cloud File Storage (CFS) can provide the above-mentioned shared storage characteristics just by easy configuration and mounting on containers, which is especially suitable for use with container businesses. This document will introduce how to use CFS on TKE.
Prerequisites
The premise of this guide is that you have already created a container cluster. If you have not created the TKE, see Deploying Container Service Operation Guide to create a container first.
Apply for CFS Resources and Obtain A Mount Point IP
- If you do not have a file system yet, please follow the Creating CFS File System guide to create a file system. When it is created, please note that the VPC network should be selected under the same VPC as your container host to ensure network intercommunication.
- If you already have a file system under the same VPC as the TKE, you can go to the File System Details page for the mount point IP.
Configure A CFS File Mounting System
Step 1: Start the NFS Client on Node
Before mounting, make sure that nfs-utils or nfs-common has been installed in the system. The installation method is as follows:
CentOS
sudo yum install nfs-utilsUbuntu
sudo apt-get install nfs-common
Step 2: Create a PV
Create a PesistentVolume of type CFS by executing the following command.
Note:
- nfs.server: It is the mount point IP of the CFS file system that has been obtained above. In this example, it is assumed that the file system IP is 10.0.1.41.
- nfs.path: It is a root directory or subdirectory of the CFS file system. This case takes the root directory as an example.
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
Step 3: Create a PVC
Next, create a PersistentVolumeClaim to request the binding of the created PersistentVolume.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: cfsclaim
spec:
accessModes:
- ReadWriteMany
volumeMode: Filesystem
storageClassName: ""
resources:
requests:
storage: 10Gi
Step 4: Create a Pod
Create a Pod application to declare that the data volume is mounted and used.
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 completing the above steps, you can use this file system in the created Pod.