mirror of https://github.com/kubernetes/kops.git
gce: Update cluster-autoscaler config
This commit is contained in:
parent
f1c1a50391
commit
7a65b0f75e
|
|
@ -318,10 +318,8 @@ spec:
|
||||||
- --aws-use-static-instance-list={{ .AWSUseStaticInstanceList }}
|
- --aws-use-static-instance-list={{ .AWSUseStaticInstanceList }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
- --expander={{ .Expander }}
|
- --expander={{ .Expander }}
|
||||||
{{ range $name, $spec := GetNodeInstanceGroups }}
|
{{ range $nodeGroup := GetClusterAutoscalerNodeGroups }}
|
||||||
{{ if WithDefaultBool $spec.Autoscale true }}
|
- --nodes={{ $nodeGroup.MinSize }}:{{ $nodeGroup.MaxSize }}:{{ $nodeGroup.Other }}
|
||||||
- --nodes={{ $spec.MinSize }}:{{ $spec.MaxSize }}:{{ $name }}{{- if not (eq GetCloudProvider "gce") }}.{{ ClusterName }}{{ end -}}
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
- --scale-down-utilization-threshold={{ .ScaleDownUtilizationThreshold }}
|
- --scale-down-utilization-threshold={{ .ScaleDownUtilizationThreshold }}
|
||||||
- --skip-nodes-with-local-storage={{ .SkipNodesWithLocalStorage }}
|
- --skip-nodes-with-local-storage={{ .SkipNodesWithLocalStorage }}
|
||||||
|
|
@ -335,9 +333,11 @@ spec:
|
||||||
- --logtostderr=true
|
- --logtostderr=true
|
||||||
- --stderrthreshold=info
|
- --stderrthreshold=info
|
||||||
- --v=4
|
- --v=4
|
||||||
|
{{ if (eq GetCloudProvider "aws") }}
|
||||||
env:
|
env:
|
||||||
- name: AWS_REGION
|
- name: AWS_REGION
|
||||||
value: "{{ Region }}"
|
value: "{{ Region }}"
|
||||||
|
{{ end }}
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
failureThreshold: 3
|
failureThreshold: 3
|
||||||
httpGet:
|
httpGet:
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap, secretStore fi.SecretS
|
||||||
dest["GetCloudProvider"] = cluster.Spec.GetCloudProvider
|
dest["GetCloudProvider"] = cluster.Spec.GetCloudProvider
|
||||||
dest["GetInstanceGroup"] = tf.GetInstanceGroup
|
dest["GetInstanceGroup"] = tf.GetInstanceGroup
|
||||||
dest["GetNodeInstanceGroups"] = tf.GetNodeInstanceGroups
|
dest["GetNodeInstanceGroups"] = tf.GetNodeInstanceGroups
|
||||||
|
dest["GetClusterAutoscalerNodeGroups"] = tf.GetClusterAutoscalerNodeGroups
|
||||||
dest["HasHighlyAvailableControlPlane"] = tf.HasHighlyAvailableControlPlane
|
dest["HasHighlyAvailableControlPlane"] = tf.HasHighlyAvailableControlPlane
|
||||||
dest["ControlPlaneControllerReplicas"] = tf.ControlPlaneControllerReplicas
|
dest["ControlPlaneControllerReplicas"] = tf.ControlPlaneControllerReplicas
|
||||||
dest["APIServerNodeRole"] = tf.APIServerNodeRole
|
dest["APIServerNodeRole"] = tf.APIServerNodeRole
|
||||||
|
|
@ -824,6 +825,37 @@ func (tf *TemplateFunctions) GetNodeInstanceGroups() map[string]kops.InstanceGro
|
||||||
return nodegroups
|
return nodegroups
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ClusterAutoscalerNodeGroup struct {
|
||||||
|
AutoScale *bool
|
||||||
|
MinSize int32
|
||||||
|
MaxSize int32
|
||||||
|
Other string
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetClusterAutoscalerGroups returns a map containing ClusterAutoscaler info for each instance group of type Node.
|
||||||
|
func (tf *TemplateFunctions) GetClusterAutoscalerNodeGroups() map[string]ClusterAutoscalerNodeGroup {
|
||||||
|
cluster := tf.Cluster
|
||||||
|
groups := make(map[string]ClusterAutoscalerNodeGroup)
|
||||||
|
for _, ig := range tf.KopsModelContext.InstanceGroups {
|
||||||
|
if ig.Spec.Role == kops.InstanceGroupRoleNode && (ig.Spec.Autoscale == nil || fi.ValueOf(ig.Spec.Autoscale)) {
|
||||||
|
group := ClusterAutoscalerNodeGroup{
|
||||||
|
AutoScale: ig.Spec.Autoscale,
|
||||||
|
MinSize: fi.ValueOf(ig.Spec.MinSize),
|
||||||
|
MaxSize: fi.ValueOf(ig.Spec.MaxSize),
|
||||||
|
}
|
||||||
|
if cluster.Spec.GetCloudProvider() == kops.CloudProviderGCE {
|
||||||
|
cloud := tf.cloud.(gce.GCECloud)
|
||||||
|
format := "https://www.googleapis.com/compute/v1/projects/%s/zones/%s/instanceGroups/%s"
|
||||||
|
group.Other = fmt.Sprintf(format, cloud.Project(), ig.Spec.Zones[0], gce.NameForInstanceGroupManager(cluster, ig, ig.Spec.Zones[0]))
|
||||||
|
} else {
|
||||||
|
group.Other = ig.Name + "." + cluster.Name
|
||||||
|
}
|
||||||
|
groups[ig.Name] = group
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return groups
|
||||||
|
}
|
||||||
|
|
||||||
func (tf *TemplateFunctions) architectureOfAMI(amiID string) string {
|
func (tf *TemplateFunctions) architectureOfAMI(amiID string) string {
|
||||||
image, _ := tf.cloud.(awsup.AWSCloud).ResolveImage(amiID)
|
image, _ := tf.cloud.(awsup.AWSCloud).ResolveImage(amiID)
|
||||||
switch *image.Architecture {
|
switch *image.Architecture {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue