Merge pull request #62611 from feiskyer/vmss-standard

Automatic merge from submit-queue. 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>.

Fix machineID getting for vmss nodes when using instance metadata

**What this PR does / why we need it**:

When instancemetadata is for Kubelet on master nodes , kubelet is not able to register itself with errors:

```sh
Unable to construct v1.Node object for kubelet: failed to get external ID from cloud provider: not a vmss instance
```

This PR fixes this issue by composing standard instance ID for such nodes.

**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 #62610

**Special notes for your reviewer**:

Need cherry pick to 1.10.

**Release note**:

```release-note
Fix machineID getting for vmss nodes when using instance metadata
```

/assign @andyzhangx
pull/8/head
Kubernetes Submit Queue 2018-04-16 05:56:03 -07:00 committed by GitHub
commit 5e50a0fb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -162,6 +162,10 @@ func (az *Cloud) InstanceID(ctx context.Context, name types.NodeName) (string, e
}
ssName, instanceID, err := extractVmssVMName(metadataName)
if err != nil {
if err == ErrorNotVmssInstance {
// Compose machineID for standard Node.
return az.getStandardMachineID(nodeName), nil
}
return "", err
}
// Compose instanceID based on ssName and instanceID for vmss instance.