2.4 KiB
2.4 KiB
一、Github仓库手动安装
1. clone 仓库
git clone https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner
cd nfs-subdir-external-provisioner/deploy
2. 修改deployment和rbac
- vim deployment.yaml
- vim rbac.yaml 替换namespace为你想部署pod的空间
- 执行以下命令
kubectl apply -f rbac.yaml
kubectl apply -f deployment.yaml
3. 创建存储类
kubectl apply -f class.yaml
4. 部署pvc和pod
kubectl apply -f test-claim.yaml
kubectl apply -f test-pod.yaml
5. pod的存储卷生命和pvc声明组合
---
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: nginx
---
apiVersion: apps/v1
kind: StatefulSet # StatefulSet 类型的资源
metadata:
name: web # StatefulSet 对象的名字
spec:
serviceName: "nginx" # 使用哪个 service 来管理 dns
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14
ports: # 容器内部要暴露的端口
- containerPort: 80 # 具体暴露的端口号
name: web # 该端口配置的名字
volumeMounts:
- mountPath: /usr/share/nginx/html
name: nginx-test-pvc
volumeClaimTemplates:
- metadata:
name: nginx-test-pvc
spec:
storageClassName: nfs-client
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
二、helm 安装
helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner --set nfs.server=192.168.0.12 --set nfs.path=/volume1/share