Skip to content

Commit 2dd1d00

Browse files
authored
Support use a unified ingress resource (skypilot-org#8532)
* Support use a unified ingress resource Signed-off-by: Aylei <rayingecho@gmail.com> * Doc Signed-off-by: Aylei <rayingecho@gmail.com> * Adopt suggestion Signed-off-by: Aylei <rayingecho@gmail.com> --------- Signed-off-by: Aylei <rayingecho@gmail.com>
1 parent e44fbbc commit 2dd1d00

7 files changed

Lines changed: 78 additions & 2 deletions

File tree

charts/skypilot/templates/grafana-ingress.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.grafana.enabled .Values.grafana.ingress.enableAuthedIngress }}
1+
{{- if and (not .Values.ingress.unified) .Values.grafana.enabled .Values.grafana.ingress.enableAuthedIngress }}
22
{{- $fullName := include "skypilot.fullname" . -}}
33
apiVersion: networking.k8s.io/v1
44
kind: Ingress
@@ -23,6 +23,9 @@ metadata:
2323
{{- end }}
2424
nginx.ingress.kubernetes.io/configuration-snippet: |
2525
proxy_set_header X-WEBAUTH-USER admin;
26+
{{- if .Values.grafana.ingress.annotations }}
27+
{{- toYaml .Values.grafana.ingress.annotations | nindent 4 }}
28+
{{- end }}
2629
spec:
2730
ingressClassName: {{ .Values.grafana.ingress.ingressClassName }}
2831
rules:

charts/skypilot/templates/ingress.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{{- $useNewIngressClass := or (gt ($kubeVersion | int) 1) (and (eq ($kubeVersion | int) 1) (ge $kubeMinorVersion 18)) -}}
55
{{- $enableBasicAuthInAPIServer := include "skypilot.enableBasicAuthInAPIServer" . | trim | eq "true" -}}
66
{{- $fullName := include "skypilot.fullname" . -}}
7+
{{- $unifiedIngress := .Values.ingress.unified | default false -}}
78

89
apiVersion: networking.k8s.io/v1
910
kind: Ingress
@@ -82,4 +83,22 @@ spec:
8283
name: {{ $fullName }}-api-service
8384
port:
8485
number: 80
86+
{{- if and $unifiedIngress .Values.grafana.enabled }}
87+
- pathType: Prefix
88+
path: /grafana
89+
backend:
90+
service:
91+
name: {{ $fullName }}-grafana
92+
port:
93+
number: 80
94+
{{- end }}
95+
{{- if and $unifiedIngress (index .Values.ingress "oauth2-proxy" "enabled") }}
96+
- pathType: Prefix
97+
path: /oauth2
98+
backend:
99+
service:
100+
name: {{ $fullName }}-oauth2-proxy
101+
port:
102+
number: 4180
103+
{{- end }}
85104
{{- end }}

charts/skypilot/templates/oauth2-proxy-ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.ingress.enabled (index .Values.ingress "oauth2-proxy" "enabled") }}
1+
{{- if and (not .Values.ingress.unified) .Values.ingress.enabled (index .Values.ingress "oauth2-proxy" "enabled") }}
22
{{- $kubeVersion := .Capabilities.KubeVersion.Major -}}
33
{{- $kubeMinorVersion := .Capabilities.KubeVersion.Minor | trimSuffix "+" | int -}}
44
{{- $useNewIngressClass := or (gt ($kubeVersion | int) 1) (and (eq ($kubeVersion | int) 1) (ge $kubeMinorVersion 18)) -}}

charts/skypilot/tests/metrics_test.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,33 @@ tests:
2828
- matchRegex:
2929
path: data["prometheus.yml"]
3030
pattern: "custom-name-api-service\\.NAMESPACE\\.svc\\.cluster\\.local:9090"
31+
32+
---
33+
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
34+
suite: grafana_ingress_annotations_test
35+
templates:
36+
- templates/grafana-ingress.yaml
37+
tests:
38+
- it: should render custom annotations when grafana.ingress.annotations is set
39+
set:
40+
ingress:
41+
unified: false
42+
grafana:
43+
enabled: true
44+
ingress:
45+
enableAuthedIngress: true
46+
ingressClassName: nginx
47+
annotations:
48+
example.com/foo: "bar"
49+
example.com/baz: "qux"
50+
asserts:
51+
- hasDocuments:
52+
count: 1
53+
- isKind:
54+
of: Ingress
55+
- equal:
56+
path: metadata.annotations["example.com/foo"]
57+
value: "bar"
58+
- equal:
59+
path: metadata.annotations["example.com/baz"]
60+
value: "qux"

charts/skypilot/values.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@
471471
"type": "boolean"
472472
}
473473
}
474+
},
475+
"unified": {
476+
"type": "boolean"
474477
}
475478
}
476479
},

charts/skypilot/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ storage:
279279

280280

281281
ingress:
282+
# Whether to use a unified ingress resource for the API server and other services like Grafana.
283+
# @schema type: [boolean]
284+
unified: false
282285
enabled: true
283286
# Name of the secret containing basic auth credentials for ingress. If not specified, a new secret will be created using authCredentials
284287
# Example:
@@ -674,6 +677,9 @@ grafana:
674677
# If you set hosts to null, the Grafana Helm chart will use its default value ([chart-example.local]).
675678
# To match all hosts, set hosts to an empty array ([]).
676679
hosts: []
680+
# Custom annotations for the ingress
681+
annotations: null
682+
677683
grafana.ini:
678684
server:
679685
domain: localhost

docs/source/reference/api-server/helm-values-spec.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Below is the available helm value keys and the default value of each key:
112112
113113
:ref:`ingress <helm-values-ingress>`:
114114
:ref:`enabled <helm-values-ingress-enabled>`: true
115+
:ref:`unified <helm-values-ingress-unified>`: false
115116
:ref:`authSecret <helm-values-ingress-authSecret>`: null
116117
:ref:`authCredentials <helm-values-ingress-authCredentials>`: null
117118
:ref:`host <helm-values-ingress-host>`: null
@@ -1252,6 +1253,20 @@ Default: ``true``
12521253
ingress:
12531254
enabled: true
12541255
1256+
.. _helm-values-ingress-unified:
1257+
1258+
``ingress.unified``
1259+
^^^^^^^^^^^^^^^^^^^
1260+
1261+
Use a single ingress resource for the API server and other auxiliary services. Dedicated ingresses for these services will be skipped, e.g. grafana and oauth2-proxy.
1262+
1263+
Default: ``false``
1264+
1265+
.. code-block:: yaml
1266+
1267+
ingress:
1268+
unified: false
1269+
12551270
.. _helm-values-ingress-authSecret:
12561271
12571272
``ingress.authSecret``

0 commit comments

Comments
 (0)