apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-volume-10m
labels:
type: local
spec:
storageClassName: my-nfs-storage
capacity:
storage: 10m
accessModes:
- ReadWriteOnce
nfs: ## 使用nfs存储系统
server: 10.170.11.8 ## 没type
path: /nfs/data/haha ### abc文件夹提前创建
apiVersion: v1
kind: Pod
metadata:
name: "nginx-pvc-000"
namespace: default
labels:
app: "nginx-pvc-000"
spec:
containers:
- name: nginx-pvc-000
image: "nginx"
ports:
- containerPort: 80
name: http
volumeMounts:
- name: localtime
mountPath: /etc/localtime
- name: html
mountPath: /usr/share/nginx/html
volumes:
- name: localtime
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
- name: html
persistentVolumeClaim:
claimName: nginx-pvc ### 你的申请书的名字
restartPolicy: Always
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx-pvc
namespace: default
labels:
app: nginx-pvc
spec:
storageClassName: my-nfs-storage ## 存储类的名字
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 70m
# ---
# apiVersion: v1
# kind: Service
# metadata:
# name: MYAPP
# namespace: default
# spec:
# selector:
# app: MYAPP
# type: ClusterIP
# ports:
# - name: MYAPP
# port:
# targetPort:
# protocol: TCP
# nodePort:
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-volume-12m-recycle
labels:
type: local
spec:
persistentVolumeReclaimPolicy: Recycle ## 回收
storageClassName: my-nfs-storage
capacity:
storage: 12m
accessModes:
- ReadWriteOnce
nfs: ## 使用nfs存储系统
server: 10.170.11.8 ## 没type
path: /nfs/data/recycle ### abc文件夹提前创建
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-12-recycle
namespace: default
labels:
app: pv-12-recycle
spec:
storageClassName: my-nfs-storage ### pv分组
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 12m