Skip to content

Commit

Permalink
Use k8s ingress instead of frontend nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashbrnrd committed Oct 4, 2023
1 parent cf09614 commit b39cc47
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 42 deletions.
1 change: 1 addition & 0 deletions frontend/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_HOST=http://localhost:5000
1 change: 1 addition & 0 deletions frontend/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_HOST=http://basegun.fr/api/
8 changes: 0 additions & 8 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ http {
try_files $uri $uri/ /index.html;
}

location /api/ {
proxy_pass http://basegun-backend:5000/;
client_max_body_size 5M;
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
proxy_send_timeout 1800;
}

error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const pinia = createPinia()
axios.defaults.withCredentials = true

// the FastAPI backend
axios.defaults.baseURL = '/api/'
axios.defaults.baseURL = import.meta.env.VITE_API_HOST

const app = createApp(App)

Expand Down
49 changes: 16 additions & 33 deletions infra/kube/helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "basegun.chart" . -}}
{{- $svcPort := .Values.frontend.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
---
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: "basegun-ingress"
Expand All @@ -23,9 +11,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
Expand All @@ -40,22 +26,19 @@ spec:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: "basegun-frontend"
port:
number: {{ $svcPort }}
{{- else }}
serviceName: "basegun-frontend"
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
paths:
- path: /
pathType: Prefix
backend:
service:
name: basegun-frontend
port:
number: {{ $.Values.client.service.port }}
- path: /api/
pathType: Prefix
backend:
service:
name: basegun-backend
port:
number: {{ $.Values.server.service.port }}
{{- end }}

0 comments on commit b39cc47

Please sign in to comment.