56 lines
986 B
YAML
56 lines
986 B
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: nginx-deployment-pvc
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app: nginx
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: nginx
|
|
spec:
|
|
containers:
|
|
- name: nginx
|
|
image: nginx
|
|
volumeMounts:
|
|
- name: wwwroot
|
|
mountPath: /usr/share/nginx/html
|
|
ports:
|
|
- containerPort: 80
|
|
volumes:
|
|
- name: wwwroot
|
|
persistentVolumeClaim:
|
|
claimName: nginx-pvc
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: nginx-pvc
|
|
# annotations: # 注释使用默认
|
|
# volume.beta.kubernetes.io/storage-class: "nfs-storage"
|
|
spec:
|
|
accessModes:
|
|
- ReadWriteMany
|
|
resources:
|
|
requests:
|
|
storage: 5Gi
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: nginx-svc
|
|
spec:
|
|
selector:
|
|
app: nginx
|
|
ports:
|
|
- name: http80
|
|
port: 80
|
|
protocol: TCP
|
|
targetPort: 80
|
|
type: ClusterIP
|