Skip to content

Commit 33363d5

Browse files
authored
feat: Split workloads by architecture (#240)
1 parent cd210df commit 33363d5

12 files changed

Lines changed: 460 additions & 266 deletions

File tree

charts/lago-rails/templates/_helpers.tpl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,56 @@ app.kubernetes.io/name: {{ include "lago-rails.name" . }}
5252
app.kubernetes.io/instance: {{ .Release.Name }}
5353
{{- end }}
5454

55+
{{/*
56+
Return true when the current resource is the arm64 architecture variant.
57+
*/}}
58+
{{- define "lago-rails.architecture.isArm64" -}}
59+
{{- eq (default "amd64" .Values.internalArchitecture) "arm64" -}}
60+
{{- end }}
61+
62+
{{/*
63+
Create an architecture-specific workload name without changing the existing
64+
amd64 name.
65+
*/}}
66+
{{- define "lago-rails.architecture.fullname" -}}
67+
{{- $fullname := include "lago-rails.fullname" . -}}
68+
{{- if eq (include "lago-rails.architecture.isArm64" .) "true" -}}
69+
{{- printf "%s-arm64" .Values.internalArchitectureFullname | trunc 63 | trimSuffix "-" -}}
70+
{{- else -}}
71+
{{- $fullname -}}
72+
{{- end -}}
73+
{{- end }}
74+
75+
{{/*
76+
Create architecture-specific selector labels. The amd64 result delegates to
77+
the existing helper so its rendered labels do not change.
78+
*/}}
79+
{{- 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 -}}
84+
{{- include "lago-rails.selectorLabels" . -}}
85+
{{- end -}}
86+
{{- end }}
87+
88+
{{/*
89+
Create architecture-specific labels. The amd64 result delegates to the
90+
existing helper so its rendered labels do not change.
91+
*/}}
92+
{{- define "lago-rails.architecture.labels" -}}
93+
{{- if eq (include "lago-rails.architecture.isArm64" .) "true" -}}
94+
helm.sh/chart: {{ include "lago-rails.chart" . }}
95+
{{ include "lago-rails.architecture.selectorLabels" . }}
96+
{{- if .Chart.AppVersion }}
97+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
98+
{{- end }}
99+
app.kubernetes.io/managed-by: {{ .Release.Service }}
100+
{{- else -}}
101+
{{- include "lago-rails.labels" . -}}
102+
{{- end -}}
103+
{{- end }}
104+
55105
{{/*
56106
Create the name of the service account to use
57107
*/}}

charts/lago-rails/templates/deployment.yaml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1+
{{- define "lago-rails.deployment" -}}
12
apiVersion: apps/v1
23
kind: Deployment
34
metadata:
4-
name: {{ include "lago-rails.fullname" . }}
5+
name: {{ include "lago-rails.architecture.fullname" . }}
56
{{- with .Values.annotations }}
67
annotations:
78
{{- toYaml . | nindent 4 }}
89
{{- end }}
910
labels:
10-
{{- include "lago-rails.labels" . | nindent 4 }}
11+
{{- include "lago-rails.architecture.labels" . | nindent 4 }}
1112
spec:
1213
{{- if not .Values.autoscaling.enabled }}
1314
replicas: {{ .Values.replicaCount }}
1415
{{- end }}
1516
selector:
1617
matchLabels:
17-
{{- include "lago-rails.selectorLabels" . | nindent 6 }}
18+
{{- include "lago-rails.architecture.selectorLabels" . | nindent 6 }}
1819
template:
1920
metadata:
2021
{{- with .Values.podAnnotations }}
2122
annotations:
2223
{{- toYaml . | nindent 8 }}
2324
{{- end }}
2425
labels:
25-
{{- include "lago-rails.labels" . | nindent 8 }}
26+
{{- include "lago-rails.architecture.labels" . | nindent 8 }}
2627
{{- with .Values.podLabels }}
2728
{{- toYaml . | nindent 8 }}
2829
{{- end }}
@@ -468,3 +469,34 @@ spec:
468469
tolerations:
469470
{{- toYaml . | nindent 8 }}
470471
{{- end }}
472+
{{- end }}
473+
474+
{{- $amd64 := .Values.architectures.amd64 }}
475+
{{- $amd64Values := deepCopy .Values }}
476+
{{- if ne $amd64.replicaCount nil }}
477+
{{- $_ := set $amd64Values "replicaCount" $amd64.replicaCount }}
478+
{{- end }}
479+
{{- $_ := set $amd64Values "nodeSelector" (mustMergeOverwrite (deepCopy .Values.nodeSelector) $amd64.nodeSelector) }}
480+
{{- $_ := set $amd64Values "tolerations" (concat .Values.tolerations $amd64.tolerations) }}
481+
{{- $amd64Context := dict "Values" $amd64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
482+
{{- $architectureFullname := include "lago-rails.fullname" $amd64Context }}
483+
{{- $architectureName := include "lago-rails.name" $amd64Context }}
484+
{{- if .Values.global.architectures.amd64.enabled }}
485+
{{ include "lago-rails.deployment" $amd64Context }}
486+
{{- end }}
487+
488+
{{- $arm64 := .Values.architectures.arm64 }}
489+
{{- $arm64Enabled := and .Values.global.architectures.arm64.enabled (or (gt (int $arm64.replicaCount) 0) $arm64.autoscaling.enabled) }}
490+
{{- if $arm64Enabled }}
491+
---
492+
{{- $arm64Values := deepCopy .Values }}
493+
{{- $_ := set $arm64Values "internalArchitecture" "arm64" }}
494+
{{- $_ := set $arm64Values "internalArchitectureFullname" $architectureFullname }}
495+
{{- $_ := set $arm64Values "internalArchitectureName" $architectureName }}
496+
{{- $_ := set $arm64Values "replicaCount" $arm64.replicaCount }}
497+
{{- $_ := set $arm64Values "nodeSelector" (mustMergeOverwrite (deepCopy .Values.nodeSelector) $arm64.nodeSelector) }}
498+
{{- $_ := set $arm64Values "tolerations" (concat .Values.tolerations $arm64.tolerations) }}
499+
{{- $_ := set $arm64Values "autoscaling" $arm64.autoscaling }}
500+
{{- $arm64Context := dict "Values" $arm64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
501+
{{ include "lago-rails.deployment" $arm64Context }}
502+
{{- end }}

charts/lago-rails/templates/hpa.yaml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
{{- if and .Values.autoscaling.enabled (not .Values.autoscaling.external) }}
1+
{{- define "lago-rails.hpa" -}}
22
apiVersion: autoscaling/v2
33
kind: HorizontalPodAutoscaler
44
metadata:
5-
name: {{ include "lago-rails.fullname" . }}
5+
name: {{ include "lago-rails.architecture.fullname" . }}
66
labels:
7-
{{- include "lago-rails.labels" . | nindent 4 }}
7+
{{- include "lago-rails.architecture.labels" . | nindent 4 }}
88
spec:
99
scaleTargetRef:
1010
apiVersion: apps/v1
1111
kind: Deployment
12-
name: {{ include "lago-rails.fullname" . }}
12+
name: {{ include "lago-rails.architecture.fullname" . }}
1313
minReplicas: {{ .Values.autoscaling.minReplicas }}
1414
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
1515
metrics:
@@ -30,3 +30,20 @@ spec:
3030
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
3131
{{- end }}
3232
{{- end }}
33+
34+
{{- if and .Values.autoscaling.enabled (not .Values.autoscaling.external) }}
35+
{{- $amd64Values := deepCopy .Values }}
36+
{{- $amd64Context := dict "Values" $amd64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
37+
{{ include "lago-rails.hpa" $amd64Context }}
38+
{{- end }}
39+
{{- $arm64 := .Values.architectures.arm64 }}
40+
{{- if and .Values.global.architectures.arm64.enabled $arm64.autoscaling.enabled (not $arm64.autoscaling.external) }}
41+
---
42+
{{- $arm64Values := deepCopy .Values }}
43+
{{- $_ := set $arm64Values "internalArchitecture" "arm64" }}
44+
{{- $_ := set $arm64Values "internalArchitectureFullname" (include "lago-rails.fullname" .) }}
45+
{{- $_ := set $arm64Values "internalArchitectureName" (include "lago-rails.name" .) }}
46+
{{- $_ := set $arm64Values "autoscaling" $arm64.autoscaling }}
47+
{{- $arm64Context := dict "Values" $arm64Values "Chart" .Chart "Release" .Release "Capabilities" .Capabilities "Template" .Template "Files" .Files }}
48+
{{ include "lago-rails.hpa" $arm64Context }}
49+
{{- end }}
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{{- if .Values.podDisruptionBudget.enabled }}
1+
{{- define "lago-rails.pdb" -}}
22
apiVersion: policy/v1
33
kind: PodDisruptionBudget
44
metadata:
5-
name: {{ include "lago-rails.fullname" . }}
5+
name: {{ include "lago-rails.architecture.fullname" . }}
66
labels:
7-
{{- include "lago-rails.labels" . | nindent 4 }}
7+
{{- include "lago-rails.architecture.labels" . | nindent 4 }}
88
spec:
99
{{- with .Values.podDisruptionBudget.minAvailable }}
1010
minAvailable: {{ . }}
@@ -14,5 +14,21 @@ spec:
1414
{{- end }}
1515
selector:
1616
matchLabels:
17-
{{- include "lago-rails.selectorLabels" . | nindent 6 }}
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 }}
1834
{{- end }}
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{{- if .Values.service.enabled }}
1+
{{- define "lago-rails.service" -}}
22
apiVersion: v1
33
kind: Service
44
metadata:
5-
name: {{ include "lago-rails.fullname" . }}
5+
name: {{ include "lago-rails.architecture.fullname" . }}
66
labels:
7-
{{- include "lago-rails.labels" . | nindent 4 }}
7+
{{- include "lago-rails.architecture.labels" . | nindent 4 }}
88
spec:
99
type: {{ .Values.service.type }}
1010
ports:
@@ -13,5 +13,21 @@ spec:
1313
protocol: TCP
1414
name: http
1515
selector:
16-
{{- include "lago-rails.selectorLabels" . | nindent 4 }}
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 }}
1733
{{- end }}

charts/lago-rails/values.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
# -- @ignore
44
global:
5+
architectures:
6+
amd64:
7+
enabled: true
8+
arm64:
9+
enabled: false
10+
511
lago:
612
# -- Override the application Docker image tag (defaults to Chart appVersion)
713
# @section -- Lago
@@ -666,6 +672,50 @@ autoscaling:
666672
targetCPUUtilizationPercentage: 80
667673
# targetMemoryUtilizationPercentage: 80
668674

675+
# -- Replica and scheduling overrides for each supported CPU architecture.
676+
# The amd64 values fall back to the existing top-level workload values.
677+
# The arm64 deployment uses the same workload values and applies only these
678+
# architecture-specific overrides.
679+
# @section -- Architectures
680+
architectures:
681+
amd64:
682+
# -- Override the existing `replicaCount` for the amd64 deployment
683+
# @section -- Architectures
684+
replicaCount:
685+
# -- Additional node selector constraints for the amd64 deployment
686+
# @section -- Architectures
687+
nodeSelector: {}
688+
# -- Additional tolerations for the amd64 deployment
689+
# @section -- Architectures
690+
tolerations: []
691+
arm64:
692+
# -- Replica count for the arm64 deployment. Zero disables this workload.
693+
# @section -- Architectures
694+
replicaCount: 0
695+
# -- Additional node selector constraints for the arm64 deployment
696+
# @section -- Architectures
697+
nodeSelector:
698+
kubernetes.io/arch: arm64
699+
# -- Additional tolerations for the arm64 deployment
700+
# @section -- Architectures
701+
tolerations: []
702+
autoscaling:
703+
# -- Enable the built-in HPA for the arm64 deployment
704+
# @section -- Architectures
705+
enabled: false
706+
# -- Set to true when an external autoscaler controls the arm64 deployment
707+
# @section -- Architectures
708+
external: false
709+
# -- Minimum arm64 replicas
710+
# @section -- Architectures
711+
minReplicas: 1
712+
# -- Maximum arm64 replicas
713+
# @section -- Architectures
714+
maxReplicas: 100
715+
# -- Target CPU utilization percentage for arm64 pods
716+
# @section -- Architectures
717+
targetCPUUtilizationPercentage: 80
718+
669719
podDisruptionBudget:
670720
# -- Create a PodDisruptionBudget. Only enable on multi-replica deployments
671721
# @section -- Pod Disruption Budget

charts/lago/Chart.lock

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ dependencies:
55
- name: lago-rails
66
repository: file://../lago-rails
77
version: 0.12.0
8-
- name: lago-rails
9-
repository: file://../lago-rails
10-
version: 0.12.0
118
- name: lago-front
129
repository: file://../lago-front
1310
version: 0.12.0
@@ -32,9 +29,6 @@ dependencies:
3229
- name: lago-rails
3330
repository: file://../lago-rails
3431
version: 0.12.0
35-
- name: lago-rails
36-
repository: file://../lago-rails
37-
version: 0.12.0
3832
- name: lago-pdf
3933
repository: file://../lago-pdf
4034
version: 0.12.0
@@ -62,5 +56,5 @@ dependencies:
6256
- name: lago-rails
6357
repository: file://../lago-rails
6458
version: 0.12.0
65-
digest: sha256:6f31f754f413050f94098daeb98d5d216906e775ecbde3e8a45b24423f478ca9
66-
generated: "2026-08-31T06:54:46.503186033Z"
59+
digest: sha256:65f9fb2858fbb769db6c28fb4c3ef26533ca80772051376cb56bf24a29ad9729
60+
generated: "2026-08-31T17:59:45.533840433+03:00"

charts/lago/Chart.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ dependencies:
2727
alias: api
2828
version: 0.12.0
2929
repository: "file://../lago-rails"
30-
- name: lago-rails
31-
alias: api-arm64
32-
version: 0.12.0
33-
repository: "file://../lago-rails"
34-
condition: global.arm64.api.enabled
3530
- name: lago-front
3631
alias: front
3732
version: 0.12.0
@@ -40,11 +35,6 @@ dependencies:
4035
alias: worker
4136
version: 0.12.0
4237
repository: "file://../lago-rails"
43-
- name: lago-rails
44-
alias: worker-arm64
45-
version: 0.12.0
46-
repository: "file://../lago-rails"
47-
condition: global.arm64.worker.enabled
4838
- name: lago-rails
4939
alias: clock
5040
version: 0.12.0

0 commit comments

Comments
 (0)