From 753ad486e75dc5e858a19b12033b61c2c3a955f2 Mon Sep 17 00:00:00 2001 From: git_admin Date: Sun, 26 Apr 2026 18:17:38 +0300 Subject: [PATCH] Step 4: enable frontend + path-based routing + tower:0.2.0 --- templates/frontend-deployment.yaml | 42 ++++++++++++++++++++++++++++++ templates/frontend-service.yaml | 17 ++++++++++++ templates/ingressroute.yaml | 22 +++++++++------- values.yaml | 14 +++++++--- 4 files changed, 81 insertions(+), 14 deletions(-) create mode 100644 templates/frontend-deployment.yaml create mode 100644 templates/frontend-service.yaml diff --git a/templates/frontend-deployment.yaml b/templates/frontend-deployment.yaml new file mode 100644 index 0000000..e9ede2e --- /dev/null +++ b/templates/frontend-deployment.yaml @@ -0,0 +1,42 @@ +{{- if .Values.frontend.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tower-frontend + labels: + {{- include "tower.labels" . | nindent 4 }} + odoosky.io/role: frontend +spec: + replicas: {{ .Values.frontend.replicas }} + selector: + matchLabels: + app.kubernetes.io/name: tower + odoosky.io/role: frontend + template: + metadata: + labels: + {{- include "tower.labels" . | nindent 8 }} + odoosky.io/role: frontend + spec: + containers: + - name: tower-ui + image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag }}" + imagePullPolicy: {{ .Values.frontend.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + readinessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 2 + periodSeconds: 5 + livenessProbe: + httpGet: + path: / + port: 80 + initialDelaySeconds: 10 + periodSeconds: 15 + resources: + {{- toYaml .Values.frontend.resources | nindent 12 }} +{{- end }} diff --git a/templates/frontend-service.yaml b/templates/frontend-service.yaml new file mode 100644 index 0000000..0538543 --- /dev/null +++ b/templates/frontend-service.yaml @@ -0,0 +1,17 @@ +{{- if .Values.frontend.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: tower-frontend + labels: + {{- include "tower.labels" . | nindent 4 }} +spec: + selector: + app.kubernetes.io/name: tower + odoosky.io/role: frontend + ports: + - name: http + port: 80 + targetPort: 80 + type: ClusterIP +{{- end }} diff --git a/templates/ingressroute.yaml b/templates/ingressroute.yaml index 9bb29e5..c3db19d 100644 --- a/templates/ingressroute.yaml +++ b/templates/ingressroute.yaml @@ -1,11 +1,13 @@ -# Tower IngressRoute. Routes by path: -# /api/* → backend (8080) -# /* → frontend (when Step 4 builds it; currently a 503 from -# Traefik because backend.frontend.enabled=false) +# Tower IngressRoute — path-based split between API and UI on the +# same hostname. # -# Once frontend lands, we add a second route block with a Path matcher -# for the `/api` prefix going to backend, and the catch-all for static -# files going to frontend. +# Routing rules (Traefik picks longest-match-with-priority): +# - API endpoints (/healthz, /instances, future /api/*) → backend +# - everything else → frontend (Vue SPA) +# +# Priority is set explicitly so Traefik doesn't fall back to its +# heuristic; the API rule outranks the catchall, which outranks no +# rule at all. apiVersion: traefik.io/v1alpha1 kind: IngressRoute metadata: @@ -17,15 +19,15 @@ spec: - {{ .Values.ingress.entryPoint }} routes: {{- if .Values.backend.enabled }} - - match: Host(`{{ .Values.ingress.domain }}`) + - match: Host(`{{ .Values.ingress.domain }}`) && (PathPrefix(`/healthz`) || PathPrefix(`/instances`) || PathPrefix(`/api`)) kind: Rule + priority: 200 services: - name: tower-backend port: 8080 {{- end }} {{- if .Values.frontend.enabled }} - # Frontend slot — enabled when Step 4 builds the UI. - - match: Host(`{{ .Values.ingress.domain }}`) && !PathPrefix(`/api`) && !PathPrefix(`/healthz`) && !PathPrefix(`/instances`) + - match: Host(`{{ .Values.ingress.domain }}`) kind: Rule priority: 100 services: diff --git a/values.yaml b/values.yaml index e46661c..0992d73 100644 --- a/values.yaml +++ b/values.yaml @@ -4,7 +4,7 @@ backend: enabled: true image: repository: docker.io/odoosky/tower - tag: "0.1.0" + tag: "0.2.0" pullPolicy: IfNotPresent # IfNotPresent because the image is in # containerd's k8s.io namespace already # (lab1 single-server). Replace with @@ -19,13 +19,19 @@ backend: memory: 256Mi frontend: - # Off until Step 4 builds it. The chart slot is reserved here so - # turning it on later is a values-flip, not a chart edit. - enabled: false + enabled: true image: repository: docker.io/odoosky/tower-ui tag: "0.1.0" + pullPolicy: IfNotPresent replicas: 1 + resources: + requests: + cpu: 10m + memory: 16Mi + limits: + cpu: 250m + memory: 64Mi # Tower needs to talk to: # - Gitea (create tenant repos, commit values.yaml)