Skip to content

Commit

Permalink
Add Azure managed disk support
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx authored and karataliu committed Jul 14, 2017
1 parent 74f1943 commit 677e593
Show file tree
Hide file tree
Showing 30 changed files with 4,274 additions and 1,172 deletions.
5 changes: 5 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

210 changes: 210 additions & 0 deletions Godeps/LICENSES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions hack/verify-flags/excluded-flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ valid_flag
retry_time
file_content_in_loop
break_on_expected_content
Premium_LRS
6 changes: 4 additions & 2 deletions pkg/cloudprovider/providers/azure/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ go_library(
srcs = [
"azure.go",
"azure_backoff.go",
"azure_blob.go",
"azure_blobDiskController.go",
"azure_controllerCommon.go",
"azure_file.go",
"azure_instance_metadata.go",
"azure_instances.go",
"azure_loadbalancer.go",
"azure_managedDiskController.go",
"azure_routes.go",
"azure_storage.go",
"azure_storageaccount.go",
"azure_util.go",
"azure_wrap.go",
"azure_zones.go",
"vhd.go",
],
tags = ["automanaged"],
deps = [
Expand All @@ -34,6 +35,7 @@ go_library(
"//pkg/version:go_default_library",
"//pkg/volume:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/disk:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/network:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/storage:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/storage:go_default_library",
Expand Down
53 changes: 53 additions & 0 deletions pkg/cloudprovider/providers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/version"

"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/disk"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/storage"
"github.com/Azure/go-autorest/autorest"
Expand Down Expand Up @@ -122,8 +123,13 @@ type Cloud struct {
SecurityGroupsClient network.SecurityGroupsClient
VirtualMachinesClient compute.VirtualMachinesClient
StorageAccountClient storage.AccountsClient
DisksClient disk.DisksClient
operationPollRateLimiter flowcontrol.RateLimiter
resourceRequestBackoff wait.Backoff

*BlobDiskController
*ManagedDiskController
*controllerCommon
}

func init() {
Expand Down Expand Up @@ -255,6 +261,11 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {

az.StorageAccountClient = storage.NewAccountsClientWithBaseURI(az.Environment.ResourceManagerEndpoint, az.SubscriptionID)
az.StorageAccountClient.Authorizer = autorest.NewBearerAuthorizer(servicePrincipalToken)
configureUserAgent(&az.StorageAccountClient.Client)

az.DisksClient = disk.NewDisksClientWithBaseURI(az.Environment.ResourceManagerEndpoint, az.SubscriptionID)
az.DisksClient.Authorizer = autorest.NewBearerAuthorizer(servicePrincipalToken)
configureUserAgent(&az.DisksClient.Client)

// Conditionally configure rate limits
if az.CloudProviderRateLimit {
Expand Down Expand Up @@ -304,6 +315,9 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {
az.CloudProviderBackoffJitter)
}

if err := initDiskControllers(&az); err != nil {
return nil, err
}
return &az, nil
}

Expand Down Expand Up @@ -353,3 +367,42 @@ func configureUserAgent(client *autorest.Client) {
k8sVersion := version.Get().GitVersion
client.UserAgent = fmt.Sprintf("%s; kubernetes-cloudprovider/%s", client.UserAgent, k8sVersion)
}

func initDiskControllers(az *Cloud) error {
// Common controller contains the function
// needed by both blob disk and managed disk controllers

common := &controllerCommon{
aadResourceEndPoint: az.Environment.ServiceManagementEndpoint,
clientID: az.AADClientID,
clientSecret: az.AADClientSecret,
location: az.Location,
storageEndpointSuffix: az.Environment.StorageEndpointSuffix,
managementEndpoint: az.Environment.ResourceManagerEndpoint,
resourceGroup: az.ResourceGroup,
tenantID: az.TenantID,
tokenEndPoint: az.Environment.ActiveDirectoryEndpoint,
subscriptionID: az.SubscriptionID,
cloud: az,
}

// BlobDiskController: contains the function needed to
// create/attach/detach/delete blob based (unmanaged disks)
blobController, err := newBlobDiskController(common)
if err != nil {
return fmt.Errorf("AzureDisk - failed to init Blob Disk Controller with error (%s)", err.Error())
}

// ManagedDiskController: contains the functions needed to
// create/attach/detach/delete managed disks
managedController, err := newManagedDiskController(common)
if err != nil {
return fmt.Errorf("AzureDisk - failed to init Managed Disk Controller with error (%s)", err.Error())
}

az.BlobDiskController = blobController
az.ManagedDiskController = managedController
az.controllerCommon = common

return nil
}
Loading

0 comments on commit 677e593

Please sign in to comment.