init ci deployment for homelab k3s
This commit is contained in:
parent
1a166d0176
commit
b509e6ac8a
5 changed files with 60 additions and 0 deletions
10
Dockerfile
Normal file
10
Dockerfile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
FROM python:3.12-slim
|
||||
WORKDIR /app
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
||||
RUN pip install -U pip && adduser --disabled-password --gecos '' app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY . .
|
||||
USER app
|
||||
EXPOSE 8080
|
||||
CMD ["gunicorn","-w","2","-b","0.0.0.0:8080","app:app"]
|
||||
9
app.py
Normal file
9
app.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from flask import Flask
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.get("/")
|
||||
def hello():
|
||||
return "Hello from Flask on Kubernetes! 🚀"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=8080)
|
||||
21
helm/templates/deployment.yaml
Normal file
21
helm/templates/deployment.yaml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "flask-hello.fullname" . }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels: { app: {{ include "flask-hello.name" . }} }
|
||||
template:
|
||||
metadata:
|
||||
labels: { app: {{ include "flask-hello.name" . }} }
|
||||
spec:
|
||||
{{- if .Values.imagePullSecrets }}
|
||||
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 6 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: app
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
ports: [{ containerPort: {{ .Values.containerPort }} }]
|
||||
readinessProbe: { httpGet: { path: "/", port: {{ .Values.containerPort }} } }
|
||||
livenessProbe: { httpGet: { path: "/", port: {{ .Values.containerPort }} } }
|
||||
18
helm/values.yaml
Normal file
18
helm/values.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
image:
|
||||
repository: registry.gitlab.com/REPLACE_GROUP/REPLACE_PROJECT
|
||||
tag: "latest"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
replicaCount: 2
|
||||
containerPort: 8080
|
||||
servicePort: 8080
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
host: hello.example.com
|
||||
tls:
|
||||
enabled: true
|
||||
secretName: flask-hello-tls
|
||||
clusterIssuer: letsencrypt
|
||||
imagePullSecrets: []
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
flask==3.0.3
|
||||
gunicorn==22.0.0
|
||||
Loading…
Add table
Add a link
Reference in a new issue