mirror of https://github.com/kubernetes/kops.git
using same disk sizes for gce
This commit is contained in:
parent
ea314784b5
commit
c4c63b2b0c
|
|
@ -68,6 +68,7 @@ k8s.io/kops/pkg/kubemanifest
|
|||
k8s.io/kops/pkg/model
|
||||
k8s.io/kops/pkg/model/awsmodel
|
||||
k8s.io/kops/pkg/model/components
|
||||
k8s.io/kops/pkg/model/defaults
|
||||
k8s.io/kops/pkg/model/gcemodel
|
||||
k8s.io/kops/pkg/model/iam
|
||||
k8s.io/kops/pkg/model/resources
|
||||
|
|
|
|||
|
|
@ -23,16 +23,14 @@ import (
|
|||
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/pkg/model"
|
||||
"k8s.io/kops/pkg/model/defaults"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/awstasks"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultVolumeSizeNode = 128
|
||||
DefaultVolumeSizeMaster = 64
|
||||
DefaultVolumeSizeBastion = 32
|
||||
DefaultVolumeType = "gp2"
|
||||
DefaultVolumeIops = 100
|
||||
DefaultVolumeType = "gp2"
|
||||
DefaultVolumeIops = 100
|
||||
)
|
||||
|
||||
// AutoscalingGroupModelBuilder configures AutoscalingGroup objects
|
||||
|
|
@ -52,18 +50,9 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
|||
// LaunchConfiguration
|
||||
var launchConfiguration *awstasks.LaunchConfiguration
|
||||
{
|
||||
volumeSize := fi.Int32Value(ig.Spec.RootVolumeSize)
|
||||
if volumeSize == 0 {
|
||||
switch ig.Spec.Role {
|
||||
case kops.InstanceGroupRoleMaster:
|
||||
volumeSize = DefaultVolumeSizeMaster
|
||||
case kops.InstanceGroupRoleNode:
|
||||
volumeSize = DefaultVolumeSizeNode
|
||||
case kops.InstanceGroupRoleBastion:
|
||||
volumeSize = DefaultVolumeSizeBastion
|
||||
default:
|
||||
return fmt.Errorf("this case should not get hit, kops.Role not found %s", ig.Spec.Role)
|
||||
}
|
||||
volumeSize, err := defaults.FindDefaultVolumeSize(fi.Int32Value(ig.Spec.RootVolumeSize), ig.Spec.Role)
|
||||
if err != nil {
|
||||
return fmt.Errorf("this case should not get hit, kops.Role not found %s", ig.Spec.Role)
|
||||
}
|
||||
volumeType := fi.StringValue(ig.Spec.RootVolumeType)
|
||||
volumeIops := fi.Int32Value(ig.Spec.RootVolumeIops)
|
||||
|
|
@ -113,8 +102,6 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
|||
t.SecurityGroups = append(t.SecurityGroups, sgTask)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
if t.SSHKey, err = b.LinkToSSHKey(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package defaults
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultVolumeSizeNode = 128
|
||||
DefaultVolumeSizeMaster = 64
|
||||
DefaultVolumeSizeBastion = 32
|
||||
)
|
||||
|
||||
// FindDefaultVolumeSize returns the default volume size based on role.
|
||||
func FindDefaultVolumeSize(volumeSize int32, role kops.InstanceGroupRole) (int32, error) {
|
||||
if volumeSize == 0 {
|
||||
switch role {
|
||||
case kops.InstanceGroupRoleMaster:
|
||||
volumeSize = DefaultVolumeSizeMaster
|
||||
case kops.InstanceGroupRoleNode:
|
||||
volumeSize = DefaultVolumeSizeNode
|
||||
case kops.InstanceGroupRoleBastion:
|
||||
volumeSize = DefaultVolumeSizeBastion
|
||||
default:
|
||||
return -1, fmt.Errorf("this case should not get hit, kops.Role not found %s", role)
|
||||
}
|
||||
}
|
||||
|
||||
return volumeSize, nil
|
||||
}
|
||||
|
|
@ -22,12 +22,12 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/pkg/model"
|
||||
"k8s.io/kops/pkg/model/defaults"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/gcetasks"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultVolumeSize = 100
|
||||
DefaultVolumeType = "pd-standard"
|
||||
)
|
||||
|
||||
|
|
@ -54,8 +54,9 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
|||
var instanceTemplate *gcetasks.InstanceTemplate
|
||||
{
|
||||
volumeSize := fi.Int32Value(ig.Spec.RootVolumeSize)
|
||||
if volumeSize == 0 {
|
||||
volumeSize = DefaultVolumeSize
|
||||
volumeSize, err := defaults.FindDefaultVolumeSize(fi.Int32Value(ig.Spec.RootVolumeSize), ig.Spec.Role)
|
||||
if err != nil {
|
||||
return fmt.Errorf("this case should not get hit, kops.Role not found %s", ig.Spec.Role)
|
||||
}
|
||||
volumeType := fi.StringValue(ig.Spec.RootVolumeType)
|
||||
if volumeType == "" {
|
||||
|
|
|
|||
Loading…
Reference in New Issue