bash
复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
name: python-deployment
spec:
replicas: 1
selector:
matchLabels:
app: python-app
template:
metadata:
labels:
app: python-app
spec:
containers:
- name: python-container
image: python:3.9
command: ["python", "-m", "http.server", "8000"]
ports:
- containerPort: 8000
volumeMounts:
- name: data-volume
mountPath: /app/data
subPath: data1
volumes:
- name: data-volume
hostPath:
path: /root/data
---
apiVersion: v1
kind: Service
metadata:
name: python-service
spec:
selector:
app: python-app
ports:
- protocol: TCP
port: 80
targetPort: 8000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: python-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: domain.com
http:
paths:
- path: /app1
pathType: Prefix
backend:
service:
name: python-service
port:
number: 80