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 }}
|
- containerPort: {{ .Values.frontend.service.targetPort }}
|
||||||
name: http
|
name: http
|
||||||
protocol: TCP
|
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:
|
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 := . }}
|
{{- range $key, $value := . }}
|
||||||
|
{{- if ne $key "API_BASE" }}
|
||||||
- name: {{ $key }}
|
- name: {{ $key }}
|
||||||
value: {{ $value | quote }}
|
value: {{ $value | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /
|
path: /
|
||||||
|
|||||||
@ -91,14 +91,17 @@ ingress:
|
|||||||
className: "nginx"
|
className: "nginx"
|
||||||
annotations:
|
annotations:
|
||||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||||
|
nginx.ingress.kubernetes.io/rewrite-target: "/$2"
|
||||||
|
nginx.ingress.kubernetes.io/use-regex: "true"
|
||||||
hosts:
|
hosts:
|
||||||
- host: recipes.local
|
- host: recipes.local
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
backend: frontend
|
backend: frontend
|
||||||
- path: /api
|
# use a regex to capture and rewrite /api/... to /... on the backend
|
||||||
pathType: Prefix
|
- path: /api(/|$)(.*)
|
||||||
|
pathType: ImplementationSpecific
|
||||||
backend: backend
|
backend: backend
|
||||||
tls:
|
tls:
|
||||||
- secretName: recipes-tls
|
- secretName: recipes-tls
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user