产品动态
local_goosefsx_pv.yamlapiVersion: v1kind: PersistentVolumemetadata:name: csi-goosefsx-local-pvspec:accessModes:- ReadWriteManycapacity:storage: 10GivolumeMode: FilesystempersistentVolumeReclaimPolicy: DeletestorageClassName: local-storagelocal:# 将此处的 path 更换成宿主机挂载 GooseFSx 的路径,然后删除此句提醒path: /goosefsx/x-c60-ow1j60r9-proxynodeAffinity:required:nodeSelectorTerms:- matchExpressions:- key: kubernetes.io/archoperator: Invalues:- amd64
参数 | 说明 |
name: csi-goosefsx-local-pv | 定义持久卷名称,根据实际情况进行修改。 |
accessModes: - ReadWriteMany | 定义访问模式,“ReadWriteMany” 是指可被多个节点以读写方式挂载。 |
storage: 10Gi | 定义存储容量,“10Gi” 是10GiB 存储容量,此参数不会限制文件系统所供给的容量; 实际存储容量是购买 GooseFSx 的容量,并随 GooseFSx 扩容而动态扩展;例如,购买 GooseFSx 容量是4.5TiB,存储容量是4.5TiB,非10GiB,扩容 GooseFSx 容量到9TiB,存储容量是9TiB。 |
volumeMode: Filesystem | 定义持久卷模式,是文件系统。 |
persistentVolumeReclaimPolicy: Delete | 定义回收策略,删除。 |
storageClassName: local-storage | 定义持久卷所属的类 “local-storage”,持久卷申领必须属于同一个类 “local-storage”;名称 “local-storage” 与 storageclass 存储类文件的 name “local-storage”保持一致。 |
local: path: /goosefsx/x-c60-ow1j60r9-proxy | 定义容器的存储空间来自宿主机的目录路径 “/goosefsx/x-c60-ow1j60r9-proxy”,即 GooseFSx 在宿主机上的挂载目录,根据实际情况进行修改。 |
nodeAffinity | 定义节点亲和性。 |
local_goosefsx_pvc.yamlapiVersion: v1kind: PersistentVolumeClaimmetadata:name: local-goosefsx-pvcspec:accessModes:- ReadWriteManyresources:requests:storage: 10GistorageClassName: local-storage
参数 | 说明 |
name: local-goosefsx-pvc | 定义持久卷申领的名称,根据实际情况进行修改。 |
accessModes: - ReadWriteMany | 定义访问模式,与定义持久卷一样。 |
resources: requests: storage: 10Gi | 定义存储容量,“10Gi” 是10GiB 存储容量,此参数不会限制文件系统所提供的容量;实际存储容量是购买 GooseFSx 的容量,并随 GooseFSx 扩容而动态扩展; 例如,购买 GooseFSx 容量是4.5TiB,存储容量是4.5TiB,非10GiB,扩容 GooseFSx 容量到9TiB,存储容量是9TiB。 |
storageClassName: local-storage | 定义持久卷申领 所属的类 “local-storage”,持久卷必须属于同一个类 “local-storage”;名称 “local-storage” 与 storageclass 存储类文件的 name “local-storage”保持一致。 |
local_goosefsx_storageclass.yamlkind: StorageClassapiVersion: storage.k8s.io/v1metadata:name: local-storageprovisioner: kubernetes.io/no-provisionervolumeBindingMode: WaitForFirstConsumer
参数 | 说明 |
name: local-storage | 定义存储类的名称为 “local-storage”,PV 持久化卷的 yaml 文件和 PVC 持久化卷申领的 yaml 文件会用上。 |
provisioner: kubernetes.io/no-provisioner | 定义 PV 持久化卷的 provisioner,GooseFSx 的 PV 持久化卷比较简单,不需要通过 StorageClass 来自动创建 PV 持久化卷。 |
volumeBindingMode:WaitForFirstConsumer | 定义卷绑定模式,该模式将延迟 PersistentVolume 的绑定和制备,直到使用该 PersistentVolumeClaim 的 Pod 被创建。 |
kubectl apply -f local_goosefsx_storageclass.yaml

kubectl apply -f local_goosefsx_pv.yaml

kubectl apply -f local_goosefsx_pvc.yaml

local_goosefsx_pod.yaml 如下:apiVersion: apps/v1kind: Deploymentmetadata:labels:k8s-app: local-goosefsx-dpname: local-goosefsx-dpspec:replicas: 1selector:matchLabels:k8s-app: local-goosefsx-podtemplate:metadata:labels:k8s-app: local-goosefsx-podspec:containers:- image: nginxname: local-goosefsx-podvolumeMounts:- mountPath: /local-goosefsxname: local-goosefsx-pvvolumes:- name: local-goosefsx-pvpersistentVolumeClaim:claimName: local-goosefsx-pvc
kubectl apply -f local_goosefsx_pod.yaml

kubectl get pod

kubectl exec -ti local-goosefsx-dp-7fb9b9f877-fcttx -- /bin/sh
pv.yaml :apiVersion: v1kind: PersistentVolumemetadata:name: csi-goosefsx-pvspec:accessModes:- ReadWriteManycapacity:storage: 10Gicsi:driver: com.tencent.cloud.csi.goosefsxvolumeHandle: csi-goosefsx-pvstorageClassName: ""
pvc.yaml :apiVersion: v1kind: PersistentVolumeClaimmetadata:name: csi-goosefsx-pvcspec:accessModes:- ReadWriteManyresources:requests:storage: 10GivolumeName: csi-goosefsx-pvstorageClassName: ""
csi-driver.yaml :apiVersion: storage.k8s.io/v1kind: CSIDrivermetadata:name: com.tencent.cloud.csi.goosefsxspec:attachRequired: falsepodInfoOnMount: falsefsGroupPolicy: File
csi-node.yaml :kind: DaemonSetapiVersion: apps/v1metadata:name: csi-goosefsx-nodenamespace: kube-systemspec:selector:matchLabels:app: csi-goosefsx-nodetemplate:metadata:labels:app: csi-goosefsx-nodespec:serviceAccount: csi-goosefsx-nodepriorityClassName: system-node-criticalhostNetwork: truehostPID: truecontainers:- name: driver-registrarimage: ccr.ccs.tencentyun.com/tkeimages/csi-node-driver-registrar:v2.0.1lifecycle:preStop:exec:command: ["/bin/sh", "-c", "rm -rf /registration/com.tencent.cloud.csi.goosefex /registration/com.tencent.cloud.csi.goosefsx-reg.sock"]args:- "--v=5"- "--csi-address=$(ADDRESS)"- "--kubelet-registration-path=/var/lib/kubelet/plugins/com.tencent.cloud.csi.goosefsx/csi.sock"env:- name: ADDRESSvalue: /plugin/csi.sock- name: KUBE_NODE_NAMEvalueFrom:fieldRef:fieldPath: spec.nodeNamevolumeMounts:- name: plugin-dirmountPath: /plugin- name: registration-dirmountPath: /registration- name: goosefsxsecurityContext:privileged: truecapabilities:add: ["SYS_ADMIN"]allowPrivilegeEscalation: trueimage: ccr.ccs.tencentyun.com/qcloud_goosefsx/goosefsx-csi:v1.0.1args:- "--v=5"- "--logtostderr=true"- "--nodeID=$(NODE_ID)"- "--endpoint=$(CSI_ENDPOINT)"# 将此处的 fileSystemId 更换成宿主机挂载的文件系统 ID,然后删除此句提醒- "--filesystemId=x-c60-s1bz66l4"env:- name: NODE_IDvalueFrom:fieldRef:fieldPath: spec.nodeName- name: CSI_ENDPOINTvalue: unix://plugin/csi.sockvolumeMounts:- name: plugin-dirmountPath: /plugin- name: goosefsx-mount-dirmountPath: /goosefsxmountPropagation: "Bidirectional"- name: pods-mount-dirmountPath: /var/lib/kubelet/podsmountPropagation: "Bidirectional"volumes:- name: plugin-dirhostPath:path: /var/lib/kubelet/plugins/com.tencent.cloud.csi.goosefsxtype: DirectoryOrCreate- name: registration-dirhostPath:path: /var/lib/kubelet/plugins_registrytype: Directory- name: pods-mount-dirhostPath:path: /var/lib/kubelet/podstype: Directory- name: goosefsx-mount-dirhostPath:path: /goosefsxtype: Directory
csi-rbac.yaml :apiVersion: v1kind: ServiceAccountmetadata:name: csi-goosefsx-nodenamespace: kube-system---kind: ClusterRoleapiVersion: rbac.authorization.k8s.io/v1metadata:name: csi-goosefsx-noderules:- apiGroups: [""]resources: ["persistentvolumeclaims/status"]verbs: ["patch", "update"]- apiGroups: [""]resources: ["configmaps", "events", "persistentvolumes","persistentvolumeclaims"]verbs: ["get", "list", "watch", "update", "patch"]- apiGroups: [""]resources: ["pods", "nodes"]verbs: ["get", "list", "watch"]- apiGroups: ["storage.k8s.io"]resources: ["storageclasses"]verbs: ["get", "list", "watch"]- apiGroups: ["storage.k8s.io"]resources: ["volumeattachments"]verbs: ["get", "list", "watch", "update"]- apiGroups: [""]resources: ["events"]verbs: ["list", "watch", "create", "update", "patch"]- apiGroups: ["coordination.k8s.io"]resources: ["leases"]verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]---kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata:name: csi-goosefsx-nodesubjects:- kind: ServiceAccountname: csi-goosefsx-nodenamespace: kube-systemroleRef:kind: ClusterRolename: csi-goosefsx-nodeapiGroup: rbac.authorization.k8s.io
kubectl apply -f csi-rbac.yamlkubectl apply -f csi-driver.yamlkubectl apply -f csi-node.yaml
kubectl get ds -n kube-system
kubectl apply -f pv.yamlkubectl apply -f pvc.yaml
pod.yaml 文件,样例如下:apiVersion: apps/v1kind: Deploymentmetadata:labels:k8s-app: csi-goosefsx-podname: csi-goosefsx-podspec:replicas: 1selector:matchLabels:k8s-app: csi-goosefsx-podtemplate:metadata:labels:k8s-app: csi-goosefsx-podspec:containers:- image: nginxname: csi-goosefsx-podvolumeMounts:- mountPath: /csi-goosefsxname: csi-goosefsxvolumes:- name: csi-goosefsxpersistentVolumeClaim:claimName: csi-goosefsx-pvc
kubectl apply -f pod.yaml
kubectl get pod
文档反馈