Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using same disk sizes for gce #3478

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hack/.packages
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 6 additions & 19 deletions pkg/model/awsmodel/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
47 changes: 47 additions & 0 deletions pkg/model/defaults/volumes.go
Original file line number Diff line number Diff line change
@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little odd to pass in volumeSize, but let's get this in and I'll send a PR...

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
}
7 changes: 4 additions & 3 deletions pkg/model/gcemodel/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 == "" {
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/ha_gce/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ resource "google_compute_instance_template" "master-us-test1-a-ha-gce-example-co
source_image = "https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images/cos-stable-57-9202-64-0"
mode = "READ_WRITE"
disk_type = "pd-standard"
disk_size_gb = 100
disk_size_gb = 64
}

network_interface = {
Expand Down Expand Up @@ -382,7 +382,7 @@ resource "google_compute_instance_template" "master-us-test1-b-ha-gce-example-co
source_image = "https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images/cos-stable-57-9202-64-0"
mode = "READ_WRITE"
disk_type = "pd-standard"
disk_size_gb = 100
disk_size_gb = 64
}

network_interface = {
Expand Down Expand Up @@ -421,7 +421,7 @@ resource "google_compute_instance_template" "master-us-test1-c-ha-gce-example-co
source_image = "https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images/cos-stable-57-9202-64-0"
mode = "READ_WRITE"
disk_type = "pd-standard"
disk_size_gb = 100
disk_size_gb = 64
}

network_interface = {
Expand Down Expand Up @@ -460,7 +460,7 @@ resource "google_compute_instance_template" "nodes-ha-gce-example-com" {
source_image = "https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images/cos-stable-57-9202-64-0"
mode = "READ_WRITE"
disk_type = "pd-standard"
disk_size_gb = 100
disk_size_gb = 128
}

network_interface = {
Expand Down