| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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
- app = Flask(__name__)
-
- @app.route("/")
- def hello():
- return "<h1>Hello from Flask on port 8000!</h1>"
-
- @app.route("/hello")
- @app.route("/hello/")
- def hello_path():
- return "<h1>Hello from Flask /hello path! This redirects to root.</h1>"
-
- if __name__ == "__main__":
- app.run(host="0.0.0.0", port=8000)
- ' > /app.py && \
- python /app.py
- resources:
- requests:
- memory: "10Mi"
- cpu: "10m"
- limits:
- memory: "32Mi"
- cpu: "50m"
- ---
- 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
- annotations:
- kubernetes.io/ingress.class: "traefik"
- spec:
- rules:
- - host: 215.9981.tech
- http:
- paths:
- - path: /hello
- pathType: Prefix
- backend:
- service:
- name: flask-service
- port:
- number: 80
|