From c4580fc437400e8e35fd1950c6f47d6c92655aab Mon Sep 17 00:00:00 2001 From: Ivan087 Date: Fri, 28 Nov 2025 11:04:20 +0800 Subject: [PATCH] Auto-generated by Trail System --- Dockerfile | 14 ++++++++++++++ app.py | 16 ++++++++++++++++ chart/Chart.yaml | 6 ++++++ chart/templates/deployment.yaml | 24 ++++++++++++++++++++++++ chart/templates/service.yaml | 11 +++++++++++ chart/values.yaml | 6 ++++++ 6 files changed, 77 insertions(+) create mode 100644 Dockerfile create mode 100644 app.py create mode 100644 chart/Chart.yaml create mode 100644 chart/templates/deployment.yaml create mode 100644 chart/templates/service.yaml create mode 100644 chart/values.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27ada38 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Build stage +FROM python:3.9-slim as build +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Runtime stage +FROM python:3.9-slim +WORKDIR /app +COPY --from=build /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages +COPY . . +RUN pip install --no-cache-dir gunicorn +EXPOSE 5000 +CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"] \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..60c6594 --- /dev/null +++ b/app.py @@ -0,0 +1,16 @@ +from flask import Flask + +app = Flask(__name__) + +@app.route('/') +def todo_list(): + """Route to return the Todo List page.""" + return 'Todo List' + +@app.errorhandler(404) +def page_not_found(e): + """Handle 404 errors.""" + return 'Page not found', 404 + +if __name__ == '__main__': + app.run(debug=False) \ No newline at end of file diff --git a/chart/Chart.yaml b/chart/Chart.yaml new file mode 100644 index 0000000..ad39b58 --- /dev/null +++ b/chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: todo-app +description: A minimal Todo App built with Python Flask, containerized with Docker, and prepared for Kubernetes deployment via Helm. The application serves a simple 'Todo List' message at the root endpoint. +type: application +version: 0.1.0 +appVersion: "1.0.0" \ No newline at end of file diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml new file mode 100644 index 0000000..b690f36 --- /dev/null +++ b/chart/templates/deployment.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: todo-app +spec: + replicas: 1 + selector: + matchLabels: + app: todo-app + template: + metadata: + labels: + app: todo-app + spec: + containers: + - name: todo-app + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + ports: + - containerPort: 5000 + env: + - name: FLASK_APP + value: "app.py" + - name: FLASK_DEBUG + value: "false" \ No newline at end of file diff --git a/chart/templates/service.yaml b/chart/templates/service.yaml new file mode 100644 index 0000000..26cb1a2 --- /dev/null +++ b/chart/templates/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: todo-app-service +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.port }} + selector: + app: todo-app \ No newline at end of file diff --git a/chart/values.yaml b/chart/values.yaml new file mode 100644 index 0000000..29a4891 --- /dev/null +++ b/chart/values.yaml @@ -0,0 +1,6 @@ +image: + repository: todo-app + tag: latest +service: + port: 5000 + type: ClusterIP \ No newline at end of file