mirror of https://github.com/kubernetes/kops.git
Hotfix for clusters with InstanceGroupName not defined
This commit is contained in:
parent
fb27039f84
commit
06a413bff9
|
|
@ -22,14 +22,12 @@ func BuildKubeletConfigSpec(cluster *Cluster, instanceGroup *InstanceGroup) (*Ku
|
|||
utils.JsonMergeStruct(c, cluster.Spec.Kubelet)
|
||||
}
|
||||
|
||||
if instanceGroup != nil {
|
||||
for k, v := range instanceGroup.Spec.NodeLabels {
|
||||
if c.NodeLabels == nil {
|
||||
c.NodeLabels = make(map[string]string)
|
||||
}
|
||||
c.NodeLabels[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const MaxAttemptsWithNoProgress = 100
|
|||
type NodeUpCommand struct {
|
||||
config *NodeUpConfig
|
||||
cluster *api.Cluster
|
||||
instancegroup *api.InstanceGroup
|
||||
instanceGroup *api.InstanceGroup
|
||||
ConfigLocation string
|
||||
ModelDir vfs.Path
|
||||
CacheDir string
|
||||
|
|
@ -109,16 +109,18 @@ func (c *NodeUpCommand) Run(out io.Writer) error {
|
|||
if c.config.InstanceGroupName != "" {
|
||||
instanceGroupLocation := configBase.Join("instancegroup", c.config.InstanceGroupName)
|
||||
|
||||
c.instancegroup = &api.InstanceGroup{}
|
||||
c.instanceGroup = &api.InstanceGroup{}
|
||||
b, err := instanceGroupLocation.ReadFile()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error loading InstanceGroup %q: %v", instanceGroupLocation, err)
|
||||
}
|
||||
|
||||
err = utils.YamlUnmarshal(b, c.instancegroup)
|
||||
err = utils.YamlUnmarshal(b, c.instanceGroup)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing InstanceGroup %q: %v", instanceGroupLocation, err)
|
||||
}
|
||||
} else {
|
||||
glog.Warningf("No instance group defined in nodeup config")
|
||||
}
|
||||
|
||||
err := evaluateSpec(c.cluster)
|
||||
|
|
@ -164,7 +166,7 @@ func (c *NodeUpCommand) Run(out io.Writer) error {
|
|||
|
||||
loader := NewLoader(c.config, c.cluster, assets, tags)
|
||||
|
||||
tf, err := newTemplateFunctions(c.config, c.cluster, c.instancegroup, tags)
|
||||
tf, err := newTemplateFunctions(c.config, c.cluster, c.instanceGroup, tags)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error initializing: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,11 +67,28 @@ func newTemplateFunctions(nodeupConfig *NodeUpConfig, cluster *api.Cluster, inst
|
|||
return nil, fmt.Errorf("KeyStore not set")
|
||||
}
|
||||
|
||||
kubeletConfigSpec, err := api.BuildKubeletConfigSpec(t.cluster, t.instanceGroup)
|
||||
{
|
||||
instanceGroup := t.instanceGroup
|
||||
if instanceGroup == nil {
|
||||
// Old clusters might not have exported instance groups
|
||||
// in that case we build a synthetic instance group with the information that BuildKubeletConfigSpec needs
|
||||
// TODO: Remove this once we have a stable release
|
||||
glog.Warningf("Building a synthetic instance group")
|
||||
instanceGroup = &api.InstanceGroup{}
|
||||
instanceGroup.Name = "synthetic"
|
||||
if t.IsMaster() {
|
||||
instanceGroup.Spec.Role = api.InstanceGroupRoleMaster
|
||||
} else {
|
||||
instanceGroup.Spec.Role = api.InstanceGroupRoleNode
|
||||
}
|
||||
t.instanceGroup = instanceGroup
|
||||
}
|
||||
kubeletConfigSpec, err := api.BuildKubeletConfigSpec(cluster, instanceGroup)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error building kubelet config: %v", err)
|
||||
}
|
||||
t.kubeletConfig = kubeletConfigSpec
|
||||
}
|
||||
|
||||
return t, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue