Skip to content

Commit

Permalink
Add backend ingress functionality
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sd109 committed Jun 11, 2024
1 parent 57a9dfd commit fafd38a
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 43 deletions.
32 changes: 32 additions & 0 deletions chart/templates/api/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.ingress.api.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
{{ if .Values.ingress.ui.annotations -}}
annotations:
{{- .Values.ingress.api.annotations | toYaml | nindent 4 }}
{{ end -}}
name: {{ default (printf "%s-api" .Release.Name) .Values.ingress.api.name }}
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /v1
pathType: Prefix
backend:
service:
name: {{ .Values.api.service.name }}
port:
# Must match Service resource
number: 80
{{ if .Values.ingress.host -}}
host: {{ .Values.ingress.host | quote }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
- hosts:
- {{ (required "ingress.host is required when ingress.tls is true" .Values.ingress.host) | quote }}
secretName: {{ .Release.Name }}-tls
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion chart/templates/api/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ spec:
targetPort: api
type: {{ .Values.api.service.type }}
selector:
{{- include "azimuth-llm.api-selectorLabels" . | nindent 4 }}
{{- include "azimuth-llm.api-selectorLabels" . | nindent 4 }}
32 changes: 32 additions & 0 deletions chart/templates/ui/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if and .Values.ui.enabled .Values.ingress.ui.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
{{ if .Values.ingress.ui.annotations -}}
annotations:
{{- .Values.ingress.ui.annotations | toYaml | nindent 4 }}
{{ end -}}
name: {{ default (printf "%s-ui" .Release.Name) .Values.ingress.ui.name }}
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ .Values.ui.service.name }}
port:
# Must match Service resource
number: 80
{{ if .Values.ingress.host -}}
host: {{ .Values.ingress.host | quote }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
- hosts:
- {{ (required "ingress.host is required when ingress.tls is true" .Values.ingress.host) | quote }}
secretName: {{ .Release.Name }}-tls
{{- end -}}
{{- end -}}
26 changes: 0 additions & 26 deletions chart/templates/ui/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,4 @@ spec:
type: {{ .Values.ui.service.type }}
selector:
{{- include "azimuth-llm.ui-selectorLabels" . | nindent 4 }}
---
{{- if .Values.ui.ingress.host -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
{{- .Values.ui.ingress.annotations | toYaml | nindent 4 }}
name: {{ .Values.ui.ingress.name | default .Release.Name }}
spec:
ingressClassName: nginx
rules:
- host: {{ .Values.ui.ingress.host | quote }}
http:
paths:
- backend:
service:
name: {{ .Values.ui.service.name }}
port:
number: 80 # Must match Service resource
path: /
pathType: Prefix
tls:
- hosts:
- {{ .Values.ui.ingress.host | quote }}
secretName: {{ .Release.Name }}-tls
{{- end -}}
{{- end -}}
45 changes: 29 additions & 16 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,40 @@ ui:
iconUrl: https://raw.githubusercontent.com/gradio-app/gradio/5524e590577769b0444a5332b8d444aafb0c5c12/js/app/public/static/img/logo.svg
description: |
A web-based user inferface for interacting with the deployed LLM.
# Optional config for an ingress resource to expose the UI
ingress:
# The name of the ingress resource to create (default: Release.Name)
name:
# Any annotations to apply to the ingress resource
# (e.g. for cert-manager TLS integration)
annotations: {}
# The domain name to use for the ingress resource.
# If host is not set then ingress support will be disabled and
# no ingress resource will be created.
# NOTE: If ingress is enabled, an ingress controller must be installed
# on the target cluster before installing this chart.
# For example, see https://kubernetes.github.io/ingress-nginx/deploy/
# TODO: Check what happens if ingress is enabled without a controller deployed
# (probably nothing, just an unused ingress resource will be created)
host:
# The update strategy to use for the deployment
updateStrategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%

# Settings for configuring ingress resources
# to make the UI and/or backend API accessible
# outside the cluster.
# NOTE: An ingress controller must be installed
# on the target cluster.
ingress:
host:
tls: true
api:
enabled: false
# Defaults to "{{ .Release.name }}"-api
name:
# This is required to be /v1 for an OpenAI API
# unless we add URL rewrite functionality to the
# Ingress resource templates in the future.
path: /v1
# Annotations to apply to the ingress resource
# e.g. for cert-manager integration
annotations:
ui:
enabled: false
# Defaults to "{{ .Release.name }}"-ui
name:
# For a Gradio app this must be the root
path: /
# Annotations to apply to the ingress resource
# e.g. for cert-manager integration
annotations:

reloader:
watchGlobally: false

0 comments on commit fafd38a

Please sign in to comment.