mirror of https://github.com/kubernetes/kops.git
Kuberenets 1.11 has deprecated ExternalID this replaces it with ProviderID
Per https://github.com/kubernetes/kubernetes/pull/61877 ExternalID is now removed from k8s.
This commit is contained in:
parent
be15242551
commit
4cb92b7c1e
|
@ -18,9 +18,12 @@ package cloudinstances
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
|
"k8s.io/kops/pkg/apis/kops"
|
||||||
|
"k8s.io/kops/pkg/apis/kops/util"
|
||||||
api "k8s.io/kops/pkg/apis/kops"
|
api "k8s.io/kops/pkg/apis/kops"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,11 +86,21 @@ func (c *CloudInstanceGroup) Status() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNodeMap returns a list of nodes keyed by their external id
|
// GetNodeMap returns a list of nodes keyed by their external id
|
||||||
func GetNodeMap(nodes []v1.Node) map[string]*v1.Node {
|
func GetNodeMap(nodes []v1.Node, cluster *kops.Cluster) map[string]*v1.Node {
|
||||||
|
sv, _ := util.ParseKubernetesVersion(cluster.Spec.KubernetesVersion)
|
||||||
|
|
||||||
nodeMap := make(map[string]*v1.Node)
|
nodeMap := make(map[string]*v1.Node)
|
||||||
for i := range nodes {
|
for i := range nodes {
|
||||||
node := &nodes[i]
|
node := &nodes[i]
|
||||||
nodeMap[node.Spec.ExternalID] = node
|
//ExternalID is deprecated in kubernetes 1.11 https://github.com/kubernetes/kubernetes/pull/61877
|
||||||
|
//Mappings from ExternalID https://github.com/kubernetes/kubernetes/issues/61966#issuecomment-377659476
|
||||||
|
if sv.Major == 1 && sv.Minor < 10 {
|
||||||
|
nodeMap[node.Spec.ExternalID] = node
|
||||||
|
} else {
|
||||||
|
providerIDs := strings.Split(node.Spec.ProviderID,"/")
|
||||||
|
instanceID := providerIDs[len(providerIDs)-1]
|
||||||
|
nodeMap[instanceID] = node
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeMap
|
return nodeMap
|
||||||
|
|
|
@ -383,7 +383,7 @@ func (c *awsCloudImplementation) GetCloudGroups(cluster *kops.Cluster, instanceg
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCloudGroups(c AWSCloud, cluster *kops.Cluster, instancegroups []*kops.InstanceGroup, warnUnmatched bool, nodes []v1.Node) (map[string]*cloudinstances.CloudInstanceGroup, error) {
|
func getCloudGroups(c AWSCloud, cluster *kops.Cluster, instancegroups []*kops.InstanceGroup, warnUnmatched bool, nodes []v1.Node) (map[string]*cloudinstances.CloudInstanceGroup, error) {
|
||||||
nodeMap := cloudinstances.GetNodeMap(nodes)
|
nodeMap := cloudinstances.GetNodeMap(nodes, cluster)
|
||||||
|
|
||||||
groups := make(map[string]*cloudinstances.CloudInstanceGroup)
|
groups := make(map[string]*cloudinstances.CloudInstanceGroup)
|
||||||
asgs, err := FindAutoscalingGroups(c, c.Tags())
|
asgs, err := FindAutoscalingGroups(c, c.Tags())
|
||||||
|
|
|
@ -100,7 +100,7 @@ func getCloudGroups(c GCECloud, cluster *kops.Cluster, instancegroups []*kops.In
|
||||||
|
|
||||||
project := c.Project()
|
project := c.Project()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
nodesByExternalID := cloudinstances.GetNodeMap(nodes)
|
nodesByProviderID := cloudinstances.GetNodeMap(nodes, cluster)
|
||||||
|
|
||||||
// There is some code duplication with resources/gce.go here, but more in the structure than a straight copy-paste
|
// There is some code duplication with resources/gce.go here, but more in the structure than a straight copy-paste
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ func getCloudGroups(c GCECloud, cluster *kops.Cluster, instancegroups []*kops.In
|
||||||
CloudInstanceGroup: g,
|
CloudInstanceGroup: g,
|
||||||
}
|
}
|
||||||
|
|
||||||
node := nodesByExternalID[strconv.FormatUint(i.Id, 10)]
|
node := nodesByProviderID[strconv.FormatUint(i.Id, 10)]
|
||||||
if node != nil {
|
if node != nil {
|
||||||
cm.Node = node
|
cm.Node = node
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue