Skip to content

Commit

Permalink
Merge pull request #29 from stackhpc/feat/backend-ingress
Browse files Browse the repository at this point in the history
Add backend ingress functionality
  • Loading branch information
sd109 authored Jun 25, 2024
2 parents 57a9dfd + 84c79f5 commit 04abbcb
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 44 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: {{ .Values.ingress.className }}
rules:
- http:
paths:
- path: {{ .Values.ingress.api.path }}
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: {{ .Values.ingress.className }}
rules:
- http:
paths:
- path: {{ .Values.ingress.ui.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 -}}
27 changes: 0 additions & 27 deletions chart/templates/ui/service.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- if .Values.ui.enabled -}}
---
apiVersion: v1
kind: Service
metadata:
Expand All @@ -15,30 +14,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 -}}
47 changes: 31 additions & 16 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,42 @@ 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:
# The name of the ingress class to use
className: nginx
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 04abbcb

Please sign in to comment.