Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#122 from kahun/fix/node_groups_val…
Browse files Browse the repository at this point in the history
…idations

Fix node groups
  • Loading branch information
kahun authored May 24, 2023
2 parents 640c62e + 9bd8dbc commit c0a2c3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/cmd/kind/create/cluster/validation/commonvalidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ func validateRegistryCredentials(descriptor commons.DescriptorFile, secrets comm
func quantityValidations(workerNodes commons.WorkerNodes) error {
for _, wn := range workerNodes {
// Cluster Autoscaler doesn't scale a managed node group lower than minSize or higher than maxSize.
if wn.NodeGroupMaxSize < wn.Quantity {
if wn.NodeGroupMaxSize < wn.Quantity && wn.NodeGroupMaxSize != 0 {
return errors.New("max_size in WorkerNodes " + wn.Name + ", must be equal or greater than quantity")
}
if wn.Quantity < wn.NodeGroupMinSize {
return errors.New("quantity in WorkerNodes " + wn.Name + ", must be equal or greater than min_size")
}
if wn.NodeGroupMinSize < 0 {
return errors.New("min_size in WorkerNodes " + wn.Name + ", must be equal or greater than 0")
}
if wn.ZoneDistribution == "balanced" || wn.ZoneDistribution == "" {
if wn.AZ != "" {
return errors.New("az in WorkerNodes " + wn.Name + ", can not be set when HA is required")
Expand Down
2 changes: 1 addition & 1 deletion pkg/commons/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ type WorkerNodes []struct {
Spot bool `yaml:"spot" validate:"omitempty,boolean"`
Labels map[string]string `yaml:"labels"`
NodeGroupMaxSize int `yaml:"max_size" validate:"required_with=NodeGroupMinSize,numeric,omitempty"`
NodeGroupMinSize int `yaml:"min_size" validate:"required_with=NodeGroupMaxSize,numeric,gt=0,omitempty"`
NodeGroupMinSize int `yaml:"min_size" validate:"required_with=NodeGroupMaxSize,numeric,omitempty"`
RootVolume struct {
Size int `yaml:"size" validate:"numeric"`
Type string `yaml:"type"`
Expand Down

0 comments on commit c0a2c3c

Please sign in to comment.