手動創(chuàng)建PV以及綁定PVC
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
nfs:
path: /path/to/nfs/directory
server: 192.168.1.100 # 替換為你的 NFS 服務器 IP
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: example-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
ingress模板
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
namespace: default
annotations:
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, PUT, DELETE, OPTIONS"
nginx.ingress.kubernetes.io/cors-allow-headers: "Content-Type, Authorization"
nginx.ingress.kubernetes.io/cors-max-age: "86400"
nginx.ingress.kubernetes.io/proxy-body-size: "50m" # 設置文件上傳大小限制
nginx.ingress.kubernetes.io/proxy-read-timeout: "60" # 讀超時時間(秒)
nginx.ingress.kubernetes.io/proxy-send-timeout: "60" # 寫超時時間(秒)
nginx.ingress.kubernetes.io/client-body-timeout: "60" # 客戶端超時
spec:
tls:
- hosts:
- example.com # 指定需要支持 HTTPS 的域名
secretName: example-tls # 引用存儲證書的 Secret 名稱
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: example-service
port:
number: 80