Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting CSI AWS topology label on machine deployment creation to allow scale-up #365

Merged
merged 7 commits into from
Jun 28, 2021
18 changes: 14 additions & 4 deletions pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
awsapi "github.com/gardener/gardener-extension-provider-aws/pkg/apis/aws"
awsapihelper "github.com/gardener/gardener-extension-provider-aws/pkg/apis/aws/helper"
"github.com/gardener/gardener-extension-provider-aws/pkg/aws"

"github.com/gardener/gardener/extensions/pkg/controller/csimigration"
himanshu-kun marked this conversation as resolved.
Show resolved Hide resolved
"github.com/gardener/gardener/extensions/pkg/controller/worker"
genericworkeractuator "github.com/gardener/gardener/extensions/pkg/controller/worker/genericactuator"
v1beta1constants "github.com/gardener/gardener/pkg/apis/core/v1beta1/constants"
Expand Down Expand Up @@ -95,6 +95,11 @@ func (w *workerDelegate) generateMachineConfig() error {
return err
}

csiEnabled, _, err := csimigration.CheckCSIConditions(w.cluster, aws.GetCSIMigrationKubernetesVersion(w.cluster))
if err != nil {
return err
}

for _, pool := range w.worker.Spec.Pools {
zoneLen := int32(len(pool.Zones))

Expand Down Expand Up @@ -168,8 +173,9 @@ func (w *workerDelegate) generateMachineConfig() error {
}

var (
deploymentName = fmt.Sprintf("%s-%s-z%d", w.worker.Namespace, pool.Name, zoneIndex+1)
className = fmt.Sprintf("%s-%s", deploymentName, workerPoolHash)
deploymentName = fmt.Sprintf("%s-%s-z%d", w.worker.Namespace, pool.Name, zoneIndex+1)
className = fmt.Sprintf("%s-%s", deploymentName, workerPoolHash)
awsCSIDriverTopologyKey = "topology.ebs.csi.aws.com/zone"
)

machineDeployments = append(machineDeployments, worker.MachineDeployment{
Expand All @@ -185,7 +191,11 @@ func (w *workerDelegate) generateMachineConfig() error {
Taints: pool.Taints,
MachineConfiguration: genericworkeractuator.ReadMachineConfiguration(pool),
})

// TODO: remove when AWS CSI driver stops using the aws csi topology key - https://github.com/kubernetes-sigs/aws-ebs-csi-driver/issues/899
// add aws csi driver topology label if its not specified
if csiEnabled {
machineDeployments[len(machineDeployments)-1].Labels = utils.MergeStringMaps(pool.Labels, map[string]string{awsCSIDriverTopologyKey: zone})
himanshu-kun marked this conversation as resolved.
Show resolved Hide resolved
}
machineClassSpec["name"] = className
machineClassSpec["labels"] = map[string]string{corev1.LabelZoneFailureDomain: zone}
machineClassSpec["secret"].(map[string]interface{})["labels"] = map[string]string{v1beta1constants.GardenerPurpose: genericworkeractuator.GardenPurposeMachineClass}
Expand Down