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
34 changes: 24 additions & 10 deletions pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
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 +96,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,19 +174,27 @@ 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{
Name: deploymentName,
ClassName: className,
SecretName: className,
Minimum: worker.DistributeOverZones(zoneIdx, pool.Minimum, zoneLen),
Maximum: worker.DistributeOverZones(zoneIdx, pool.Maximum, zoneLen),
MaxSurge: worker.DistributePositiveIntOrPercent(zoneIdx, pool.MaxSurge, zoneLen, pool.Maximum),
MaxUnavailable: worker.DistributePositiveIntOrPercent(zoneIdx, pool.MaxUnavailable, zoneLen, pool.Minimum),
Labels: pool.Labels,
Name: deploymentName,
ClassName: className,
SecretName: className,
Minimum: worker.DistributeOverZones(zoneIdx, pool.Minimum, zoneLen),
Maximum: worker.DistributeOverZones(zoneIdx, pool.Maximum, zoneLen),
MaxSurge: worker.DistributePositiveIntOrPercent(zoneIdx, pool.MaxSurge, zoneLen, pool.Maximum),
MaxUnavailable: worker.DistributePositiveIntOrPercent(zoneIdx, pool.MaxUnavailable, zoneLen, pool.Minimum),
Labels: func() map[string]string {
if !csiEnabled {
return pool.Labels
}
// TODO: remove the csi topology label 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
return utils.MergeStringMaps(pool.Labels, map[string]string{awsCSIDriverTopologyKey: zone})
}(),
Annotations: pool.Annotations,
Taints: pool.Taints,
MachineConfiguration: genericworkeractuator.ReadMachineConfiguration(pool),
Expand Down