Skip to content

Commit

Permalink
Pass NodeTemplate to MachineClass after reading from Worker resource (#…
Browse files Browse the repository at this point in the history
…359)

* template updated

* vendored mcm v0.43.1

* pass nodeTemplate to machineClass

* more vendoring

* gomod changes

* vendor mcm 0.44.1
  • Loading branch information
himanshu-kun authored Apr 22, 2022
1 parent 4666bc3 commit d6d0231
Show file tree
Hide file tree
Showing 68 changed files with 1,903 additions and 257 deletions.
8 changes: 8 additions & 0 deletions charts/internal/machineclass/templates/machineclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ metadata:
{{ toYaml $machineClass.labels | indent 4 }}
{{- end }}
provider: "OpenStack"
{{- if $machineClass.nodeTemplate }}
nodeTemplate:
capacity:
{{ toYaml $machineClass.nodeTemplate.capacity | indent 4 }}
instanceType: {{ $machineClass.nodeTemplate.instanceType }}
region: {{ $machineClass.nodeTemplate.region }}
zone: {{ $machineClass.nodeTemplate.zone }}
{{- end }}
secretRef:
name: {{ $machineClass.name }}
namespace: {{ $.Release.Namespace }}
Expand Down
8 changes: 8 additions & 0 deletions charts/internal/machineclass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ machineClasses:
region: europe-1
availabilityZone: europe-1a
machineType: medium_2_4
nodeTemplate:
capacity:
cpu: 2
gpu: 1
memory: 25Gi
instanceType: medium_2_4
region: europe-1
zone: europe-1a
keyName: my-ssh-key
imageName: coreos-v1.0
#imageID: 836428cd-5f98-1305-af9d-9825d4dfd0ec
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/coreos/go-systemd/v22 v22.3.2
github.com/gardener/etcd-druid v0.8.0
github.com/gardener/gardener v1.44.0
github.com/gardener/machine-controller-manager v0.41.0
github.com/gardener/machine-controller-manager v0.44.1
github.com/go-logr/logr v1.2.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.1.2
Expand Down
17 changes: 12 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down Expand Up @@ -271,8 +272,9 @@ github.com/gardener/hvpa-controller/api v0.4.0/go.mod h1:QQl3ELkCaki+8RhXl0FZMfv
github.com/gardener/landscaper/apis v0.7.0/go.mod h1:++MW27PlSnbWM4AJipikw62RSprxO5TKVxZ8nh0e4Yw=
github.com/gardener/machine-controller-manager v0.27.0/go.mod h1:zlIxuLQMtRO+aXOFsG6qtYkBmggbWY82K7MSO051ARU=
github.com/gardener/machine-controller-manager v0.33.0/go.mod h1:jxxE+mGgXwg4iPlCHTG4GtUfK2CcHA6yYoIIowoxOZU=
github.com/gardener/machine-controller-manager v0.41.0 h1:X8MrCqnGnRnn8GwDU3ajeRbu50yFUplcac++isqCFY4=
github.com/gardener/machine-controller-manager v0.41.0/go.mod h1:43OABkCemMS6b35z3OprbfaT3p2HxKAZkJekjCO2T48=
github.com/gardener/machine-controller-manager v0.44.1 h1:qTb4KhWZvI8Lz5aKdOFolqL8BzIlmJsIFrBB63njMLI=
github.com/gardener/machine-controller-manager v0.44.1/go.mod h1:X3MKnVQ83ov7e8Ct0TxL+3PiTodGTc41klr6MbEuxxY=
github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
Expand Down Expand Up @@ -572,6 +574,7 @@ github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPK
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mandelsoft/filepath v0.0.0-20200909114706-3df73d378d55/go.mod h1:n4xEiUD2HNHnn2w5ZKF0qgjDecHVCWAl5DxZ7+pcFU8=
Expand Down Expand Up @@ -707,13 +710,15 @@ github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.28.0 h1:vGVfV9KrDTvWt5boZO0I19g2E3CsWfpPPKZM9dt3mEw=
github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
Expand Down Expand Up @@ -1103,8 +1108,9 @@ golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211015200801-69063c4bb744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down Expand Up @@ -1516,6 +1522,7 @@ sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:w
sigs.k8s.io/structured-merge-diff/v2 v2.0.1/go.mod h1:Wb7vfKAodbKgf6tn1Kl0VvGj7mRH6DGaRcixXEJXTsE=
sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
sigs.k8s.io/structured-merge-diff/v4 v4.0.3/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/structured-merge-diff/v4 v4.2.0/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y=
Expand Down
9 changes: 9 additions & 0 deletions pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error {
machineClassSpec["serverGroupID"] = serverGroupDep.ID
}

if pool.NodeTemplate != nil {
machineClassSpec["nodeTemplate"] = machinev1alpha1.NodeTemplate{
Capacity: pool.NodeTemplate.Capacity,
InstanceType: pool.MachineType,
Region: w.worker.Spec.Region,
Zone: zone,
}
}

var (
deploymentName = fmt.Sprintf("%s-%s-z%d", w.worker.Namespace, pool.Name, zoneIndex+1)
className = fmt.Sprintf("%s-%s", deploymentName, workerPoolHash)
Expand Down
56 changes: 56 additions & 0 deletions pkg/controller/worker/machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand Down Expand Up @@ -121,6 +122,9 @@ var _ = Describe("Machines", func() {
zone1 string
zone2 string

nodeCapacity corev1.ResourceList
nodeTemplateZone1 machinev1alpha1.NodeTemplate
nodeTemplateZone2 machinev1alpha1.NodeTemplate
machineConfiguration *machinev1alpha1.MachineConfiguration

workerPoolHash1 string
Expand Down Expand Up @@ -174,6 +178,25 @@ var _ = Describe("Machines", func() {
zone1 = region + "a"
zone2 = region + "b"

nodeCapacity = corev1.ResourceList{
"cpu": resource.MustParse("8"),
"gpu": resource.MustParse("1"),
"memory": resource.MustParse("128Gi"),
}
nodeTemplateZone1 = machinev1alpha1.NodeTemplate{
Capacity: nodeCapacity,
InstanceType: machineType,
Region: region,
Zone: zone1,
}

nodeTemplateZone2 = machinev1alpha1.NodeTemplate{
Capacity: nodeCapacity,
InstanceType: machineType,
Region: region,
Zone: zone2,
}

machineConfiguration = &machinev1alpha1.MachineConfiguration{}

shootVersionMajorMinor = "1.2"
Expand Down Expand Up @@ -287,6 +310,9 @@ var _ = Describe("Machines", func() {
Name: machineImageName,
Version: machineImageVersion,
},
NodeTemplate: &extensionsv1alpha1.NodeTemplate{
Capacity: nodeCapacity,
},
UserData: userData,
Zones: []string{
zone1,
Expand All @@ -304,6 +330,9 @@ var _ = Describe("Machines", func() {
Name: machineImageName,
Version: machineImageVersion,
},
NodeTemplate: &extensionsv1alpha1.NodeTemplate{
Capacity: nodeCapacity,
},
UserData: userData,
Zones: []string{
zone1,
Expand Down Expand Up @@ -367,6 +396,20 @@ var _ = Describe("Machines", func() {
defaultMachineClass["imageID"] = imageID
}

newNodeTemplateZone1 := machinev1alpha1.NodeTemplate{
Capacity: nodeCapacity,
InstanceType: machineType,
Region: region,
Zone: zone1,
}

newNodeTemplateZone2 := machinev1alpha1.NodeTemplate{
Capacity: nodeCapacity,
InstanceType: machineType,
Region: region,
Zone: zone2,
}

var (
machineClassPool1Zone1 = useDefaultMachineClass(defaultMachineClass, "availabilityZone", zone1)
machineClassPool1Zone2 = useDefaultMachineClass(defaultMachineClass, "availabilityZone", zone2)
Expand All @@ -389,6 +432,11 @@ var _ = Describe("Machines", func() {
addNameAndSecretToMachineClass(machineClassPool2Zone1, machineClassWithHashPool2Zone1, w.Spec.SecretRef)
addNameAndSecretToMachineClass(machineClassPool2Zone2, machineClassWithHashPool2Zone2, w.Spec.SecretRef)

addNodeTemplateToMachineClass(machineClassPool1Zone1, newNodeTemplateZone1)
addNodeTemplateToMachineClass(machineClassPool1Zone2, newNodeTemplateZone2)
addNodeTemplateToMachineClass(machineClassPool2Zone1, newNodeTemplateZone1)
addNodeTemplateToMachineClass(machineClassPool2Zone2, newNodeTemplateZone2)

machineClasses = map[string]interface{}{"machineClasses": []map[string]interface{}{
machineClassPool1Zone1,
machineClassPool1Zone2,
Expand Down Expand Up @@ -637,6 +685,10 @@ var _ = Describe("Machines", func() {
addNameAndSecretToMachineClass(machineClassPool1Zone2, machineClassWithHashPool1Zone2, w.Spec.SecretRef)
addNameAndSecretToMachineClass(machineClassPool2Zone1, machineClassWithHashPool2Zone1, w.Spec.SecretRef)
addNameAndSecretToMachineClass(machineClassPool2Zone2, machineClassWithHashPool2Zone2, w.Spec.SecretRef)
addNodeTemplateToMachineClass(machineClassPool1Zone1, nodeTemplateZone1)
addNodeTemplateToMachineClass(machineClassPool1Zone2, nodeTemplateZone2)
addNodeTemplateToMachineClass(machineClassPool2Zone1, nodeTemplateZone1)
addNodeTemplateToMachineClass(machineClassPool2Zone2, nodeTemplateZone2)
machineClasses := map[string]interface{}{"machineClasses": []map[string]interface{}{
machineClassPool1Zone1,
machineClassPool1Zone2,
Expand Down Expand Up @@ -785,6 +837,10 @@ func useDefaultMachineClassWith(def map[string]interface{}, add map[string]inter
return out
}

func addNodeTemplateToMachineClass(class map[string]interface{}, nodeTemplate machinev1alpha1.NodeTemplate) {
class["nodeTemplate"] = nodeTemplate
}

func addNameAndSecretToMachineClass(class map[string]interface{}, name string, credentialsSecretRef corev1.SecretReference) {
class["name"] = name
class["labels"] = map[string]string{
Expand Down
8 changes: 0 additions & 8 deletions vendor/github.com/cespare/xxhash/v2/.travis.yml

This file was deleted.

6 changes: 4 additions & 2 deletions vendor/github.com/cespare/xxhash/v2/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vendor/github.com/cespare/xxhash/v2/xxhash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d6d0231

Please sign in to comment.