Added support for multiple workers for vSphere.

This commit is contained in:
prashima 2017-03-29 16:37:56 -07:00 committed by Miao Luo
parent d65adc6834
commit 4128b50bae
2 changed files with 33 additions and 21 deletions

View File

@ -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
}

View File

@ -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,7 +38,12 @@ 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))
if ig.Spec.Role == kops.InstanceGroupRoleMaster {
instanceCount = 1
}
for i := 1; i <= instanceCount; i++ {
name := b.InstanceName(ig, strconv.Itoa(i))
createVmTask := &vspheretasks.VirtualMachine{ createVmTask := &vspheretasks.VirtualMachine{
Name: &name, Name: &name,
VMTemplateName: fi.String(ig.Spec.Image), VMTemplateName: fi.String(ig.Spec.Image),
@ -62,5 +69,6 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
} }
c.AddTask(powerOnTask) c.AddTask(powerOnTask)
} }
}
return nil return nil
} }