8、docker+k8s+kubesphere:nfs安装(2020-08-02更新)
8、docker+k8s+kubesphere:nfs安装server端安装在node151yum -y install nfs-utils rpcbind配置文件中的*是允许所有网段,根据自己实际情况写明网段cat >/etc/exports <<EOF/data *(insecure,rw,async,no_root_squash)EOF创建目录并修改权限mkdir /dat
·
8、docker+k8s+kubesphere:nfs安装
server端安装在node151
yum -y install nfs-utils rpcbind
配置文件中的*是允许所有网段,根据自己实际情况写明网段
cat >/etc/exports <<EOF
/data *(insecure,rw,async,no_root_squash)
EOF
创建目录并修改权限
mkdir /data && chmod 777 /data
systemctl enable nfs-server rpcbind && systemctl start nfs-server rpcbind
client端安装在node152、node153
yum -y install nfs-utils
在node152、node153执行
cat >nfs-storage.yaml <<EOF
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: nfs-provisioner
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: nfs-provisioner-runner
namespace: default
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: ["watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["services", "endpoints"]
verbs: ["get","create","list", "watch","update"]
- apiGroups: ["extensions"]
resources: ["podsecuritypolicies"]
resourceNames: ["nfs-provisioner"]
verbs: ["use"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: run-nfs-provisioner
subjects:
- kind: ServiceAccount
name: nfs-provisioner
namespace: default
roleRef:
kind: ClusterRole
name: nfs-provisioner-runner
apiGroup: rbac.authorization.k8s.io
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: nfs-client-provisioner
spec:
selector:
matchLabels:
app: nfs-client-provisioner
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: nfs-client-provisioner
spec:
serviceAccount: nfs-provisioner
containers:
- name: nfs-client-provisioner
image: quay.io/external_storage/nfs-client-provisioner:latest
imagePullPolicy: IfNotPresent
volumeMounts:
- name: nfs-client
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
value: fuseim.pri/ifs
- name: NFS_SERVER
value: 192.168.5.151 #此处修改为nfs服务器ip
- name: NFS_PATH
value: /data #这里为nfs共享目录
volumes:
- name: nfs-client
nfs:
server: 192.168.5.151 #此处修改为nfs服务器ip
path: /data #这里为nfs共享目录
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: nfs-storage
provisioner: fuseim.pri/ifs
reclaimPolicy: Retain
EOF
执行结果
[root@node152 ~]# kubectl apply -f nfs-storage.yaml
serviceaccount/nfs-provisioner created
clusterrole.rbac.authorization.k8s.io/nfs-provisioner-runner created
clusterrolebinding.rbac.authorization.k8s.io/run-nfs-provisioner created
deployment.apps/nfs-client-provisioner created
storageclass.storage.k8s.io/nfs-storage created
检查nfs-client pod状态
[root@node152 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nfs-client-provisioner-5cf8c79ff9-jhbmx 0/1 ContainerCreating 0 28s
检查默认存储
[root@node153 ~]# kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
nfs-storage fuseim.pri/ifs Retain Immediate false 2m40s
设置默认存储
分别在node151、node152、node153上执行
kubectl patch storageclass nfs-storage -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
查看默认存储
[root@node151 ~]# kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
nfs-storage (default) fuseim.pri/ifs Retain Immediate false 8d
[root@node152 ~]# kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
nfs-storage (default) fuseim.pri/ifs Retain Immediate false 8d
[root@node153 ~]# kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
nfs-storage (default) fuseim.pri/ifs Retain Immediate false 8d
多个(default)
更多推荐
已为社区贡献8条内容
所有评论(0)