mirror of https://github.com/kubernetes/kops.git
azure: Fix instance deletion
This commit is contained in:
parent
87a0483ca3
commit
afbafff75d
|
@ -64,6 +64,7 @@ type AzureCloud interface {
|
||||||
|
|
||||||
type azureCloudImplementation struct {
|
type azureCloudImplementation struct {
|
||||||
subscriptionID string
|
subscriptionID string
|
||||||
|
resourceGroupName string
|
||||||
location string
|
location string
|
||||||
tags map[string]string
|
tags map[string]string
|
||||||
resourceGroupsClient ResourceGroupsClient
|
resourceGroupsClient ResourceGroupsClient
|
||||||
|
@ -85,7 +86,7 @@ type azureCloudImplementation struct {
|
||||||
var _ fi.Cloud = &azureCloudImplementation{}
|
var _ fi.Cloud = &azureCloudImplementation{}
|
||||||
|
|
||||||
// NewAzureCloud creates a new AzureCloud.
|
// NewAzureCloud creates a new AzureCloud.
|
||||||
func NewAzureCloud(subscriptionID, location string, tags map[string]string) (AzureCloud, error) {
|
func NewAzureCloud(subscriptionID, resourceGroupName, location string, tags map[string]string) (AzureCloud, error) {
|
||||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error creating an identity: %s", err)
|
return nil, fmt.Errorf("error creating an identity: %s", err)
|
||||||
|
@ -93,6 +94,7 @@ func NewAzureCloud(subscriptionID, location string, tags map[string]string) (Azu
|
||||||
|
|
||||||
azureCloudImpl := &azureCloudImplementation{
|
azureCloudImpl := &azureCloudImplementation{
|
||||||
subscriptionID: subscriptionID,
|
subscriptionID: subscriptionID,
|
||||||
|
resourceGroupName: resourceGroupName,
|
||||||
location: location,
|
location: location,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
}
|
}
|
||||||
|
@ -195,7 +197,7 @@ func (c *azureCloudImplementation) FindVNetInfo(id, resourceGroup string) (*fi.V
|
||||||
func (c *azureCloudImplementation) DeleteInstance(i *cloudinstances.CloudInstance) error {
|
func (c *azureCloudImplementation) DeleteInstance(i *cloudinstances.CloudInstance) error {
|
||||||
vmssName := i.CloudInstanceGroup.HumanName
|
vmssName := i.CloudInstanceGroup.HumanName
|
||||||
instanceID := strings.TrimPrefix(i.ID, vmssName+"_")
|
instanceID := strings.TrimPrefix(i.ID, vmssName+"_")
|
||||||
return c.vmscaleSetVMsClient.Delete(context.TODO(), "my.k8s", vmssName, instanceID)
|
return c.vmscaleSetVMsClient.Delete(context.TODO(), c.resourceGroupName, vmssName, instanceID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeregisterInstance drains a cloud instance and loadbalancers.
|
// DeregisterInstance drains a cloud instance and loadbalancers.
|
||||||
|
|
|
@ -157,7 +157,9 @@ func BuildCloud(cluster *kops.Cluster) (fi.Cloud, error) {
|
||||||
|
|
||||||
cloudTags := map[string]string{azure.TagClusterName: cluster.ObjectMeta.Name}
|
cloudTags := map[string]string{azure.TagClusterName: cluster.ObjectMeta.Name}
|
||||||
|
|
||||||
azureCloud, err := azure.NewAzureCloud(cluster.Spec.CloudProvider.Azure.SubscriptionID, region, cloudTags)
|
subscriptionID := cluster.Spec.CloudProvider.Azure.SubscriptionID
|
||||||
|
resourceGroupName := cluster.Spec.CloudProvider.Azure.ResourceGroupName
|
||||||
|
azureCloud, err := azure.NewAzureCloud(subscriptionID, resourceGroupName, region, cloudTags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue