mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-15 20:37:39 +00:00
Merge pull request #65730 from ddebroy/ebs-affinity1
Automatic merge from submit-queue (batch tested with PRs 65730, 66615, 66684, 66519, 66510). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add DynamicProvisioningScheduling support for EBS **What this PR does / why we need it**: This PR adds support for the DynamicProvisioningScheduling feature in EBS. With this in place, if VolumeBindingMode: WaitForFirstConsumer is specified in a EBS storageclass and DynamicProvisioningScheduling is enabled, EBS provisioner will use the selected node's LabelZoneFailureDomain as the zone to provision the EBS volume in. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: Related to #63232 Sample `describe pv` output with NodeAffinity populated: ``` ~$ kubectl describe pv pvc-f9d2138b-7e3e-11e8-a4ea-064124617820 Name: pvc-f9d2138b-7e3e-11e8-a4ea-064124617820 Labels: failure-domain.beta.kubernetes.io/region=us-west-2 failure-domain.beta.kubernetes.io/zone=us-west-2a Annotations: kubernetes.io/createdby=aws-ebs-dynamic-provisioner pv.kubernetes.io/bound-by-controller=yes pv.kubernetes.io/provisioned-by=kubernetes.io/aws-ebs Finalizers: [kubernetes.io/pv-protection] StorageClass: slow3 Status: Bound Claim: default/pvc3 Reclaim Policy: Delete Access Modes: RWO Capacity: 6Gi Node Affinity: Required Terms: Term 0: failure-domain.beta.kubernetes.io/zone in [us-west-2a] failure-domain.beta.kubernetes.io/region in [us-west-2] Message: Source: Type: AWSElasticBlockStore (a Persistent Disk resource in AWS) VolumeID: aws://us-west-2a/vol-0fc1cdae7d10860f6 FSType: ext4 Partition: 0 ReadOnly: false Events: <none> ``` **Release note**: ```release-note none ``` /sig storage /assign @msau42 @jsafrane
This commit is contained in:
@@ -413,14 +413,10 @@ const (
|
||||
|
||||
// VolumeOptions specifies capacity and tags for a volume.
|
||||
type VolumeOptions struct {
|
||||
CapacityGB int
|
||||
Tags map[string]string
|
||||
PVCName string
|
||||
VolumeType string
|
||||
ZonePresent bool
|
||||
ZonesPresent bool
|
||||
AvailabilityZone string
|
||||
AvailabilityZones string
|
||||
CapacityGB int
|
||||
Tags map[string]string
|
||||
VolumeType string
|
||||
AvailabilityZone string
|
||||
// IOPSPerGB x CapacityGB will give total IOPS of the volume to create.
|
||||
// Calculated total IOPS will be capped at MaxTotalIOPS.
|
||||
IOPSPerGB int
|
||||
@@ -1431,9 +1427,9 @@ func (c *Cloud) InstanceType(ctx context.Context, nodeName types.NodeName) (stri
|
||||
return aws.StringValue(inst.InstanceType), nil
|
||||
}
|
||||
|
||||
// getCandidateZonesForDynamicVolume retrieves a list of all the zones in which nodes are running
|
||||
// GetCandidateZonesForDynamicVolume retrieves a list of all the zones in which nodes are running
|
||||
// It currently involves querying all instances
|
||||
func (c *Cloud) getCandidateZonesForDynamicVolume() (sets.String, error) {
|
||||
func (c *Cloud) GetCandidateZonesForDynamicVolume() (sets.String, error) {
|
||||
// We don't currently cache this; it is currently used only in volume
|
||||
// creation which is expected to be a comparatively rare occurrence.
|
||||
|
||||
@@ -2159,29 +2155,6 @@ func (c *Cloud) DetachDisk(diskName KubernetesVolumeID, nodeName types.NodeName)
|
||||
|
||||
// CreateDisk implements Volumes.CreateDisk
|
||||
func (c *Cloud) CreateDisk(volumeOptions *VolumeOptions) (KubernetesVolumeID, error) {
|
||||
var createAZ string
|
||||
if !volumeOptions.ZonePresent && !volumeOptions.ZonesPresent {
|
||||
// querry for candidate zones only if zone parameters absent
|
||||
allZones, err := c.getCandidateZonesForDynamicVolume()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error querying for all zones: %v", err)
|
||||
}
|
||||
createAZ = volumeutil.ChooseZoneForVolume(allZones, volumeOptions.PVCName)
|
||||
}
|
||||
if !volumeOptions.ZonePresent && volumeOptions.ZonesPresent {
|
||||
if adminSetOfZones, err := volumeutil.ZonesToSet(volumeOptions.AvailabilityZones); err != nil {
|
||||
return "", err
|
||||
} else {
|
||||
createAZ = volumeutil.ChooseZoneForVolume(adminSetOfZones, volumeOptions.PVCName)
|
||||
}
|
||||
}
|
||||
if volumeOptions.ZonePresent && !volumeOptions.ZonesPresent {
|
||||
if err := volumeutil.ValidateZone(volumeOptions.AvailabilityZone); err != nil {
|
||||
return "", err
|
||||
}
|
||||
createAZ = volumeOptions.AvailabilityZone
|
||||
}
|
||||
|
||||
var createType string
|
||||
var iops int64
|
||||
switch volumeOptions.VolumeType {
|
||||
@@ -2213,7 +2186,7 @@ func (c *Cloud) CreateDisk(volumeOptions *VolumeOptions) (KubernetesVolumeID, er
|
||||
|
||||
// TODO: Should we tag this with the cluster id (so it gets deleted when the cluster does?)
|
||||
request := &ec2.CreateVolumeInput{}
|
||||
request.AvailabilityZone = aws.String(createAZ)
|
||||
request.AvailabilityZone = aws.String(volumeOptions.AvailabilityZone)
|
||||
request.Size = aws.Int64(int64(volumeOptions.CapacityGB))
|
||||
request.VolumeType = aws.String(createType)
|
||||
request.Encrypted = aws.Bool(volumeOptions.Encrypted)
|
||||
|
||||
Reference in New Issue
Block a user