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
35 changes: 24 additions & 11 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,19 +173,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),
// 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
Labels: func() map[string]string {
if !csiEnabled {
return pool.Labels
}
return utils.MergeStringMaps(pool.Labels, map[string]string{awsCSIDriverTopologyKey: zone})
himanshu-kun marked this conversation as resolved.
Show resolved Hide resolved
}(),
Annotations: pool.Annotations,
Taints: pool.Taints,
MachineConfiguration: genericworkeractuator.ReadMachineConfiguration(pool),
Expand Down