Compare commits
No commits in common. "e983a425c6bdb30c8180a982984c94a182592b1e" and "f8acc55f67ae633ebc38f794533fdfcc0a556dc7" have entirely different histories.
e983a425c6
...
f8acc55f67
13
app.py
13
app.py
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
import random
|
||||
import configparser
|
||||
import requests
|
||||
from flask import Flask, render_template_string, jsonify, send_from_directory
|
||||
|
|
@ -11,16 +10,6 @@ OLLAMA_MODEL = os.environ.get("OLLAMA_MODEL", "gemma4:e4b")
|
|||
PROMPT = os.environ.get("JOKE_PROMPT", "tell me a dad joke about programming")
|
||||
PORT = int(os.environ.get("PORT", "80"))
|
||||
|
||||
PRESET_JOKES = [
|
||||
"What do you call parenting with a software engineer? Pair programming (or O-pair programming).",
|
||||
"My kids were rolling on the floor and screaming. My wife asked what was happening, and I told her it was a version conflict.",
|
||||
"When I wrote this code, only God and I knew how it worked. Now, only God knows.",
|
||||
"A programmer is sent to the store by his wife: “Get a gallon of milk, and if they have eggs, get a dozen.” The programmer returns home with 13 gallons of milk and says, “They had eggs”.",
|
||||
"Where do coder dads store all their projects? In a dad-abase.",
|
||||
"Why don't programmers like going outside into nature? Too many bugs.",
|
||||
"Why did the programmer die taking a shower? The shampoo bottle instructions said: Lather. Rinse. Repeat."
|
||||
]
|
||||
|
||||
def get_app_version():
|
||||
config = configparser.ConfigParser()
|
||||
version_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "version.ini")
|
||||
|
|
@ -707,7 +696,7 @@ def request_joke():
|
|||
|
||||
@app.route("/")
|
||||
def index():
|
||||
joke = random.choice(PRESET_JOKES)
|
||||
joke = request_joke()
|
||||
version = get_app_version()
|
||||
return render_template_string(
|
||||
HTML_TEMPLATE,
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ apiVersion: v2
|
|||
name: dadjoke-app
|
||||
description: A basic Helm chart for the Programming Dad Joke Flask application
|
||||
type: application
|
||||
version: 0.1.2
|
||||
version: 0.1.0
|
||||
appVersion: "0.1"
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
1. Get the application URL by running these commands:
|
||||
{{- if .Values.ingress.enabled }}
|
||||
{{- range $host := .Values.ingress.hosts }}
|
||||
{{- range .paths }}
|
||||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if contains "NodePort" .Values.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dadjoke-app.fullname" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo http://$NODE_IP:$NODE_PORT
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dadjoke-app.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dadjoke-app.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dadjoke-app.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
|
||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
|
||||
{{- end }}
|
||||
{{- if .Values.cloudflared.enabled }}
|
||||
|
||||
Cloudflare Ephemeral Quick Tunnel is enabled!
|
||||
To retrieve your generated *.trycloudflare.com URL, run:
|
||||
kubectl --namespace {{ .Release.Namespace }} logs deploy/{{ include "dadjoke-app.fullname" . }} -c cloudflared | grep trycloudflare.com
|
||||
{{- end }}
|
||||
|
|
@ -59,37 +59,6 @@ spec:
|
|||
timeoutSeconds: 5
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- if .Values.cloudflared.enabled }}
|
||||
- name: cloudflared
|
||||
image: "{{ .Values.cloudflared.image.repository }}:{{ .Values.cloudflared.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.cloudflared.image.pullPolicy }}
|
||||
command:
|
||||
- cloudflared
|
||||
- tunnel
|
||||
- --no-autoupdate
|
||||
- --loglevel
|
||||
- {{ .Values.cloudflared.loglevel | quote }}
|
||||
- --metrics
|
||||
- "0.0.0.0:{{ .Values.cloudflared.metricsPort }}"
|
||||
- --url
|
||||
- {{ .Values.cloudflared.url | default (printf "http://localhost:%v" (.Values.service.targetPort | default .Values.service.port)) | quote }}
|
||||
{{- range .Values.cloudflared.extraArgs }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: cf-metrics
|
||||
containerPort: {{ .Values.cloudflared.metricsPort }}
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /ready
|
||||
port: cf-metrics
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
{{- toYaml .Values.cloudflared.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
|
|
|
|||
|
|
@ -25,30 +25,6 @@ securityContext:
|
|||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Cloudflare Quick Tunnel Sidecar Configuration (Ephemeral *.trycloudflare.com)
|
||||
# ----------------------------------------------------------------------------
|
||||
cloudflared:
|
||||
enabled: true
|
||||
image:
|
||||
repository: cloudflare/cloudflared
|
||||
tag: "latest"
|
||||
pullPolicy: IfNotPresent
|
||||
# Target URL to tunnel to. Defaults to http://localhost:<service.targetPort> (80)
|
||||
url: ""
|
||||
loglevel: info
|
||||
metricsPort: 2000
|
||||
# Optional additional arguments to pass to `cloudflared tunnel`
|
||||
extraArgs: []
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
cpu: 200m
|
||||
memory: 128Mi
|
||||
|
||||
env:
|
||||
OLLAMA_HOST: "http://harbor.freshbrewed.science:11444"
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
[metadata]
|
||||
version = 0.3
|
||||
version = 0.2
|
||||
|
|
|
|||
Loading…
Reference in New Issue