Skip to content

Commit d4107da

Browse files
committed
improvement(helm): support copilot-only deployments
1 parent 20b230d commit d4107da

File tree

7 files changed

+96
-21
lines changed

7 files changed

+96
-21
lines changed

helm/sim/examples/values-copilot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ copilot:
6363

6464
image:
6565
repository: postgres
66-
tag: 16-alpine
66+
tag: 17-alpine
6767
pullPolicy: IfNotPresent
6868

6969
auth:

helm/sim/templates/ingress-internal.yaml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{{- if .Values.ingressInternal.enabled }}
2+
{{- $appActive := .Values.app.enabled -}}
3+
{{- $realtimeActive := .Values.realtime.enabled -}}
4+
{{- $hasCopilotIngress := and .Values.copilot.enabled .Values.ingressInternal.copilot -}}
5+
{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host)) -}}
26
apiVersion: networking.k8s.io/v1
37
kind: Ingress
48
metadata:
@@ -17,22 +21,32 @@ spec:
1721
{{- if .Values.ingressInternal.tls.enabled }}
1822
tls:
1923
- hosts:
24+
{{- if $appActive }}
2025
- {{ .Values.ingressInternal.app.host | quote }}
21-
{{- if and .Values.realtime.enabled (ne .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }}
26+
{{- end }}
27+
{{- if $realtimeHasOwnRule }}
2228
- {{ .Values.ingressInternal.realtime.host | quote }}
2329
{{- end }}
24-
{{- if and .Values.copilot.enabled .Values.ingressInternal.copilot }}
25-
{{- if and (ne .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) (ne .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }}
30+
{{- if $hasCopilotIngress }}
31+
{{- $copilotHostCovered := false }}
32+
{{- if and $appActive (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }}
33+
{{- $copilotHostCovered = true }}
34+
{{- end }}
35+
{{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }}
36+
{{- $copilotHostCovered = true }}
37+
{{- end }}
38+
{{- if not $copilotHostCovered }}
2639
- {{ .Values.ingressInternal.copilot.host | quote }}
2740
{{- end }}
2841
{{- end }}
2942
secretName: {{ .Values.ingressInternal.tls.secretName }}
3043
{{- end }}
3144
rules:
45+
{{- if $appActive }}
3246
- host: {{ .Values.ingressInternal.app.host | quote }}
3347
http:
3448
paths:
35-
{{- if and .Values.realtime.enabled (eq .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }}
49+
{{- if and $realtimeActive (eq .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }}
3650
{{- range .Values.ingressInternal.realtime.paths }}
3751
- path: {{ .path }}
3852
pathType: {{ .pathType }}
@@ -43,7 +57,7 @@ spec:
4357
number: {{ $.Values.realtime.service.port }}
4458
{{- end }}
4559
{{- end }}
46-
{{- if and .Values.copilot.enabled .Values.ingressInternal.copilot (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }}
60+
{{- if and $hasCopilotIngress (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }}
4761
{{- range .Values.ingressInternal.copilot.paths }}
4862
- path: {{ .path }}
4963
pathType: {{ .pathType }}
@@ -63,7 +77,8 @@ spec:
6377
port:
6478
number: {{ $.Values.app.service.port }}
6579
{{- end }}
66-
{{- if and .Values.realtime.enabled (ne .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }}
80+
{{- end }}
81+
{{- if $realtimeHasOwnRule }}
6782
- host: {{ .Values.ingressInternal.realtime.host | quote }}
6883
http:
6984
paths:
@@ -76,7 +91,7 @@ spec:
7691
port:
7792
number: {{ $.Values.realtime.service.port }}
7893
{{- end }}
79-
{{- if and .Values.copilot.enabled .Values.ingressInternal.copilot (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }}
94+
{{- if and $hasCopilotIngress (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }}
8095
{{- range .Values.ingressInternal.copilot.paths }}
8196
- path: {{ .path }}
8297
pathType: {{ .pathType }}
@@ -88,7 +103,15 @@ spec:
88103
{{- end }}
89104
{{- end }}
90105
{{- end }}
91-
{{- 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)) }}
106+
{{- if $hasCopilotIngress }}
107+
{{- $copilotServed := false }}
108+
{{- if and $appActive (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }}
109+
{{- $copilotServed = true }}
110+
{{- end }}
111+
{{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }}
112+
{{- $copilotServed = true }}
113+
{{- end }}
114+
{{- if not $copilotServed }}
92115
- host: {{ .Values.ingressInternal.copilot.host | quote }}
93116
http:
94117
paths:
@@ -101,5 +124,6 @@ spec:
101124
port:
102125
number: {{ $.Values.copilot.server.service.port }}
103126
{{- end }}
127+
{{- end }}
104128
{{- end }}
105129
{{- end }}

helm/sim/templates/ingress.yaml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{{- if .Values.ingress.enabled }}
2+
{{- $appActive := .Values.app.enabled -}}
3+
{{- $realtimeActive := .Values.realtime.enabled -}}
4+
{{- $hasCopilotIngress := and .Values.copilot.enabled .Values.ingress.copilot -}}
5+
{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne .Values.ingress.realtime.host .Values.ingress.app.host)) -}}
26
apiVersion: networking.k8s.io/v1
37
kind: Ingress
48
metadata:
@@ -17,22 +21,32 @@ spec:
1721
{{- if .Values.ingress.tls.enabled }}
1822
tls:
1923
- hosts:
24+
{{- if $appActive }}
2025
- {{ .Values.ingress.app.host | quote }}
21-
{{- if and .Values.realtime.enabled (ne .Values.ingress.realtime.host .Values.ingress.app.host) }}
26+
{{- end }}
27+
{{- if $realtimeHasOwnRule }}
2228
- {{ .Values.ingress.realtime.host | quote }}
2329
{{- end }}
24-
{{- if and .Values.copilot.enabled .Values.ingress.copilot }}
25-
{{- if and (ne .Values.ingress.copilot.host .Values.ingress.app.host) (ne .Values.ingress.copilot.host .Values.ingress.realtime.host) }}
30+
{{- if $hasCopilotIngress }}
31+
{{- $copilotHostCovered := false }}
32+
{{- if and $appActive (eq .Values.ingress.copilot.host .Values.ingress.app.host) }}
33+
{{- $copilotHostCovered = true }}
34+
{{- end }}
35+
{{- if and $realtimeHasOwnRule (eq .Values.ingress.copilot.host .Values.ingress.realtime.host) }}
36+
{{- $copilotHostCovered = true }}
37+
{{- end }}
38+
{{- if not $copilotHostCovered }}
2639
- {{ .Values.ingress.copilot.host | quote }}
2740
{{- end }}
2841
{{- end }}
2942
secretName: {{ .Values.ingress.tls.secretName }}
3043
{{- end }}
3144
rules:
45+
{{- if $appActive }}
3246
- host: {{ .Values.ingress.app.host | quote }}
3347
http:
3448
paths:
35-
{{- if and .Values.realtime.enabled (eq .Values.ingress.realtime.host .Values.ingress.app.host) }}
49+
{{- if and $realtimeActive (eq .Values.ingress.realtime.host .Values.ingress.app.host) }}
3650
{{- range .Values.ingress.realtime.paths }}
3751
- path: {{ .path }}
3852
pathType: {{ .pathType }}
@@ -43,7 +57,7 @@ spec:
4357
number: {{ $.Values.realtime.service.port }}
4458
{{- end }}
4559
{{- end }}
46-
{{- if and .Values.copilot.enabled .Values.ingress.copilot (eq .Values.ingress.copilot.host .Values.ingress.app.host) }}
60+
{{- if and $hasCopilotIngress (eq .Values.ingress.copilot.host .Values.ingress.app.host) }}
4761
{{- range .Values.ingress.copilot.paths }}
4862
- path: {{ .path }}
4963
pathType: {{ .pathType }}
@@ -63,7 +77,8 @@ spec:
6377
port:
6478
number: {{ $.Values.app.service.port }}
6579
{{- end }}
66-
{{- if and .Values.realtime.enabled (ne .Values.ingress.realtime.host .Values.ingress.app.host) }}
80+
{{- end }}
81+
{{- if $realtimeHasOwnRule }}
6782
- host: {{ .Values.ingress.realtime.host | quote }}
6883
http:
6984
paths:
@@ -76,7 +91,7 @@ spec:
7691
port:
7792
number: {{ $.Values.realtime.service.port }}
7893
{{- end }}
79-
{{- if and .Values.copilot.enabled .Values.ingress.copilot (eq .Values.ingress.copilot.host .Values.ingress.realtime.host) }}
94+
{{- if and $hasCopilotIngress (eq .Values.ingress.copilot.host .Values.ingress.realtime.host) }}
8095
{{- range .Values.ingress.copilot.paths }}
8196
- path: {{ .path }}
8297
pathType: {{ .pathType }}
@@ -88,7 +103,15 @@ spec:
88103
{{- end }}
89104
{{- end }}
90105
{{- end }}
91-
{{- 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)) }}
106+
{{- if $hasCopilotIngress }}
107+
{{- $copilotServed := false }}
108+
{{- if and $appActive (eq .Values.ingress.copilot.host .Values.ingress.app.host) }}
109+
{{- $copilotServed = true }}
110+
{{- end }}
111+
{{- if and $realtimeHasOwnRule (eq .Values.ingress.copilot.host .Values.ingress.realtime.host) }}
112+
{{- $copilotServed = true }}
113+
{{- end }}
114+
{{- if not $copilotServed }}
92115
- host: {{ .Values.ingress.copilot.host | quote }}
93116
http:
94117
paths:
@@ -101,5 +124,6 @@ spec:
101124
port:
102125
number: {{ $.Values.copilot.server.service.port }}
103126
{{- end }}
127+
{{- end }}
104128
{{- end }}
105129
{{- end }}

helm/sim/templates/job-copilot-migrations.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spec:
3636
{{- if .Values.copilot.postgresql.enabled }}
3737
initContainers:
3838
- name: wait-for-postgres
39-
image: postgres:16-alpine
39+
image: {{ include "sim.image" (dict "context" . "image" .Values.copilot.postgresql.image) }}
4040
command:
4141
- /bin/sh
4242
- -c

helm/sim/templates/statefulset-copilot-postgres.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ spec:
8080
- name: postgresql
8181
containerPort: {{ .Values.copilot.postgresql.service.targetPort }}
8282
protocol: TCP
83+
env:
84+
- name: PGDATA
85+
value: /var/lib/postgresql/data/pgdata
8386
envFrom:
8487
- secretRef:
8588
name: {{ include "sim.fullname" . }}-copilot-postgresql-secret

helm/sim/values.schema.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,31 @@
10081008
}
10091009
}
10101010
}
1011-
}
1011+
},
1012+
"anyOf": [
1013+
{
1014+
"properties": {
1015+
"app": {
1016+
"properties": {
1017+
"enabled": {
1018+
"const": true
1019+
}
1020+
}
1021+
}
1022+
}
1023+
},
1024+
{
1025+
"properties": {
1026+
"realtime": {
1027+
"properties": {
1028+
"enabled": {
1029+
"const": true
1030+
}
1031+
}
1032+
}
1033+
}
1034+
}
1035+
]
10121036
},
10131037
"then": {
10141038
"properties": {

helm/sim/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,11 +1073,11 @@ copilot:
10731073
postgresql:
10741074
# Enable/disable internal PostgreSQL for copilot
10751075
enabled: true
1076-
1076+
10771077
# Image configuration
10781078
image:
10791079
repository: postgres
1080-
tag: 16-alpine
1080+
tag: 17-alpine
10811081
pullPolicy: IfNotPresent
10821082

10831083
# Authentication configuration

0 commit comments

Comments
 (0)