Skip to content

Commit a3993b5

Browse files
committed
Put both architectures in one Service
The arm64 pods had their own name label, so they got their own Service and their own PodDisruptionBudget. The HTTPRoute backs only the amd64 Service, so the arm64 pods received no traffic. Both architectures now keep the same `app.kubernetes.io/name`. The arm64 variant adds `app.kubernetes.io/component: arm64`, which keeps its Deployment selector unique. One Service and one budget now cover the pods of both architectures, and the load balancer sends traffic to both. The amd64 output does not change. CAUTION: `spec.selector` of a Deployment is immutable. Delete each live `*-arm64` Deployment one time before the next sync.
1 parent a380dcf commit a3993b5

6 files changed

Lines changed: 44 additions & 49 deletions

File tree

charts/lago-rails/templates/_helpers.tpl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ amd64 name.
7373
{{- end }}
7474

7575
{{/*
76-
Create architecture-specific selector labels. The amd64 result delegates to
77-
the existing helper so its rendered labels do not change.
76+
Create architecture-specific selector labels. Both architectures keep the same
77+
`app.kubernetes.io/name`, so the Service selects the pods of both. arm64 adds
78+
`app.kubernetes.io/component`, which keeps its Deployment selector unique.
7879
*/}}
7980
{{- define "lago-rails.architecture.selectorLabels" -}}
80-
{{- if eq (include "lago-rails.architecture.isArm64" .) "true" -}}
81-
app.kubernetes.io/name: {{ printf "%s-arm64" .Values.internalArchitectureName | trunc 63 | trimSuffix "-" }}
82-
app.kubernetes.io/instance: {{ .Release.Name }}
83-
{{- else -}}
8481
{{- include "lago-rails.selectorLabels" . -}}
82+
{{- if eq (include "lago-rails.architecture.isArm64" .) "true" }}
83+
app.kubernetes.io/component: arm64
8584
{{- end -}}
8685
{{- end }}
8786

charts/lago-rails/templates/deployment.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ spec:
480480
{{- $_ := set $amd64Values "tolerations" (concat .Values.tolerations $amd64.tolerations) }}
481481
{{- $amd64Context := dict "Values" $amd64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
482482
{{- $architectureFullname := include "lago-rails.fullname" $amd64Context }}
483-
{{- $architectureName := include "lago-rails.name" $amd64Context }}
484483
{{- if .Values.global.architectures.amd64.enabled }}
485484
{{ include "lago-rails.deployment" $amd64Context }}
486485
{{- end }}
@@ -492,7 +491,6 @@ spec:
492491
{{- $arm64Values := deepCopy .Values }}
493492
{{- $_ := set $arm64Values "internalArchitecture" "arm64" }}
494493
{{- $_ := set $arm64Values "internalArchitectureFullname" $architectureFullname }}
495-
{{- $_ := set $arm64Values "internalArchitectureName" $architectureName }}
496494
{{- $_ := set $arm64Values "replicaCount" $arm64.replicaCount }}
497495
{{- $_ := set $arm64Values "nodeSelector" (mustMergeOverwrite (deepCopy .Values.nodeSelector) $arm64.nodeSelector) }}
498496
{{- $_ := set $arm64Values "tolerations" (concat .Values.tolerations $arm64.tolerations) }}

charts/lago-rails/templates/hpa.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ spec:
4242
{{- $arm64Values := deepCopy .Values }}
4343
{{- $_ := set $arm64Values "internalArchitecture" "arm64" }}
4444
{{- $_ := set $arm64Values "internalArchitectureFullname" (include "lago-rails.fullname" .) }}
45-
{{- $_ := set $arm64Values "internalArchitectureName" (include "lago-rails.name" .) }}
4645
{{- $_ := set $arm64Values "autoscaling" $arm64.autoscaling }}
4746
{{- $arm64Context := dict "Values" $arm64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
4847
{{ include "lago-rails.hpa" $arm64Context }}
Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
{{- define "lago-rails.pdb" -}}
1+
{{/*
2+
One PodDisruptionBudget for all architectures. The pods of both serve the same
3+
Service, so one budget applies to them together.
4+
*/}}
5+
{{- if .Values.podDisruptionBudget.enabled }}
26
apiVersion: policy/v1
37
kind: PodDisruptionBudget
48
metadata:
5-
name: {{ include "lago-rails.architecture.fullname" . }}
9+
name: {{ include "lago-rails.fullname" . }}
610
labels:
7-
{{- include "lago-rails.architecture.labels" . | nindent 4 }}
11+
{{- include "lago-rails.labels" . | nindent 4 }}
812
spec:
913
{{- with .Values.podDisruptionBudget.minAvailable }}
1014
minAvailable: {{ . }}
@@ -14,21 +18,5 @@ spec:
1418
{{- end }}
1519
selector:
1620
matchLabels:
17-
{{- include "lago-rails.architecture.selectorLabels" . | nindent 6 }}
18-
{{- end }}
19-
20-
{{- if .Values.podDisruptionBudget.enabled }}
21-
{{- $amd64Values := deepCopy .Values }}
22-
{{- $amd64Context := dict "Values" $amd64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
23-
{{ include "lago-rails.pdb" $amd64Context }}
24-
{{- $arm64 := .Values.architectures.arm64 }}
25-
{{- if and .Values.global.architectures.arm64.enabled (or (gt (int $arm64.replicaCount) 0) $arm64.autoscaling.enabled) }}
26-
---
27-
{{- $arm64Values := deepCopy .Values }}
28-
{{- $_ := set $arm64Values "internalArchitecture" "arm64" }}
29-
{{- $_ := set $arm64Values "internalArchitectureFullname" (include "lago-rails.fullname" .) }}
30-
{{- $_ := set $arm64Values "internalArchitectureName" (include "lago-rails.name" .) }}
31-
{{- $arm64Context := dict "Values" $arm64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
32-
{{ include "lago-rails.pdb" $arm64Context }}
33-
{{- end }}
21+
{{- include "lago-rails.selectorLabels" . | nindent 6 }}
3422
{{- end }}
Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
{{- define "lago-rails.service" -}}
1+
{{/*
2+
One Service for all architectures. The selector has no
3+
`app.kubernetes.io/component`, so it matches amd64 pods and arm64 pods.
4+
*/}}
5+
{{- if .Values.service.enabled }}
26
apiVersion: v1
37
kind: Service
48
metadata:
5-
name: {{ include "lago-rails.architecture.fullname" . }}
9+
name: {{ include "lago-rails.fullname" . }}
610
labels:
7-
{{- include "lago-rails.architecture.labels" . | nindent 4 }}
11+
{{- include "lago-rails.labels" . | nindent 4 }}
812
spec:
913
type: {{ .Values.service.type }}
1014
ports:
@@ -13,21 +17,5 @@ spec:
1317
protocol: TCP
1418
name: http
1519
selector:
16-
{{- include "lago-rails.architecture.selectorLabels" . | nindent 4 }}
17-
{{- end }}
18-
19-
{{- if .Values.service.enabled }}
20-
{{- $amd64Values := deepCopy .Values }}
21-
{{- $amd64Context := dict "Values" $amd64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
22-
{{ include "lago-rails.service" $amd64Context }}
23-
{{- $arm64 := .Values.architectures.arm64 }}
24-
{{- if and .Values.global.architectures.arm64.enabled (or (gt (int $arm64.replicaCount) 0) $arm64.autoscaling.enabled) }}
25-
---
26-
{{- $arm64Values := deepCopy .Values }}
27-
{{- $_ := set $arm64Values "internalArchitecture" "arm64" }}
28-
{{- $_ := set $arm64Values "internalArchitectureFullname" (include "lago-rails.fullname" .) }}
29-
{{- $_ := set $arm64Values "internalArchitectureName" (include "lago-rails.name" .) }}
30-
{{- $arm64Context := dict "Values" $arm64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
31-
{{ include "lago-rails.service" $arm64Context }}
32-
{{- end }}
20+
{{- include "lago-rails.selectorLabels" . | nindent 4 }}
3321
{{- end }}

charts/lago/tests/architecture_test.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ suite: Test amd64 and arm64 API and worker deployments
22
templates:
33
- charts/api/templates/deployment.yaml
44
- charts/worker/templates/deployment.yaml
5+
- charts/api/templates/service.yaml
56

67
set:
78
global:
@@ -201,6 +202,28 @@ tests:
201202
- hasDocuments:
202203
count: 1
203204

205+
- it: gives the arm64 API deployment the shared name and the architecture label
206+
template: charts/api/templates/deployment.yaml
207+
documentIndex: 1
208+
asserts:
209+
- equal:
210+
path: spec.selector.matchLabels
211+
value:
212+
app.kubernetes.io/name: lago-api
213+
app.kubernetes.io/instance: RELEASE-NAME
214+
app.kubernetes.io/component: arm64
215+
216+
- it: renders one API service that selects both architectures
217+
template: charts/api/templates/service.yaml
218+
asserts:
219+
- hasDocuments:
220+
count: 1
221+
- equal:
222+
path: spec.selector
223+
value:
224+
app.kubernetes.io/name: lago-api
225+
app.kubernetes.io/instance: RELEASE-NAME
226+
204227
- it: renders an arm64 worker without replicas when KEDA controls it
205228
template: charts/worker/templates/deployment.yaml
206229
set:

0 commit comments

Comments
 (0)