44 lines
883 B
YAML
44 lines
883 B
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: nginx-hostpath-demo
|
|
namespace: default
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: nginx-hostpath-demo
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: nginx-hostpath-demo
|
|
spec:
|
|
nodeSelector:
|
|
kubernetes.io/hostname: ylc61
|
|
containers:
|
|
- name: nginx
|
|
image: nginx:1.27-alpine
|
|
ports:
|
|
- containerPort: 80
|
|
volumeMounts:
|
|
- name: app-data
|
|
mountPath: /usr/share/nginx/html
|
|
volumes:
|
|
- name: app-data
|
|
hostPath:
|
|
path: /data/nginx-hostpath-demo
|
|
type: DirectoryOrCreate
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: nginx-hostpath-demo
|
|
namespace: default
|
|
spec:
|
|
selector:
|
|
app: nginx-hostpath-demo
|
|
ports:
|
|
- port: 80
|
|
targetPort: 80
|
|
type: ClusterIP
|