Skip to content

Commit

Permalink
Merge pull request #816 from tedteng/mc-lables
Browse files Browse the repository at this point in the history
add operatingsystem label
  • Loading branch information
AndreasBurger authored Apr 11, 2024
2 parents 81c5530 + 5a5c248 commit b859d7b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions charts/internal/machineclass/templates/machineclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ kind: MachineClass
metadata:
name: {{ $machineClass.name }}
namespace: {{ $.Release.Namespace }}
labels:
{{- if $machineClass.operatingSystem }}
{{ toYaml $machineClass.operatingSystem | indent 4 }}
{{- end }}
{{- if $machineClass.labels }}
{{ toYaml $machineClass.labels | indent 4 }}
{{- end }}
{{- if $machineClass.nodeTemplate }}
nodeTemplate:
capacity:
Expand Down
7 changes: 7 additions & 0 deletions pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error {
machineClassSpec["name"] = className
machineClassSpec["labels"] = map[string]string{v1beta1constants.GardenerPurpose: v1beta1constants.GardenPurposeMachineClass}

if pool.MachineImage.Name != "" && pool.MachineImage.Version != "" {
machineClassSpec["operatingSystem"] = map[string]interface{}{
"operatingSystemName": pool.MachineImage.Name,
"operatingSystemVersion": pool.MachineImage.Version,
}
}

return machineDeployment, machineClassSpec
}

Expand Down
17 changes: 17 additions & 0 deletions pkg/controller/worker/machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,23 @@ var _ = Describe("Machines", func() {
"type": volumeType,
}

machineClassPool1["operatingSystem"] = map[string]interface{}{
"operatingSystemName": machineImageName,
"operatingSystemVersion": machineImageVersion,
}
machineClassPool2["operatingSystem"] = map[string]interface{}{
"operatingSystemName": machineImageName,
"operatingSystemVersion": machineImageVersionID,
}
machineClassPool3["operatingSystem"] = map[string]interface{}{
"operatingSystemName": machineImageName,
"operatingSystemVersion": machineImageVersionCommunityID,
}
machineClassPool4["operatingSystem"] = map[string]interface{}{
"operatingSystemName": machineImageName,
"operatingSystemVersion": machineImageVersionSharedID,
}

machineClasses = map[string]interface{}{"machineClasses": []map[string]interface{}{
machineClassPool1,
machineClassPool2,
Expand Down

0 comments on commit b859d7b

Please sign in to comment.