cloud initialize node in external cloud controller
This commit is contained in:
@@ -202,6 +202,7 @@ func (kl *Kubelet) initialNode() (*v1.Node, error) {
|
||||
Unschedulable: !kl.registerSchedulable,
|
||||
},
|
||||
}
|
||||
nodeTaints := make([]v1.Taint, 0)
|
||||
if len(kl.kubeletConfiguration.RegisterWithTaints) > 0 {
|
||||
taints := make([]v1.Taint, len(kl.kubeletConfiguration.RegisterWithTaints))
|
||||
for i := range kl.kubeletConfiguration.RegisterWithTaints {
|
||||
@@ -209,7 +210,19 @@ func (kl *Kubelet) initialNode() (*v1.Node, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
node.Spec.Taints = taints
|
||||
nodeTaints = append(nodeTaints, taints...)
|
||||
}
|
||||
if kl.externalCloudProvider {
|
||||
taint := v1.Taint{
|
||||
Key: metav1.TaintExternalCloudProvider,
|
||||
Value: "true",
|
||||
Effect: v1.TaintEffectNoSchedule,
|
||||
}
|
||||
|
||||
nodeTaints = append(nodeTaints, taint)
|
||||
}
|
||||
if len(nodeTaints) > 0 {
|
||||
node.Spec.Taints = nodeTaints
|
||||
}
|
||||
// Initially, set NodeNetworkUnavailable to true.
|
||||
if kl.providerRequiresNetworkingConfiguration() {
|
||||
@@ -241,6 +254,10 @@ func (kl *Kubelet) initialNode() (*v1.Node, error) {
|
||||
node.ObjectMeta.Labels[k] = v
|
||||
}
|
||||
|
||||
if kl.providerID != "" {
|
||||
node.Spec.ProviderID = kl.providerID
|
||||
}
|
||||
|
||||
if kl.cloud != nil {
|
||||
instances, ok := kl.cloud.Instances()
|
||||
if !ok {
|
||||
@@ -259,9 +276,11 @@ func (kl *Kubelet) initialNode() (*v1.Node, error) {
|
||||
// TODO: We can't assume that the node has credentials to talk to the
|
||||
// cloudprovider from arbitrary nodes. At most, we should talk to a
|
||||
// local metadata server here.
|
||||
node.Spec.ProviderID, err = cloudprovider.GetInstanceProviderID(kl.cloud, kl.nodeName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if node.Spec.ProviderID == "" {
|
||||
node.Spec.ProviderID, err = cloudprovider.GetInstanceProviderID(kl.cloud, kl.nodeName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
instanceType, err := instances.InstanceType(kl.nodeName)
|
||||
@@ -443,6 +462,7 @@ func (kl *Kubelet) setNodeAddress(node *v1.Node) error {
|
||||
// 4) Try to get the IP from the network interface used as default gateway
|
||||
if kl.nodeIP != nil {
|
||||
ipAddr = kl.nodeIP
|
||||
node.ObjectMeta.Annotations[metav1.AnnotationProvidedIPAddr] = kl.nodeIP.String()
|
||||
} else if addr := net.ParseIP(kl.hostname); addr != nil {
|
||||
ipAddr = addr
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user