Study From https://jimmysong.io/kubernetes-handbook/practice/using-nfs-for-persistent-storage.html
1. 机器不FQ 所以手工download 了image 来处理.
需要的images
docker search nfs-client-provisioner
比较简单的处理方法:
docker pull registry.docker-cn.com/jmgao1983/nfs-client-provisioner
docker tag registry.docker-cn.com/jmgao1983/nfs-client-provisioner nfs-client-provisioner:1.0 # 为了简单便于测试....
2. 在本机安装NFS 以及进行简单的配置 exportfs -r 等处理
3. download 一些文档.
与 handbook 里面的一样 获取子目录
git clone https://github.com/kubernetes-incubator/external-storage.git
4. 首先修改 使用 deployment.yaml
kind: Deployment apiVersion: extensions/v1beta1 metadata: name: nfs-client-provisioner spec: replicas: 1 strategy: type: Recreate template: metadata: labels: app: nfs-client-provisioner spec: serviceAccountName: nfs-client-provisioner containers: - name: nfs-client-provisioner image: nfs-client-provisioner:1.0 volumeMounts: - name: nfs-client-root mountPath: /persistentvolumes env: - name: PROVISIONER_NAME value: fuseim.pri/ifs - name: NFS_SERVER value: 127.0.0.1 - name: NFS_PATH value: /nfs/gitlab volumes: - name: nfs-client-root nfs: server: 127.0.0.1 path: /nfs/gitlab
5. 创建 default 的 storage 随意命名即可 应该.
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: default provisioner: fuseim.pri/ifs
设置成默认的 pv 提供者
执行命令
kubectl patch storageclass default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
6. 需要执行创建 serviceaccount 和 role 以及 rolebinding 的 部分 (RBAC)
下载nfs-client 里面的三个文件 分别 kubectl -f 即可
ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
name: nfs-client-provisioner
第二个文件
clusterrole.yaml
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"] - apiGroups: [""] resources: ["endpoints"] verbs: ["get", "list", "watch", "create", "update", "patch"]
第三个文件
ClusterRoleBinding.yaml
kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: run-nfs-client-provisioner subjects: - kind: ServiceAccount name: nfs-client-provisioner namespace: default roleRef: kind: ClusterRole name: nfs-client-provisioner-runner apiGroup: rbac.authorization.k8s.io
创建执行即可,