| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: flask-app
- namespace: nginx-app
- labels:
- app: flask-app
- spec:
- replicas: 2
- selector:
- matchLabels:
- app: flask-app
- template:
- metadata:
- labels:
- app: flask-app
- spec:
- containers:
- - name: flask
- image: registry.cn-hangzhou.aliyuncs.com/zhongpengqun/wanderer:amd64-linux-python-3.10-slim
- ports:
- - containerPort: 8000
- env:
- - name: FLASK_APP
- value: "app.py"
- command:
- - sh
- - -c
- - |
- pip install flask && \
- echo '
- from flask import Flask, redirect
- app = Flask(__name__)
-
- @app.route("/")
- def hello():
- return "<h1>Hello from Flask on port 8000!</h1>"
-
- @app.route("/hello")
- @app.route("/hello/")
- def hello_redirect():
- return redirect("/")
-
- if __name__ == "__main__":
- app.run(host="0.0.0.0", port=8000)
- ' > /app.py && \
- python /app.py
- resources:
- requests:
- memory: "64Mi"
- cpu: "250m"
- limits:
- memory: "128Mi"
- cpu: "500m"
- ---
- apiVersion: v1
- kind: Service
- metadata:
- name: flask-service
- namespace: nginx-app
- labels:
- app: flask-app
- spec:
- selector:
- app: flask-app
- ports:
- - protocol: TCP
- port: 80
- targetPort: 8000
- type: ClusterIP
- ---
- apiVersion: networking.k8s.io/v1
- kind: Ingress
- metadata:
- name: flask-ingress
- namespace: nginx-app
- spec:
- ingressClassName: traefik # 使用新的ingressClassName字段
- rules:
- - host: 215.9981.tech
- http:
- paths:
- - path: /hello
- pathType: Prefix
- backend:
- service:
- name: flask-service
- port:
- number: 80
|