linux

nfs server安装&&k8s中部署nfs provisionernfs server安装&&

1.nfs server安装

1.1节点信息

192.168.0.203  

1.2.nfs server端

安装nfs服务
[root@MES-203 home]#yum -y install rpcbind nfs-utils

创建共享目录
[root@MES-203 home]# mkdir -p /home/nfsShare
[root@MES-203 home]#chmod 755 /home/nfsShare

配置nfs
[root@MES-203 home]# cat /etc/exports
/home/nfsShare/ 192.168.0.0/16(rw,no_root_squash)

使配置立即生效
  [root@MES-203 home]#exportfs -r

启动
 [root@MES-203 home]#systemctl start rpcbind
[root@MES-203 home]# systemctl start nfs
[root@MES-203 home]# systemctl enable nfs
[root@MES-203 home]# systemctl enable rpcbind

查看挂载点
showmount -e

1.3nfs client端测试

在192.168.0.204上测试

安装工具
[root@MES-204 ~]# yum -y install nfs-utils rpcbind

查看下服务端挂载点
[root@MES-204 ~]# showmount -e 192.168.0.203
Export list for 192.168.0.203:
/home/nfsShare 192.168.0.0/16

挂载
[root@MES-204 ~]# mkdir /root/nfstest
[root@MES-204 ~]# mount -t nfs 192.168.0.203:/home/nfsShare/ /root/nfstest

查看
取消挂载
[root@MES-204 ~]# umount /root/nfstest

2.k8s中部署nfs provisioner-用于storageClass

修改了NFS_SERVER 和path处

也修改了namespace为middleware

nfs server: 192.168.0.203
 path: /home/nfsShare

直接kubectl apply -f nfs.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-nfs-storage
provisioner: fuseim.pri/ifs
parameters:
  archiveOnDelete: "false"
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
  namespace: middleware
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: nfs-client-provisioner
  namespace: middleware
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nfs-client-provisioner
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccount: 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: fuseim.pri/ifs
            - name: NFS_SERVER
              value: 192.168.0.203
            - name: NFS_PATH
              value: /home/nfsShare
      volumes:
        - name: nfs-client-root
          nfs:
            server: 192.168.0.203
            path: /home/nfsShare
    ---
    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: [""]
  resources: ["endpoints"]
  verbs: ["get", "list", "watch", "create", "update", "patch"]
- 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
  namespace: middleware
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
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
subjects:
- kind: ServiceAccount
  name: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: middleware
roleRef:
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io

参考文献

https://nacos.io/zh-cn/docs/use-nacos-with-kubernetes.html

留言

您的邮箱地址不会被公开。 必填项已用 * 标注

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。