Found 0 result in total
Content is empty
If you don't find the content you expect, please try another search term
Last updated:2021-05-11 10:41:17
You can use KFS volumes in Kubernetes clusters of KCE.
Kingsoft Cloud provides the following methods for you to mount KFS volumes to Kubernetes:
Static volume
You can use KFS static volumes by using one of the following two methods:
A KFS file system is created before the file system can be mounted.
disk-provisioner
component in the kube-system
namespace of the clusters. For more information about the YAML file, see Appendix.In the preceding figure:
The server version is 10.0.1.***.
The mount path is ** /***-7EVaUh33Wd /mnt.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kfs
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: "kfs"
mountPath: "/data"
volumes:
- name: "kfs"
nfs:
server: "10.0.1.x"
path: "/share-2c51940a-6261-4044-addc-xxxxxxx"
Create a PV:
apiVersion: v1
kind: PersistentVolume
metadata:
name: kfs-pv
spec:
storageClassName: "kfs"
capacity:
storage: 100Mi
accessModes:
- ReadWriteMany
mountOptions:
- nfsvers=3
nfs:
server: 10.0.1.x
path: "/share-2c51940a-6261-4044-addc-xxxxxxx"
Create a PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: kfs-pvc
spec:
storageClassName: "kfs"
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
Create a deployment:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kfs-deploy
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: kfs
mountPath: "/data"
volumes:
- name: kfs
persistentVolumeClaim:
claimName: kfs-pvc
Parameter | Description |
---|---|
server | The IP address of the KFS server. This parameter is required. |
path | The mount directory of the KFS volume. A mount directory is automatically created if no sub-directory is available. This parameter is required. |
archiveOnDelete | The way of processing the KFS volume mount directory when a PVC or a PV is deleted. If reclaimPolicy is set to Delete and archiveOnDelete is set to false, the mount directory and data are directly deleted. Use this setting with caution. If reclaimPolicy is set to Delete and archiveOnDelete is set to true, the mount directory is deleted and a mount directory backup is created with another name. If reclaimPolicy is set to Retain, the mount directory is retained without modifications. This parameter is optional. The default value is false. |
storageType | The storage type. Set the value to ksc/kfs, indicating that KFS is used. This parameter is required. |
Create a StorageClass:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ksc-kfs
parameters:
server: 10.0.1.xx
path: /cfs-AyQaA3xxxx/test-path
archiveOnDelete: "false"
storageType: ksc/kfs
provisioner: ksc/storage
Create a StatefulSet:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: test
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: www
mountPath: "/data"
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes:
- ReadWriteOnce
storageClassName: ksc-kfs
resources:
requests:
storage: 10Gi
The YAML file of the disk-provisioner
component is as follows:
apiVersion: apps/v1
kind: Deployment
metadata:
name: disk-provisioner
namespace: kube-system
spec:
selector:
matchLabels:
app: disk-provisioner
replicas: 1
revisionHistoryLimit: 2
template:
metadata:
labels:
app: disk-provisioner
spec:
dnsPolicy: Default
tolerations:
# this taint is set by all kubelets running `--cloud-provider=external`
- key: "node.cloudprovider.kubernetes.io/uninitialized"
value: "true"
effect: "NoSchedule"
containers:
- image: hub-cn-shanghai-2.kce.ksyun.com/ksyun/disk-provisioner:v1.6.0
name: ebs-provisioner
env:
- name: OPENAPI_ENDPOINT
value: "internal.api.ksyun.com"
- name: OPENAPI_PREFIX
value: "http"
volumeMounts:
- name: kubeconfig
mountPath: /root/.kube/config
- name: clusterinfo
mountPath: /opt/app-agent/arrangement/clusterinfo
- image: hub-cn-shanghai-2.kce.ksyun.com/ksyun/disk-provisioner:v1.6.0
name: ksc-storage-provisioner
securityContext:
privileged: true # do mount
args:
- --provisioner=ksc/storage
env:
- name: OPENAPI_ENDPOINT
value: "internal.api.ksyun.com"
- name: OPENAPI_PREFIX
value: "http"
volumeMounts:
- name: kubeconfig
mountPath: /root/.kube/config
- name: clusterinfo
mountPath: /opt/app-agent/arrangement/clusterinfo
volumes:
- name: kubeconfig
hostPath:
path: /root/.kube/config
- name: clusterinfo
hostPath:
path: /opt/app-agent/arrangement/clusterinfo
Pure Mode