Skip to content

Commit fafd38a

Browse files
author
sd109
committed
Add backend ingress functionality
Refactors the ingress configuration and adds the option to expose both the UI and the backend API via separate ingress resources. This allows the OpenAI-compatible backend API to be exposed to external tooling.
1 parent 57a9dfd commit fafd38a

File tree

5 files changed

+94
-43
lines changed

5 files changed

+94
-43
lines changed

chart/templates/api/ingress.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.ingress.api.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
{{ if .Values.ingress.ui.annotations -}}
6+
annotations:
7+
{{- .Values.ingress.api.annotations | toYaml | nindent 4 }}
8+
{{ end -}}
9+
name: {{ default (printf "%s-api" .Release.Name) .Values.ingress.api.name }}
10+
spec:
11+
ingressClassName: nginx
12+
rules:
13+
- http:
14+
paths:
15+
- path: /v1
16+
pathType: Prefix
17+
backend:
18+
service:
19+
name: {{ .Values.api.service.name }}
20+
port:
21+
# Must match Service resource
22+
number: 80
23+
{{ if .Values.ingress.host -}}
24+
host: {{ .Values.ingress.host | quote }}
25+
{{- end -}}
26+
{{- if .Values.ingress.tls }}
27+
tls:
28+
- hosts:
29+
- {{ (required "ingress.host is required when ingress.tls is true" .Values.ingress.host) | quote }}
30+
secretName: {{ .Release.Name }}-tls
31+
{{- end -}}
32+
{{- end -}}

chart/templates/api/service.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ spec:
1212
targetPort: api
1313
type: {{ .Values.api.service.type }}
1414
selector:
15-
{{- include "azimuth-llm.api-selectorLabels" . | nindent 4 }}
15+
{{- include "azimuth-llm.api-selectorLabels" . | nindent 4 }}

chart/templates/ui/ingress.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if and .Values.ui.enabled .Values.ingress.ui.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
{{ if .Values.ingress.ui.annotations -}}
6+
annotations:
7+
{{- .Values.ingress.ui.annotations | toYaml | nindent 4 }}
8+
{{ end -}}
9+
name: {{ default (printf "%s-ui" .Release.Name) .Values.ingress.ui.name }}
10+
spec:
11+
ingressClassName: nginx
12+
rules:
13+
- http:
14+
paths:
15+
- path: /
16+
pathType: Prefix
17+
backend:
18+
service:
19+
name: {{ .Values.ui.service.name }}
20+
port:
21+
# Must match Service resource
22+
number: 80
23+
{{ if .Values.ingress.host -}}
24+
host: {{ .Values.ingress.host | quote }}
25+
{{- end -}}
26+
{{- if .Values.ingress.tls }}
27+
tls:
28+
- hosts:
29+
- {{ (required "ingress.host is required when ingress.tls is true" .Values.ingress.host) | quote }}
30+
secretName: {{ .Release.Name }}-tls
31+
{{- end -}}
32+
{{- end -}}

chart/templates/ui/service.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,4 @@ spec:
1515
type: {{ .Values.ui.service.type }}
1616
selector:
1717
{{- include "azimuth-llm.ui-selectorLabels" . | nindent 4 }}
18-
---
19-
{{- if .Values.ui.ingress.host -}}
20-
apiVersion: networking.k8s.io/v1
21-
kind: Ingress
22-
metadata:
23-
annotations:
24-
{{- .Values.ui.ingress.annotations | toYaml | nindent 4 }}
25-
name: {{ .Values.ui.ingress.name | default .Release.Name }}
26-
spec:
27-
ingressClassName: nginx
28-
rules:
29-
- host: {{ .Values.ui.ingress.host | quote }}
30-
http:
31-
paths:
32-
- backend:
33-
service:
34-
name: {{ .Values.ui.service.name }}
35-
port:
36-
number: 80 # Must match Service resource
37-
path: /
38-
pathType: Prefix
39-
tls:
40-
- hosts:
41-
- {{ .Values.ui.ingress.host | quote }}
42-
secretName: {{ .Release.Name }}-tls
4318
{{- end -}}
44-
{{- end -}}

chart/values.yaml

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,40 @@ ui:
112112
iconUrl: https://raw.githubusercontent.com/gradio-app/gradio/5524e590577769b0444a5332b8d444aafb0c5c12/js/app/public/static/img/logo.svg
113113
description: |
114114
A web-based user inferface for interacting with the deployed LLM.
115-
# Optional config for an ingress resource to expose the UI
116-
ingress:
117-
# The name of the ingress resource to create (default: Release.Name)
118-
name:
119-
# Any annotations to apply to the ingress resource
120-
# (e.g. for cert-manager TLS integration)
121-
annotations: {}
122-
# The domain name to use for the ingress resource.
123-
# If host is not set then ingress support will be disabled and
124-
# no ingress resource will be created.
125-
# NOTE: If ingress is enabled, an ingress controller must be installed
126-
# on the target cluster before installing this chart.
127-
# For example, see https://kubernetes.github.io/ingress-nginx/deploy/
128-
# TODO: Check what happens if ingress is enabled without a controller deployed
129-
# (probably nothing, just an unused ingress resource will be created)
130-
host:
131115
# The update strategy to use for the deployment
132116
updateStrategy:
133117
rollingUpdate:
134118
maxSurge: 25%
135119
maxUnavailable: 25%
136120

121+
# Settings for configuring ingress resources
122+
# to make the UI and/or backend API accessible
123+
# outside the cluster.
124+
# NOTE: An ingress controller must be installed
125+
# on the target cluster.
126+
ingress:
127+
host:
128+
tls: true
129+
api:
130+
enabled: false
131+
# Defaults to "{{ .Release.name }}"-api
132+
name:
133+
# This is required to be /v1 for an OpenAI API
134+
# unless we add URL rewrite functionality to the
135+
# Ingress resource templates in the future.
136+
path: /v1
137+
# Annotations to apply to the ingress resource
138+
# e.g. for cert-manager integration
139+
annotations:
140+
ui:
141+
enabled: false
142+
# Defaults to "{{ .Release.name }}"-ui
143+
name:
144+
# For a Gradio app this must be the root
145+
path: /
146+
# Annotations to apply to the ingress resource
147+
# e.g. for cert-manager integration
148+
annotations:
149+
137150
reloader:
138151
watchGlobally: false

0 commit comments

Comments
 (0)