Set the front to communicate with the backend via ingress
This commit is contained in:
parent
224eebfb7a
commit
566f49d050
@ -25,13 +25,26 @@ spec:
|
||||
- containerPort: {{ .Values.frontend.service.targetPort }}
|
||||
name: http
|
||||
protocol: TCP
|
||||
{{- with .Values.frontend.env }}
|
||||
{{- /* compute API_BASE: prefer frontend.env.API_BASE, else use first ingress host */}}
|
||||
{{- $apiBase := "" }}
|
||||
{{- if .Values.frontend.env.API_BASE }}
|
||||
{{- $apiBase = .Values.frontend.env.API_BASE }}
|
||||
{{- else if .Values.ingress.hosts }}
|
||||
{{- $firstHost := index .Values.ingress.hosts 0 }}
|
||||
{{- $apiBase = printf "https://%s/api" $firstHost.host }}
|
||||
{{- end }}
|
||||
env:
|
||||
- name: API_BASE
|
||||
value: {{ $apiBase | quote }}
|
||||
{{- /* include any other env vars provided in values.frontend.env (skip API_BASE to avoid duplicate) */}}
|
||||
{{- with .Values.frontend.env }}
|
||||
{{- range $key, $value := . }}
|
||||
{{- if ne $key "API_BASE" }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
|
||||
@ -91,14 +91,17 @@ ingress:
|
||||
className: "nginx"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
nginx.ingress.kubernetes.io/rewrite-target: "/$2"
|
||||
nginx.ingress.kubernetes.io/use-regex: "true"
|
||||
hosts:
|
||||
- host: recipes.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend: frontend
|
||||
- path: /api
|
||||
pathType: Prefix
|
||||
# use a regex to capture and rewrite /api/... to /... on the backend
|
||||
- path: /api(/|$)(.*)
|
||||
pathType: ImplementationSpecific
|
||||
backend: backend
|
||||
tls:
|
||||
- secretName: recipes-tls
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user