Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#63 from kahun/fix/zone_distribution
Browse files Browse the repository at this point in the history
[EOS-11006] No funciona el parametro zone_distribution
  • Loading branch information
kahun authored Mar 14, 2023
2 parents 23b35a5 + 2c5c9e4 commit c0d447f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
34 changes: 21 additions & 13 deletions pkg/cluster/internal/create/actions/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,29 +216,37 @@ func GetClusterDescriptor(descriptorPath string) (*DescriptorFile, error) {
return &descriptorFile, nil
}

func resto(n int, i int) int {
var r int
r = (n % 3) / (i + 1)
if r > 1 {
r = 1
}
return r
}

func GetClusterManifest(flavor string, params TemplateParams) (string, error) {

funcMap := template.FuncMap{
"loop": func(az string, qa int, maxsize int, minsize int) <-chan Node {
"loop": func(az string, zd string, qa int, maxsize int, minsize int) <-chan Node {
ch := make(chan Node)
go func() {
var azs []string
var q int
var mx int
var mn int
if az != "" {
azs = []string{az}
q = qa
mx = maxsize
mn = minsize
ch <- Node{AZ: az, QA: qa, MaxSize: maxsize, MinSize: minsize}
} else {
azs = []string{"a", "b", "c"}
q = qa / 3
mx = maxsize / 3
mn = minsize / 3
}
for _, a := range azs {
ch <- Node{AZ: a, QA: q, MaxSize: mx, MinSize: mn}
for i, a := range []string{"a", "b", "c"} {
if zd == "unbalanced" {
q = qa/3 + resto(qa, i)
mx = maxsize/3 + resto(maxsize, i)
mn = minsize/3 + resto(minsize, i)
ch <- Node{AZ: a, QA: q, MaxSize: mx, MinSize: mn}
} else {
ch <- Node{AZ: a, QA: qa / 3, MaxSize: maxsize / 3, MinSize: minsize / 3}
}
}
}
close(ch)
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
- name: ANNOTATE_POD_IP
value: \"true\"
{{- range $node := .Descriptor.WorkerNodes }}
{{- range $index, $n := loop .AZ .Quantity .NodeGroupMaxSize .NodeGroupMinSize }}
{{- range $index, $n := loop .AZ .ZoneDistribution .Quantity .NodeGroupMaxSize .NodeGroupMinSize }}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ spec:
rootDeviceType: {{ .Descriptor.ControlPlane.RootVolume.Type }}
{{- end }}
{{- range $node := .Descriptor.WorkerNodes }}
{{- range $index, $n := loop .AZ .Quantity .NodeGroupMaxSize .NodeGroupMinSize }}
{{- range $index, $n := loop .AZ .ZoneDistribution .Quantity .NodeGroupMaxSize .NodeGroupMinSize }}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
Expand Down

0 comments on commit c0d447f

Please sign in to comment.