Skip to content

Commit 13d28e7

Browse files
committed
improvement(helm): add internal ingress support and same-host path consolidation
1 parent f44594c commit 13d28e7

File tree

4 files changed

+236
-19
lines changed

4 files changed

+236
-19
lines changed

helm/sim/examples/values-azure.yaml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,28 +173,62 @@ ollama:
173173
OLLAMA_DEBUG: "1"
174174

175175
# Ingress configuration (NGINX ingress controller on Azure AKS)
176+
# Option 1: Separate subdomains (default)
176177
ingress:
177178
enabled: true
178179
className: nginx
179-
180+
180181
annotations:
181182
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
182-
183+
183184
# Main application
184185
app:
185186
host: simstudio.acme.com
186187
paths:
187188
- path: /
188189
pathType: Prefix
189-
190-
# Realtime service
190+
191+
# Realtime service (separate subdomain)
192+
# For same-domain setup, use host: simstudio.acme.com with path: /socket.io
191193
realtime:
192194
host: simstudio-ws.acme.com
193195
paths:
194196
- path: /
195197
pathType: Prefix
196-
198+
197199
# TLS configuration
198200
tls:
199201
enabled: true
200-
secretName: simstudio-tls-secret
202+
secretName: simstudio-tls-secret
203+
204+
# Internal Ingress configuration (for private access via internal load balancer)
205+
# Use this when you need access from within your VNet without going through the public internet
206+
# Supports Azure Application Gateway with private IP or NGINX with internal load balancer
207+
ingressInternal:
208+
enabled: false # Set to true to enable internal ingress
209+
className: azure-application-gateway # or nginx for internal NGINX
210+
211+
annotations:
212+
# For Azure Application Gateway with private IP:
213+
appgw.ingress.kubernetes.io/use-private-ip: "true"
214+
# For NGINX with internal Azure Load Balancer:
215+
# service.beta.kubernetes.io/azure-load-balancer-internal: "true"
216+
217+
# Main application (internal hostname)
218+
app:
219+
host: simstudio-internal.acme.local
220+
paths:
221+
- path: /
222+
pathType: Prefix
223+
224+
# Realtime service (same host with /socket.io path for consolidated routing)
225+
realtime:
226+
host: simstudio-internal.acme.local
227+
paths:
228+
- path: /socket.io
229+
pathType: Prefix
230+
231+
# TLS configuration (use internal CA cert if needed)
232+
tls:
233+
enabled: true
234+
secretName: simstudio-internal-tls-secret
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{{- if .Values.ingressInternal.enabled }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "sim.fullname" . }}-ingress-internal
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "sim.labels" . | nindent 4 }}
9+
{{- with .Values.ingressInternal.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
spec:
14+
{{- if .Values.ingressInternal.className }}
15+
ingressClassName: {{ .Values.ingressInternal.className }}
16+
{{- end }}
17+
{{- if .Values.ingressInternal.tls.enabled }}
18+
tls:
19+
- hosts:
20+
- {{ .Values.ingressInternal.app.host | quote }}
21+
{{- /* Add Realtime host only if enabled and unique */ -}}
22+
{{- if and .Values.realtime.enabled (ne .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }}
23+
- {{ .Values.ingressInternal.realtime.host | quote }}
24+
{{- end }}
25+
{{- /* Add Copilot host only if enabled, exists, and unique from both App and Realtime */ -}}
26+
{{- if and .Values.copilot.enabled .Values.ingressInternal.copilot }}
27+
{{- if and (ne .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) (ne .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }}
28+
- {{ .Values.ingressInternal.copilot.host | quote }}
29+
{{- end }}
30+
{{- end }}
31+
secretName: {{ .Values.ingressInternal.tls.secretName }}
32+
{{- end }}
33+
rules:
34+
# --- Main Rule: App (plus consolidated Realtime/Copilot if hosts match) ---
35+
- host: {{ .Values.ingressInternal.app.host | quote }}
36+
http:
37+
paths:
38+
{{- /* Consolidate Realtime paths here if host matches App */ -}}
39+
{{- if and .Values.realtime.enabled (eq .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }}
40+
{{- range .Values.ingressInternal.realtime.paths }}
41+
- path: {{ .path }}
42+
pathType: {{ .pathType }}
43+
backend:
44+
service:
45+
name: {{ include "sim.fullname" $ }}-realtime
46+
port:
47+
number: {{ $.Values.realtime.service.port }}
48+
{{- end }}
49+
{{- end }}
50+
{{- /* Consolidate Copilot paths here if host matches App */ -}}
51+
{{- if and .Values.copilot.enabled .Values.ingressInternal.copilot (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }}
52+
{{- range .Values.ingressInternal.copilot.paths }}
53+
- path: {{ .path }}
54+
pathType: {{ .pathType }}
55+
backend:
56+
service:
57+
name: {{ include "sim.fullname" $ }}-copilot
58+
port:
59+
number: {{ $.Values.copilot.server.service.port }}
60+
{{- end }}
61+
{{- end }}
62+
{{- /* App paths are always included in this first rule */ -}}
63+
{{- range .Values.ingressInternal.app.paths }}
64+
- path: {{ .path }}
65+
pathType: {{ .pathType }}
66+
backend:
67+
service:
68+
name: {{ include "sim.fullname" $ }}-app
69+
port:
70+
number: {{ $.Values.app.service.port }}
71+
{{- end }}
72+
73+
# --- Realtime Rule (Only if host is unique) ---
74+
{{- if and .Values.realtime.enabled (ne .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }}
75+
- host: {{ .Values.ingressInternal.realtime.host | quote }}
76+
http:
77+
paths:
78+
{{- range .Values.ingressInternal.realtime.paths }}
79+
- path: {{ .path }}
80+
pathType: {{ .pathType }}
81+
backend:
82+
service:
83+
name: {{ include "sim.fullname" $ }}-realtime
84+
port:
85+
number: {{ $.Values.realtime.service.port }}
86+
{{- end }}
87+
{{- end }}
88+
89+
# --- Copilot Rule (Only if host is unique from both App and Realtime) ---
90+
{{- if and .Values.copilot.enabled .Values.ingressInternal.copilot (and (ne .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) (ne .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host)) }}
91+
- host: {{ .Values.ingressInternal.copilot.host | quote }}
92+
http:
93+
paths:
94+
{{- range .Values.ingressInternal.copilot.paths }}
95+
- path: {{ .path }}
96+
pathType: {{ .pathType }}
97+
backend:
98+
service:
99+
name: {{ include "sim.fullname" $ }}-copilot
100+
port:
101+
number: {{ $.Values.copilot.server.service.port }}
102+
{{- end }}
103+
{{- end }}
104+
{{- end }}

helm/sim/templates/ingress.yaml

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,49 @@ spec:
1717
{{- if .Values.ingress.tls.enabled }}
1818
tls:
1919
- hosts:
20-
- {{ .Values.ingress.app.host }}
21-
{{- if .Values.realtime.enabled }}
22-
- {{ .Values.ingress.realtime.host }}
20+
- {{ .Values.ingress.app.host | quote }}
21+
{{- /* Add Realtime host only if enabled and unique */ -}}
22+
{{- if and .Values.realtime.enabled (ne .Values.ingress.realtime.host .Values.ingress.app.host) }}
23+
- {{ .Values.ingress.realtime.host | quote }}
2324
{{- end }}
25+
{{- /* Add Copilot host only if enabled, exists, and unique from both App and Realtime */ -}}
2426
{{- if and .Values.copilot.enabled .Values.ingress.copilot }}
25-
- {{ .Values.ingress.copilot.host }}
27+
{{- if and (ne .Values.ingress.copilot.host .Values.ingress.app.host) (ne .Values.ingress.copilot.host .Values.ingress.realtime.host) }}
28+
- {{ .Values.ingress.copilot.host | quote }}
29+
{{- end }}
2630
{{- end }}
2731
secretName: {{ .Values.ingress.tls.secretName }}
2832
{{- end }}
2933
rules:
30-
# Main application ingress rule
31-
- host: {{ .Values.ingress.app.host }}
34+
# --- Main Rule: App (plus consolidated Realtime/Copilot if hosts match) ---
35+
- host: {{ .Values.ingress.app.host | quote }}
3236
http:
3337
paths:
38+
{{- /* Consolidate Realtime paths here if host matches App */ -}}
39+
{{- if and .Values.realtime.enabled (eq .Values.ingress.realtime.host .Values.ingress.app.host) }}
40+
{{- range .Values.ingress.realtime.paths }}
41+
- path: {{ .path }}
42+
pathType: {{ .pathType }}
43+
backend:
44+
service:
45+
name: {{ include "sim.fullname" $ }}-realtime
46+
port:
47+
number: {{ $.Values.realtime.service.port }}
48+
{{- end }}
49+
{{- end }}
50+
{{- /* Consolidate Copilot paths here if host matches App */ -}}
51+
{{- if and .Values.copilot.enabled .Values.ingress.copilot (eq .Values.ingress.copilot.host .Values.ingress.app.host) }}
52+
{{- range .Values.ingress.copilot.paths }}
53+
- path: {{ .path }}
54+
pathType: {{ .pathType }}
55+
backend:
56+
service:
57+
name: {{ include "sim.fullname" $ }}-copilot
58+
port:
59+
number: {{ $.Values.copilot.server.service.port }}
60+
{{- end }}
61+
{{- end }}
62+
{{- /* App paths are always included in this first rule */ -}}
3463
{{- range .Values.ingress.app.paths }}
3564
- path: {{ .path }}
3665
pathType: {{ .pathType }}
@@ -40,9 +69,10 @@ spec:
4069
port:
4170
number: {{ $.Values.app.service.port }}
4271
{{- end }}
43-
{{- if .Values.realtime.enabled }}
44-
# Realtime service ingress rule
45-
- host: {{ .Values.ingress.realtime.host }}
72+
73+
# --- Realtime Rule (Only if host is unique) ---
74+
{{- if and .Values.realtime.enabled (ne .Values.ingress.realtime.host .Values.ingress.app.host) }}
75+
- host: {{ .Values.ingress.realtime.host | quote }}
4676
http:
4777
paths:
4878
{{- range .Values.ingress.realtime.paths }}
@@ -55,9 +85,10 @@ spec:
5585
number: {{ $.Values.realtime.service.port }}
5686
{{- end }}
5787
{{- end }}
58-
{{- if and .Values.copilot.enabled .Values.ingress.copilot }}
59-
# Copilot service ingress rule
60-
- host: {{ .Values.ingress.copilot.host }}
88+
89+
# --- Copilot Rule (Only if host is unique from both App and Realtime) ---
90+
{{- if and .Values.copilot.enabled .Values.ingress.copilot (and (ne .Values.ingress.copilot.host .Values.ingress.app.host) (ne .Values.ingress.copilot.host .Values.ingress.realtime.host)) }}
91+
- host: {{ .Values.ingress.copilot.host | quote }}
6192
http:
6293
paths:
6394
{{- range .Values.ingress.copilot.paths }}
@@ -70,4 +101,4 @@ spec:
70101
number: {{ $.Values.copilot.server.service.port }}
71102
{{- end }}
72103
{{- end }}
73-
{{- end }}
104+
{{- end }}

helm/sim/values.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,54 @@ ingress:
582582
enabled: false
583583
secretName: sim-tls-secret
584584

585+
# Internal Ingress configuration (for private/internal access)
586+
# Use this when you need a separate ingress for internal traffic
587+
# (e.g., internal load balancer with private IP)
588+
ingressInternal:
589+
# Enable/disable internal ingress
590+
enabled: false
591+
592+
# Ingress class name (e.g., nginx-internal, azure-application-gateway-internal)
593+
className: nginx
594+
595+
# Annotations (typically includes internal load balancer annotations)
596+
# Example for Azure:
597+
# kubernetes.io/ingress.class: azure/application-gateway
598+
# appgw.ingress.kubernetes.io/use-private-ip: "true"
599+
# Example for AWS:
600+
# alb.ingress.kubernetes.io/scheme: internal
601+
# Example for GCP:
602+
# kubernetes.io/ingress.class: "gce-internal"
603+
annotations: {}
604+
605+
# Main application host configuration
606+
app:
607+
host: sim-internal.local
608+
paths:
609+
- path: /
610+
pathType: Prefix
611+
612+
# Realtime service host configuration
613+
# Set to same host as app.host to consolidate paths under one rule
614+
# Use /socket.io path when sharing the same host
615+
realtime:
616+
host: sim-internal.local
617+
paths:
618+
- path: /socket.io
619+
pathType: Prefix
620+
621+
# Copilot service host configuration (optional)
622+
# copilot:
623+
# host: sim-internal.local
624+
# paths:
625+
# - path: /copilot
626+
# pathType: Prefix
627+
628+
# TLS configuration
629+
tls:
630+
enabled: false
631+
secretName: sim-internal-tls-secret
632+
585633
# Service Account configuration
586634
serviceAccount:
587635
# Specifies whether a service account should be created

0 commit comments

Comments
 (0)