mirror of https://github.com/k3s-io/k3s
Get public IP for Azure vmss nodes
This is required for getting public IP when --public-ip-per-vm (publicIpAddressConfiguration) is enabled for vmss.pull/58/head
parent
6b1af84d4a
commit
303af63ec9
|
@ -291,8 +291,6 @@ func (ss *scaleSet) GetPrimaryVMSetName() string {
|
|||
}
|
||||
|
||||
// GetIPByNodeName gets machine private IP and public IP by node name.
|
||||
// TODO(feiskyer): Azure vmss doesn't support associating a public IP to single virtual machine yet,
|
||||
// fix this after it is supported.
|
||||
func (ss *scaleSet) GetIPByNodeName(nodeName string) (string, string, error) {
|
||||
nic, err := ss.GetPrimaryInterface(nodeName)
|
||||
if err != nil {
|
||||
|
@ -306,8 +304,30 @@ func (ss *scaleSet) GetIPByNodeName(nodeName string) (string, string, error) {
|
|||
return "", "", err
|
||||
}
|
||||
|
||||
targetIP := *ipConfig.PrivateIPAddress
|
||||
return targetIP, "", nil
|
||||
internalIP := *ipConfig.PrivateIPAddress
|
||||
publicIP := ""
|
||||
if ipConfig.PublicIPAddress != nil && ipConfig.PublicIPAddress.ID != nil {
|
||||
pipID := *ipConfig.PublicIPAddress.ID
|
||||
pipName, err := getLastSegment(pipID)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to get publicIP name for node %q with pipID %q", nodeName, pipID)
|
||||
}
|
||||
|
||||
resourceGroup, err := ss.GetNodeResourceGroup(nodeName)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
pip, existsPip, err := ss.getPublicIPAddress(resourceGroup, pipName)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
if existsPip {
|
||||
publicIP = *pip.IPAddress
|
||||
}
|
||||
}
|
||||
|
||||
return internalIP, publicIP, nil
|
||||
}
|
||||
|
||||
// This returns the full identifier of the primary NIC for the given VM.
|
||||
|
|
Loading…
Reference in New Issue