• Kubernetes Submit Queue's avatar
    Merge pull request #67121 from feiskyer/azdisk-affinity · ae351f11
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue (batch tested with PRs 67061, 66589, 67121, 67149). 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 and VolumeScheduling support for Azure managed disks
    
    **What this PR does / why we need it**:
    
    Continue of [Azure Availability Zone feature](https://github.com/kubernetes/features/issues/586).
    
    This PR adds `VolumeScheduling` and `DynamicProvisioningScheduling` support to Azure managed disks.
    
    When feature gate `VolumeScheduling` disabled, no NodeAffinity set for PV:
    
    ```yaml
    kubectl describe pv
    Name:              pvc-d30dad05-9ad8-11e8-94f2-000d3a07de8c
    Labels:            failure-domain.beta.kubernetes.io/region=southeastasia
                       failure-domain.beta.kubernetes.io/zone=southeastasia-2
    Annotations:       pv.kubernetes.io/bound-by-controller=yes
                       pv.kubernetes.io/provisioned-by=kubernetes.io/azure-disk
                       volumehelper.VolumeDynamicallyCreatedByKey=azure-disk-dynamic-provisioner
    Finalizers:        [kubernetes.io/pv-protection]
    StorageClass:      default
    Status:            Bound
    Claim:             default/pvc-azuredisk
    Reclaim Policy:    Delete
    Access Modes:      RWO
    Capacity:          5Gi
    Node Affinity:
      Required Terms:
        Term 0:        failure-domain.beta.kubernetes.io/region in [southeastasia]
                       failure-domain.beta.kubernetes.io/zone in [southeastasia-2]
    Message:
    Source:
        Type:         AzureDisk (an Azure Data Disk mount on the host and bind mount to the pod)
        DiskName:     k8s-5b3d7b8f-dynamic-pvc-d30dad05-9ad8-11e8-94f2-000d3a07de8c
        DiskURI:      /subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.Compute/disks/k8s-5b3d7b8f-dynamic-pvc-d30dad05-9ad8-11e8-94f2-000d3a07de8c
        Kind:         Managed
        FSType:
        CachingMode:  None
        ReadOnly:     false
    Events:           <none>
    ```
    
    When feature gate `VolumeScheduling` enabled, NodeAffinity will be populated for PV:
    
    ```yaml
    kubectl describe pv
    Name:              pvc-0284337b-9ada-11e8-a7f6-000d3a07de8c
    Labels:            failure-domain.beta.kubernetes.io/region=southeastasia
                       failure-domain.beta.kubernetes.io/zone=southeastasia-2
    Annotations:       pv.kubernetes.io/bound-by-controller=yes
                       pv.kubernetes.io/provisioned-by=kubernetes.io/azure-disk
                       volumehelper.VolumeDynamicallyCreatedByKey=azure-disk-dynamic-provisioner
    Finalizers:        [kubernetes.io/pv-protection]
    StorageClass:      default
    Status:            Bound
    Claim:             default/pvc-azuredisk
    Reclaim Policy:    Delete
    Access Modes:      RWO
    Capacity:          5Gi
    Node Affinity:
      Required Terms:
        Term 0:        failure-domain.beta.kubernetes.io/region in [southeastasia]
                       failure-domain.beta.kubernetes.io/zone in [southeastasia-2]
    Message:
    Source:
        Type:         AzureDisk (an Azure Data Disk mount on the host and bind mount to the pod)
        DiskName:     k8s-5b3d7b8f-dynamic-pvc-0284337b-9ada-11e8-a7f6-000d3a07de8c
        DiskURI:      /subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.Compute/disks/k8s-5b3d7b8f-dynamic-pvc-0284337b-9ada-11e8-a7f6-000d3a07de8c
        Kind:         Managed
        FSType:
        CachingMode:  None
        ReadOnly:     false
    Events:           <none>
    ```
    
    When both  `VolumeScheduling` and `DynamicProvisioningScheduling` are enabled, storage class also supports `allowedTopologies` and `volumeBindingMode: WaitForFirstConsumer` for volume topology aware dynamic provisioning:
    
    ```yaml
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      annotations:
      name: managed-disk-dynamic
    parameters:
      cachingmode: None
      kind: Managed
      storageaccounttype: Standard_LRS
    provisioner: kubernetes.io/azure-disk
    reclaimPolicy: Delete
    volumeBindingMode: WaitForFirstConsumer
    allowedTopologies:
    - matchLabelExpressions:
      - key: failure-domain.beta.kubernetes.io/zone
        values:
        - southeastasia-2
        - southeastasia-1
    ```
    
    **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**:
    
    **Release note**:
    
    ```release-note
    DynamicProvisioningScheduling and VolumeScheduling is not supported for Azure managed disks. Feature gates DynamicProvisioningScheduling and VolumeScheduling should be enabled before using this feature.
    ```
    
    /kind feature
    /sig azure
    /cc @brendandburns @khenidak @andyzhangx
    /cc @ddebroy @msau42 @justaugustus
    ae351f11
Name
Last commit
Last update
.github Loading commit data...
Godeps Loading commit data...
api Loading commit data...
build Loading commit data...
cluster Loading commit data...
cmd Loading commit data...
docs Loading commit data...
hack Loading commit data...
logo Loading commit data...
pkg Loading commit data...
plugin Loading commit data...
staging Loading commit data...
test Loading commit data...
third_party Loading commit data...
translations Loading commit data...
vendor Loading commit data...
.bazelrc Loading commit data...
.generated_files Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.kazelcfg.json Loading commit data...
BUILD.bazel Loading commit data...
CHANGELOG-1.10.md Loading commit data...
CHANGELOG-1.11.md Loading commit data...
CHANGELOG-1.12.md Loading commit data...
CHANGELOG-1.2.md Loading commit data...
CHANGELOG-1.3.md Loading commit data...
CHANGELOG-1.4.md Loading commit data...
CHANGELOG-1.5.md Loading commit data...
CHANGELOG-1.6.md Loading commit data...
CHANGELOG-1.7.md Loading commit data...
CHANGELOG-1.8.md Loading commit data...
CHANGELOG-1.9.md Loading commit data...
CHANGELOG.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
Makefile.generated_files Loading commit data...
OWNERS Loading commit data...
OWNERS_ALIASES Loading commit data...
README.md Loading commit data...
SECURITY_CONTACTS Loading commit data...
SUPPORT.md Loading commit data...
WORKSPACE Loading commit data...
code-of-conduct.md Loading commit data...