mirror of https://github.com/kubernetes/kops.git
Added support for multiple workers for vSphere.
This commit is contained in:
parent
d65adc6834
commit
4128b50bae
|
|
@ -203,3 +203,7 @@ func (b *KopsModelContext) NamePrivateRouteTableInZone(zoneName string) string {
|
||||||
func (b *KopsModelContext) LinkToPrivateRouteTableInZone(zoneName string) *awstasks.RouteTable {
|
func (b *KopsModelContext) LinkToPrivateRouteTableInZone(zoneName string) *awstasks.RouteTable {
|
||||||
return &awstasks.RouteTable{Name: s(b.NamePrivateRouteTableInZone(zoneName))}
|
return &awstasks.RouteTable{Name: s(b.NamePrivateRouteTableInZone(zoneName))}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *KopsModelContext) InstanceName(ig *kops.InstanceGroup, suffix string) string {
|
||||||
|
return b.AutoscalingGroupName(ig) + suffix
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,11 @@ limitations under the License.
|
||||||
package vspheremodel
|
package vspheremodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"k8s.io/kops/pkg/apis/kops"
|
||||||
"k8s.io/kops/pkg/model"
|
"k8s.io/kops/pkg/model"
|
||||||
"k8s.io/kops/upup/pkg/fi"
|
"k8s.io/kops/upup/pkg/fi"
|
||||||
"k8s.io/kops/upup/pkg/fi/cloudup/vspheretasks"
|
"k8s.io/kops/upup/pkg/fi/cloudup/vspheretasks"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AutoscalingGroupModelBuilder configures AutoscalingGroup objects
|
// AutoscalingGroupModelBuilder configures AutoscalingGroup objects
|
||||||
|
|
@ -36,31 +38,37 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
// The following logic should considerably change once we add support for multiple master/worker nodes,
|
// The following logic should considerably change once we add support for multiple master/worker nodes,
|
||||||
// cloud-init etc.
|
// cloud-init etc.
|
||||||
for _, ig := range b.InstanceGroups {
|
for _, ig := range b.InstanceGroups {
|
||||||
name := b.AutoscalingGroupName(ig)
|
instanceCount := int(fi.Int32Value(ig.Spec.MinSize))
|
||||||
createVmTask := &vspheretasks.VirtualMachine{
|
if ig.Spec.Role == kops.InstanceGroupRoleMaster {
|
||||||
Name: &name,
|
instanceCount = 1
|
||||||
VMTemplateName: fi.String(ig.Spec.Image),
|
|
||||||
}
|
}
|
||||||
|
for i := 1; i <= instanceCount; i++ {
|
||||||
|
name := b.InstanceName(ig, strconv.Itoa(i))
|
||||||
|
createVmTask := &vspheretasks.VirtualMachine{
|
||||||
|
Name: &name,
|
||||||
|
VMTemplateName: fi.String(ig.Spec.Image),
|
||||||
|
}
|
||||||
|
|
||||||
c.AddTask(createVmTask)
|
c.AddTask(createVmTask)
|
||||||
|
|
||||||
attachISOTaskName := "AttachISO-" + name
|
attachISOTaskName := "AttachISO-" + name
|
||||||
attachISOTask := &vspheretasks.AttachISO{
|
attachISOTask := &vspheretasks.AttachISO{
|
||||||
Name: &attachISOTaskName,
|
Name: &attachISOTaskName,
|
||||||
VM: createVmTask,
|
VM: createVmTask,
|
||||||
IG: ig,
|
IG: ig,
|
||||||
BootstrapScript: b.BootstrapScript,
|
BootstrapScript: b.BootstrapScript,
|
||||||
|
}
|
||||||
|
attachISOTask.BootstrapScript.AddAwsEnvironmentVariables = true
|
||||||
|
|
||||||
|
c.AddTask(attachISOTask)
|
||||||
|
|
||||||
|
powerOnTaskName := "PowerON-" + name
|
||||||
|
powerOnTask := &vspheretasks.VMPowerOn{
|
||||||
|
Name: &powerOnTaskName,
|
||||||
|
AttachISO: attachISOTask,
|
||||||
|
}
|
||||||
|
c.AddTask(powerOnTask)
|
||||||
}
|
}
|
||||||
attachISOTask.BootstrapScript.AddAwsEnvironmentVariables = true
|
|
||||||
|
|
||||||
c.AddTask(attachISOTask)
|
|
||||||
|
|
||||||
powerOnTaskName := "PowerON-" + name
|
|
||||||
powerOnTask := &vspheretasks.VMPowerOn{
|
|
||||||
Name: &powerOnTaskName,
|
|
||||||
AttachISO: attachISOTask,
|
|
||||||
}
|
|
||||||
c.AddTask(powerOnTask)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue