From df8e4148a31af927054f60f8d319e8006e84121e Mon Sep 17 00:00:00 2001 From: sd109 Date: Thu, 13 Feb 2025 21:31:10 +0000 Subject: [PATCH 1/3] Refactor ingress config to allow maximum configurability --- charts/azimuth-llm/templates/api/ingress.yml | 63 ++++++++++++-------- charts/azimuth-llm/templates/ui/ingress.yml | 63 ++++++++++++-------- charts/azimuth-llm/values.yaml | 63 ++++++++++---------- 3 files changed, 107 insertions(+), 82 deletions(-) diff --git a/charts/azimuth-llm/templates/api/ingress.yml b/charts/azimuth-llm/templates/api/ingress.yml index 14c13b1..fdb6243 100644 --- a/charts/azimuth-llm/templates/api/ingress.yml +++ b/charts/azimuth-llm/templates/api/ingress.yml @@ -1,32 +1,43 @@ -{{- if and .Values.api.enabled .Values.ingress.api.enabled -}} +{{- if and .Values.api.enabled .Values.api.ingress.enabled -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - {{ if .Values.ingress.ui.annotations -}} + name: {{ printf "%s-api" .Release.Name }} + labels: + {{- include "azimuth-llm.labels" . | nindent 4 }} + {{- with .Values.api.ingress.annotations }} annotations: - {{- .Values.ingress.api.annotations | toYaml | nindent 4 }} - {{ end -}} - name: {{ default (printf "%s-api" .Release.Name) .Values.ingress.api.name }} + {{- toYaml . | nindent 4 }} + {{- end }} 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 }} + {{- with .Values.api.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.api.ingress.tls }} tls: - - hosts: - - {{ (required "ingress.host is required when ingress.tls is true" .Values.ingress.host) | quote }} - secretName: {{ .Release.Name }}-api-tls - {{- end -}} -{{- end -}} + {{- range .Values.api.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.api.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "azimuth-llm.fullname" $ }} + port: + number: 80 + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/azimuth-llm/templates/ui/ingress.yml b/charts/azimuth-llm/templates/ui/ingress.yml index e9e6e02..8247a17 100644 --- a/charts/azimuth-llm/templates/ui/ingress.yml +++ b/charts/azimuth-llm/templates/ui/ingress.yml @@ -1,32 +1,43 @@ -{{- if and .Values.ui.enabled .Values.ingress.ui.enabled -}} +{{- if and .Values.ui.enabled .Values.ui.ingress.enabled -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - {{ if .Values.ingress.ui.annotations -}} + name: {{ printf "%s-ui" .Release.Name }} + labels: + {{- include "azimuth-llm.labels" . | nindent 4 }} + {{- with .Values.ui.ingress.annotations }} annotations: - {{- .Values.ingress.ui.annotations | toYaml | nindent 4 }} - {{ end -}} - name: {{ default (printf "%s-ui" .Release.Name) .Values.ingress.ui.name }} + {{- toYaml . | nindent 4 }} + {{- end }} 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 }} + {{- with .Values.ui.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.ui.ingress.tls }} tls: - - hosts: - - {{ (required "ingress.host is required when ingress.tls is true" .Values.ingress.host) | quote }} - secretName: {{ .Release.Name }}-ui-tls - {{- end -}} -{{- end -}} + {{- range .Values.ui.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ui.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "azimuth-llm.fullname" $ }} + port: + number: 80 + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/azimuth-llm/values.yaml b/charts/azimuth-llm/values.yaml index 29879d4..197ec0c 100644 --- a/charts/azimuth-llm/values.yaml +++ b/charts/azimuth-llm/values.yaml @@ -50,6 +50,23 @@ api: iconUrl: https://raw.githubusercontent.com/vllm-project/vllm/v0.2.7/docs/source/assets/logos/vllm-logo-only-light.png description: | The OpenAI API for the deployed LLM. + # Standard ingress resource config for backend API + ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: /v1 + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + # Config for huggingface model cache volume # This is mounted at /root/.cache/huggingface in the api deployment cacheVolume: @@ -114,38 +131,24 @@ 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. + # Standard ingress resource config for UI web app + ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local # 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: From fa2c3e50282d30452f6dca1cacc4ed8d241363a7 Mon Sep 17 00:00:00 2001 From: sd109 Date: Fri, 14 Feb 2025 21:05:39 +0000 Subject: [PATCH 2/3] Fix ingress values paths --- charts/azimuth-llm/templates/test/end-to-end.yml | 4 ++-- charts/azimuth-llm/templates/test/web-app.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/azimuth-llm/templates/test/end-to-end.yml b/charts/azimuth-llm/templates/test/end-to-end.yml index e94d4d2..28258dd 100644 --- a/charts/azimuth-llm/templates/test/end-to-end.yml +++ b/charts/azimuth-llm/templates/test/end-to-end.yml @@ -18,8 +18,8 @@ spec: command: - python - gradio-client-test.py - {{- if .Values.ingress.ui.enabled }} - - {{ .Values.ingress.host }}{{ .Values.ingress.ui.path }} + {{- if .Values.ui.ingress.enabled }} + - {{ .Values.ingress.host }}{{ .Values.ui.ingress.path }} {{- else }} - http://{{ .Values.ui.service.name }}.{{ .Release.Namespace }}.svc {{- end }} diff --git a/charts/azimuth-llm/templates/test/web-app.yml b/charts/azimuth-llm/templates/test/web-app.yml index 65dbb90..2017370 100644 --- a/charts/azimuth-llm/templates/test/web-app.yml +++ b/charts/azimuth-llm/templates/test/web-app.yml @@ -15,8 +15,8 @@ spec: command: - nc - -vz - {{- if .Values.ingress.ui.enabled }} - - {{ .Values.ingress.host | trimPrefix "http://" | trimPrefix "https://" }}{{ .Values.ingress.ui.path }} + {{- if .Values.ui.ingress.enabled }} + - {{ .Values.ingress.host | trimPrefix "http://" | trimPrefix "https://" }}{{ .Values.ui.ingress.path }} {{- else }} - {{ .Values.ui.service.name }}.{{ .Release.Namespace }}.svc {{- end }} From 1486d98ef447b85e17745450d75180800b5967df Mon Sep 17 00:00:00 2001 From: sd109 Date: Tue, 18 Feb 2025 14:43:30 +0000 Subject: [PATCH 3/3] Use internal service endpoints for chart tests --- charts/azimuth-llm/templates/api/ingress.yml | 2 +- charts/azimuth-llm/templates/test/end-to-end.yml | 4 ---- charts/azimuth-llm/templates/test/web-app.yml | 4 ---- charts/azimuth-llm/templates/ui/ingress.yml | 2 +- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/charts/azimuth-llm/templates/api/ingress.yml b/charts/azimuth-llm/templates/api/ingress.yml index fdb6243..af3cbdc 100644 --- a/charts/azimuth-llm/templates/api/ingress.yml +++ b/charts/azimuth-llm/templates/api/ingress.yml @@ -35,7 +35,7 @@ spec: {{- end }} backend: service: - name: {{ include "azimuth-llm.fullname" $ }} + name: {{ $.Release.Name }}-api port: number: 80 {{- end }} diff --git a/charts/azimuth-llm/templates/test/end-to-end.yml b/charts/azimuth-llm/templates/test/end-to-end.yml index 5201742..ff3f85c 100644 --- a/charts/azimuth-llm/templates/test/end-to-end.yml +++ b/charts/azimuth-llm/templates/test/end-to-end.yml @@ -17,11 +17,7 @@ spec: command: - python - gradio-client-test.py - {{- if .Values.ui.ingress.enabled }} - - {{ .Values.ingress.host }}{{ .Values.ui.ingress.path }} - {{- else }} - http://{{ .Release.Name }}-ui.{{ .Release.Namespace }}.svc - {{- end }} env: - name: PYTHONUNBUFFERED value: "1" diff --git a/charts/azimuth-llm/templates/test/web-app.yml b/charts/azimuth-llm/templates/test/web-app.yml index 6ee1f13..213e386 100644 --- a/charts/azimuth-llm/templates/test/web-app.yml +++ b/charts/azimuth-llm/templates/test/web-app.yml @@ -15,11 +15,7 @@ spec: command: - nc - -vz - {{- if .Values.ui.ingress.enabled }} - - {{ .Values.ingress.host | trimPrefix "http://" | trimPrefix "https://" }}{{ .Values.ui.ingress.path }} - {{- else }} - {{ .Release.Name }}-ui.{{ .Release.Namespace }}.svc - {{- end }} - "80" restartPolicy: Never backoffLimit: 3 diff --git a/charts/azimuth-llm/templates/ui/ingress.yml b/charts/azimuth-llm/templates/ui/ingress.yml index 8247a17..8565522 100644 --- a/charts/azimuth-llm/templates/ui/ingress.yml +++ b/charts/azimuth-llm/templates/ui/ingress.yml @@ -35,7 +35,7 @@ spec: {{- end }} backend: service: - name: {{ include "azimuth-llm.fullname" $ }} + name: {{ $.Release.Name }}-ui port: number: 80 {{- end }}