diff --git a/charts/skypilot/templates/ingress.yaml b/charts/skypilot/templates/ingress.yaml index 56b27609077..834a20f64ee 100644 --- a/charts/skypilot/templates/ingress.yaml +++ b/charts/skypilot/templates/ingress.yaml @@ -60,16 +60,35 @@ spec: {{- if $useNewIngressClass }} ingressClassName: {{ .Values.ingress.ingressClassName }} {{- end }} + rules: - - host: {{ .Values.ingress.host }} - http: - paths: - {{- /* TODO(aylei): check whether this works for ingress-controllers other than nginx */}} - - pathType: {{ if eq .Values.ingress.path "/" }}Prefix{{ else }}ImplementationSpecific{{ end }} - path: {{ .Values.ingress.path }}{{ if ne .Values.ingress.path "/" }}(/|$)(.*){{ end }} - backend: - service: - name: {{ .Release.Name }}-api-service - port: - number: 80 -{{- end }} + {{- if .Values.ingress.hosts }} + {{- /* --- Multi-host mode --- */}} + {{- range .Values.ingress.hosts }} + - host: {{ .host | default "null" }} + http: + paths: + {{- range .paths }} + - pathType: {{ if eq .path "/" }}Prefix{{ else }}ImplementationSpecific{{ end }} + path: {{ .path }} + backend: + service: + name: {{ printf "%s-%s" $.Release.Namespace .serviceName }} + port: + number: {{ .servicePort }} + {{- end }} + {{- end }} + {{- else }} + {{- /* --- Backward compatibility (single-host mode) --- */}} + - host: {{ .Values.ingress.host | default "null" }} + http: + paths: + - pathType: {{ if eq .Values.ingress.path "/" }}Prefix{{ else }}ImplementationSpecific{{ end }} + path: {{ .Values.ingress.path | default "/" }}{{ if and .Values.ingress.path (ne .Values.ingress.path "/") }}(/|$)(.*){{ end }} + backend: + service: + name: {{ .Release.Name }}-api-service + port: + number: 80 + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/skypilot/values.yaml b/charts/skypilot/values.yaml index 07f0295b409..3216dfed1ea 100644 --- a/charts/skypilot/values.yaml +++ b/charts/skypilot/values.yaml @@ -264,6 +264,36 @@ ingress: # Host to exclusively accept traffic from (optional) - will respond to all host requests if not set # @schema type: [string, null] host: null + ## ----------------------------------------------------------------------------- + ## Adding support for multiple hosts and backend services + ## + ## This replaces the legacy single 'ingress.host' key. + ## Each item in the list defines: + ## - a hostname (DNS name) + ## - one or more backend services (paths) + ## + ## Example: + ## hosts: + ## - host: null + ## paths: + ## - path: / + ## serviceName: skypilot-api-service + ## servicePort: 80 + ## - path: /grafana + ## serviceName: skypilot-grafana + ## servicePort: 80 + ## - host: mlflow.company.com + ## paths: + ## - path: / + ## serviceName: mlflow-tracking + ## servicePort: 5000 + ## + ## Notes: + ## - All hosts will share the same TLS certificate (see annotations below). + ## - Paths are defined per host; each path routes to a Kubernetes Service. + ## - You can mix multiple paths per host (e.g. /grafana → grafana service). + ## - To keep backward compatibility, you can still define a single host. + ## ----------------------------------------------------------------------------- # The base path of API server, you may use different path to expose multiple API server through a unified ingress-controller path: '/' # Ingress class name (for newer Kubernetes versions)