mirror of https://github.com/kubernetes/kops.git
cluster-autoscaler: Fix priority expander config
This commit is contained in:
parent
cae34bd4f5
commit
d041db85aa
|
@ -41,7 +41,7 @@ spec:
|
|||
version: 9.99.0
|
||||
- id: k8s-1.15
|
||||
manifest: cluster-autoscaler.addons.k8s.io/k8s-1.15.yaml
|
||||
manifestHash: b0c764405add27350d8642bbb30352457acd9b7f223cff119a62bb18773fe2e3
|
||||
manifestHash: 963767d82e85200787e166f3cc6e7b3b9e60d2383c9fef71a562d9e4eedd7086
|
||||
name: cluster-autoscaler.addons.k8s.io
|
||||
selector:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
|
|
|
@ -282,12 +282,12 @@ spec:
|
|||
apiVersion: v1
|
||||
data:
|
||||
priorities: |-
|
||||
"0":
|
||||
0:
|
||||
- .*
|
||||
"50":
|
||||
- .*low.*
|
||||
"100":
|
||||
100:
|
||||
- .*high.*
|
||||
50:
|
||||
- .*low.*
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
|
|
|
@ -41,7 +41,7 @@ spec:
|
|||
version: 9.99.0
|
||||
- id: k8s-1.15
|
||||
manifest: cluster-autoscaler.addons.k8s.io/k8s-1.15.yaml
|
||||
manifestHash: c4557839138e0ff31d1f98ed22223c98cb99170cf838929e4141ac924758314a
|
||||
manifestHash: d28605db2e6ade6fee371d462c0e9893871ea73a35ad598fa616a2657290d319
|
||||
name: cluster-autoscaler.addons.k8s.io
|
||||
selector:
|
||||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
|
|
|
@ -282,12 +282,12 @@ spec:
|
|||
apiVersion: v1
|
||||
data:
|
||||
priorities: |-
|
||||
"0":
|
||||
0:
|
||||
- nodes.cas-priority-expander.example.com
|
||||
"50":
|
||||
- nodes-low-priority.cas-priority-expander.example.com
|
||||
"100":
|
||||
100:
|
||||
- nodes-high-priority.cas-priority-expander.example.com
|
||||
50:
|
||||
- nodes-low-priority.cas-priority-expander.example.com
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
|
|
|
@ -266,8 +266,7 @@ metadata:
|
|||
k8s-addon: cluster-autoscaler.addons.k8s.io
|
||||
k8s-app: cluster-autoscaler
|
||||
data:
|
||||
priorities: |-
|
||||
{{- ClusterAutoscalerPriorities | ToYAML | nindent 4 }}
|
||||
priorities: |- {{ ClusterAutoscalerPriorities | nindent 4 }}
|
||||
{{ end }}
|
||||
---
|
||||
# Source: cluster-autoscaler/templates/deployment.yaml
|
||||
|
|
|
@ -71,6 +71,7 @@ import (
|
|||
"k8s.io/kops/upup/pkg/fi/cloudup/openstack"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/scaleway"
|
||||
"k8s.io/kops/util/pkg/env"
|
||||
"k8s.io/kops/util/pkg/maps"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
|
@ -341,19 +342,26 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap, secretStore fi.SecretS
|
|||
dest["UseServiceAccountExternalPermissions"] = tf.UseServiceAccountExternalPermissions
|
||||
|
||||
if cluster.Spec.ClusterAutoscaler != nil {
|
||||
dest["ClusterAutoscalerPriorities"] = func() map[string][]string {
|
||||
dest["ClusterAutoscalerPriorities"] = func() string {
|
||||
priorities := make(map[string][]string)
|
||||
if cluster.Spec.ClusterAutoscaler.CustomPriorityExpanderConfig != nil {
|
||||
priorities = cluster.Spec.ClusterAutoscaler.CustomPriorityExpanderConfig
|
||||
} else {
|
||||
for name, spec := range tf.GetNodeInstanceGroups() {
|
||||
|
||||
if spec.Autoscale != nil {
|
||||
priorities[fmt.Sprint(spec.AutoscalePriority)] = append(priorities[fmt.Sprint(spec.AutoscalePriority)], fmt.Sprintf("%s.%s", name, tf.ClusterName()))
|
||||
priorities[strconv.Itoa(int(spec.AutoscalePriority))] = append(priorities[strconv.Itoa(int(spec.AutoscalePriority))], fmt.Sprintf("%s.%s", name, tf.ClusterName()))
|
||||
}
|
||||
}
|
||||
}
|
||||
return priorities
|
||||
|
||||
var prioritiesStr []string
|
||||
for _, prio := range maps.SortedKeys(priorities) {
|
||||
prioritiesStr = append(prioritiesStr, fmt.Sprintf("%s:", prio))
|
||||
for _, value := range priorities[prio] {
|
||||
prioritiesStr = append(prioritiesStr, fmt.Sprintf("- %s", value))
|
||||
}
|
||||
}
|
||||
return strings.Join(prioritiesStr, "\n")
|
||||
}
|
||||
dest["CreateClusterAutoscalerPriorityConfig"] = func() bool {
|
||||
return fi.ValueOf(cluster.Spec.ClusterAutoscaler.CreatePriorityExpenderConfig)
|
||||
|
|
Loading…
Reference in New Issue