diff --git a/pkg/cloudprovider/providers/azure/azure.go b/pkg/cloudprovider/providers/azure/azure.go index 47826f1bb0..25650e022b 100644 --- a/pkg/cloudprovider/providers/azure/azure.go +++ b/pkg/cloudprovider/providers/azure/azure.go @@ -38,6 +38,7 @@ import ( cloudprovider "k8s.io/cloud-provider" "k8s.io/kubernetes/pkg/cloudprovider/providers/azure/auth" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "k8s.io/klog" @@ -170,6 +171,7 @@ type Cloud struct { VirtualMachinesClient VirtualMachinesClient StorageAccountClient StorageAccountClient DisksClient DisksClient + SnapshotsClient *compute.SnapshotsClient FileClient FileClient resourceRequestBackoff wait.Backoff metadata *InstanceMetadataService @@ -344,6 +346,7 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) { resourceRequestBackoff: resourceRequestBackoff, DisksClient: newAzDisksClient(azClientConfig), + SnapshotsClient: newSnapshotsClient(azClientConfig), RoutesClient: newAzRoutesClient(azClientConfig), SubnetsClient: newAzSubnetsClient(azClientConfig), InterfacesClient: newAzInterfacesClient(azClientConfig), diff --git a/pkg/cloudprovider/providers/azure/azure_client.go b/pkg/cloudprovider/providers/azure/azure_client.go index e7d2a9d6ce..8559c1cd37 100644 --- a/pkg/cloudprovider/providers/azure/azure_client.go +++ b/pkg/cloudprovider/providers/azure/azure_client.go @@ -1385,6 +1385,18 @@ func (az *azDisksClient) Get(ctx context.Context, resourceGroupName string, disk return } +func newSnapshotsClient(config *azClientConfig) *compute.SnapshotsClient { + snapshotsClient := compute.NewSnapshotsClientWithBaseURI(config.resourceManagerEndpoint, config.subscriptionID) + snapshotsClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken) + snapshotsClient.PollingDelay = 5 * time.Second + if config.ShouldOmitCloudProviderBackoff { + snapshotsClient.RetryAttempts = config.CloudProviderBackoffRetries + snapshotsClient.RetryDuration = time.Duration(config.CloudProviderBackoffDuration) * time.Second + } + configureUserAgent(&snapshotsClient.Client) + return &snapshotsClient +} + // azVirtualMachineSizesClient implements VirtualMachineSizesClient. type azVirtualMachineSizesClient struct { client compute.VirtualMachineSizesClient