官方文檔:https://github.com/kubernetes-incubator/external-storage/tree/master/nfs
以自己?jiǎn)为?dú)安裝NFS系統(tǒng)為例
1、安裝nfs設(shè)置共享(生產(chǎn)環(huán)境建議使用云服務(wù)商提供的云共享存儲(chǔ)如:阿里云的NAS,AWS的EBS)
#yum install nfs-utils #每個(gè)節(jié)點(diǎn)安裝
#systemctl enable nfs
#cat /etc/exports
/data/data/nfs 192.168.1.0/24(rw,async)
2、安裝rbac,不安裝nfs-provisioner會(huì)報(bào)錯(cuò)沒(méi)有權(quán)限
#cat nfs-rbac.yml
apiVersion: v1 kind: ServiceAccount metadata: name: nfs-client-provisioner # replace with namespace where provisioner is deployed namespace: atang --- kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: nfs-client-provisioner-runner rules: - apiGroups: [""] resources: ["persistentvolumes"] verbs: ["get", "list", "watch", "create", "delete"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "watch", "update"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] - apiGroups: [""] resources: ["events"] verbs: ["create", "update", "patch"] --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: run-nfs-client-provisioner subjects: - kind: ServiceAccount name: nfs-client-provisioner # replace with namespace where provisioner is deployed namespace: atang roleRef: kind: ClusterRole name: nfs-client-provisioner-runner apiGroup: rbac.authorization.k8s.io --- kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: name: leader-locking-nfs-client-provisioner # replace with namespace where provisioner is deployed namespace: atang rules: - apiGroups: [""] resources: ["endpoints"] verbs: ["get", "list", "watch", "create", "update", "patch"] --- kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: leader-locking-nfs-client-provisioner # replace with namespace where provisioner is deployed namespace: atang subjects: - kind: ServiceAccount name: nfs-client-provisioner # replace with namespace where provisioner is deployed namespace: atang roleRef: kind: Role name: leader-locking-nfs-client-provisioner apiGroup: rbac.authorization.k8s.io
3、安裝nfs-client-provisioner
#cat nfs-provisioner.yml
apiVersion: apps/v1 kind: Deployment metadata: name: nfs-client-provisioner labels: app: nfs-client-provisioner # replace with namespace where provisioner is deployed namespace: atang spec: replicas: 1 strategy: type: Recreate selector: matchLabels: app: nfs-client-provisioner template: metadata: labels: app: nfs-client-provisioner spec: serviceAccountName: nfs-client-provisioner containers: - name: nfs-client-provisioner image: quay.io/external_storage/nfs-client-provisioner:latest volumeMounts: - name: nfs-client-root mountPath: /persistentvolumes env: - name: PROVISIONER_NAME value: www.zhongjima.net/nfs - name: NFS_SERVER value: 192.168.1.222 - name: NFS_PATH value: /data/data/nfs volumes: - name: nfs-client-root nfs: server: 192.168.1.222 path: /data/data/nfs
4、創(chuàng)建storageclass
#cat nfs-class.yml
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: atang-nfs namespace: atang provisioner: www.zhongjima.net/nfs mountOptions: - vers=4.1 parameters: archiveOnDelete: "false"
5、創(chuàng)建PVC測(cè)試
#cat nfs-pvc.yml
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: test-nfs annotations: volume.beta.kubernetes.io/storage-class: "atang-nfs" namespace: atang spec: accessModes: - ReadWriteMany resources: requests: storage: 100Mi
6、查看運(yùn)行狀態(tài)
#kubectl get pvc,sc,sa -n atang
相關(guān)閱讀:
Kubernetes1.20 創(chuàng)建pvc報(bào)錯(cuò)selfLink was empty, can’t make reference
贊
0
賞