mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
vagrant: report the nodes external id
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This commit is contained in:
parent
bfb93a1928
commit
b942b1cb71
@ -99,8 +99,8 @@ func (v *VagrantCloud) Zones() (cloudprovider.Zones, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// IPAddress returns the address of a particular machine instance.
|
||||
func (v *VagrantCloud) IPAddress(instance string) (net.IP, error) {
|
||||
// getInstanceByAddress retuns
|
||||
func (v *VagrantCloud) getInstanceByAddress(address string) (*SaltMinion, error) {
|
||||
token, err := v.saltLogin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -112,16 +112,31 @@ func (v *VagrantCloud) IPAddress(instance string) (net.IP, error) {
|
||||
filteredMinions := v.saltMinionsByRole(minions, "kubernetes-pool")
|
||||
for _, minion := range filteredMinions {
|
||||
// Due to vagrant not running with a dedicated DNS setup, we return the IP address of a minion as its hostname at this time
|
||||
if minion.IP == instance {
|
||||
return net.ParseIP(minion.IP), nil
|
||||
if minion.IP == address {
|
||||
return &minion, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("unable to find IP address for instance: %s", instance)
|
||||
return nil, fmt.Errorf("unable to find instance for address: %s", address)
|
||||
}
|
||||
|
||||
// IPAddress returns the address of a particular machine instance.
|
||||
func (v *VagrantCloud) IPAddress(instance string) (net.IP, error) {
|
||||
// Due to vagrant not running with a dedicated DNS setup, we return the IP address of a minion as its hostname at this time
|
||||
minion, err := v.getInstanceByAddress(instance)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return net.ParseIP(minion.IP), nil
|
||||
}
|
||||
|
||||
// ExternalID returns the cloud provider ID of the specified instance.
|
||||
func (v *VagrantCloud) ExternalID(instance string) (string, error) {
|
||||
return "", fmt.Errorf("unimplemented")
|
||||
// Due to vagrant not running with a dedicated DNS setup, we return the IP address of a minion as its hostname at this time
|
||||
minion, err := v.getInstanceByAddress(instance)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return minion.IP, nil
|
||||
}
|
||||
|
||||
// saltMinionsByRole filters a list of minions that have a matching role.
|
||||
|
Loading…
Reference in New Issue
Block a user