k8s 部署nfs storeclass
yum install rpcbind nfs-utils -ysystemctl enable nfs-server.servicesystemctl enable rpcbind.servicesystemctl start nfs-server.servicesystemctl start rpcbind.servicemkdir /nfsdataecho'/nfsdata 192.168.
·
yum install rpcbind nfs-utils -y
systemctl enable nfs-server.service
systemctl enable rpcbind.service
systemctl start nfs-server.service
systemctl start rpcbind.service
mkdir /nfsdata
echo '/nfsdata 192.168.11.0/24(rw,sync,fsid=0)' >> /etc/exports
exportfs -ra
vi deployment.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: nfs-client-provisioner
namespace: kube-system
---
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: ["list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["endpoints","services"]
verbs: ["get", "list", "watch","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: kube-system
roleRef:
kind: ClusterRole
name: nfs-client-provisioner-runner
apiGroup: rbac.authorization.k8s.io
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: nfs-provisioner-01
namespace: kube-system
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: nfs-provisioner-01
template:
metadata:
labels:
app: nfs-provisioner-01
spec:
serviceAccountName: nfs-client-provisioner
containers:
- name: nfs-client-provisioner
image: quay.io/external_storage/nfs-client-provisioner:latest
imagePullPolicy: IfNotPresent
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
# 此处供应者名字供storageclass调用
value: nfs-provisioner-01
- name: NFS_SERVER
value: 192.168.11.193
- name: NFS_PATH
value: /nfs4k8s
volumes:
- name: nfs-client-root
nfs:
server: 192.168.11.193
path: /nfs4k8s
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: nfs-dynamic-class
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: nfs-provisioner-01
parameters:
archiveOnDelete: "false"
kubectl apply -f deployment.yaml
更多推荐
已为社区贡献9条内容
所有评论(0)