Skip to content

Commit

Permalink
Add support for cluster autoscaler 1.20.x
Browse files Browse the repository at this point in the history
Update upup/models/cloudup/resources/addons/cluster-autoscaler.addons.k8s.io/k8s-1.15.yaml.template

Co-authored-by: Ciprian Hacman <[email protected]>
  • Loading branch information
Ole Markus With and hakman committed Feb 17, 2021
1 parent dbd503f commit 8ba837f
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docs/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ spec:
Read more about cluster autoscaler in the [official documentation](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler).
##### Disabling cluster autoscaler for a given instance group
{{ kops_feature_table(kops_added_default='1.20') }}
You can disable the autoscaler for a given instance group by adding the following to the instance group spec.
```yaml
spec:
autoscale: false
```
#### Cert-manager
{{ kops_feature_table(kops_added_default='1.20', k8s_min='1.16') }}
Expand Down
4 changes: 4 additions & 0 deletions k8s/crds/kops.k8s.io_instancegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ spec:
description: AssociatePublicIP is true if we want instances to have
a public IP
type: boolean
autoscale:
description: Autoscale determines if autoscaling will be enabled for
the group if cluster autoscaler is enabled
type: boolean
cloudLabels:
additionalProperties:
type: string
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type InstanceGroupSpec struct {
MinSize *int32 `json:"minSize,omitempty"`
// MaxSize is the maximum size of the pool
MaxSize *int32 `json:"maxSize,omitempty"`
// Autoscale determines if autoscaling will be enabled for the group if cluster autoscaler is enabled
Autoscale *bool `json:"autoscale,omitempty"`
// MachineType is the instance class
MachineType string `json:"machineType,omitempty"`
// RootVolumeSize is the size of the EBS root volume to use, in GB
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ type InstanceGroupSpec struct {
MinSize *int32 `json:"minSize,omitempty"`
// MaxSize is the maximum size of the pool
MaxSize *int32 `json:"maxSize,omitempty"`
// Autoscale determines if autoscaling will be enabled for the group if cluster autoscaler is enabled
Autoscale *bool `json:"autoscale,omitempty"`
// MachineType is the instance class
MachineType string `json:"machineType,omitempty"`
// RootVolumeSize is the size of the EBS root volume to use, in GB
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/model/components/clusterautoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func (b *ClusterAutoscalerOptionsBuilder) BuildOptions(o interface{}) error {
v, err := util.ParseKubernetesVersion(clusterSpec.KubernetesVersion)
if err == nil {
switch v.Minor {
case 20:
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.20.0"
case 19:
image = "k8s.gcr.io/autoscaling/cluster-autoscaler:v1.19.1"
case 18:
Expand Down
5 changes: 3 additions & 2 deletions upup/models/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ with .ClusterAutoscaler }}
# Sourced from https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws/examples
# Sourced from https://github.com/kubernetes/autoscaler/blob/cluster-autoscaler-release-1.20/cluster-autoscaler/cloudprovider/aws/examples/cluster-autoscaler-multi-asg.yaml
---
apiVersion: v1
kind: ServiceAccount
Expand Down Expand Up @@ -135,7 +135,6 @@ spec:
labels:
app: cluster-autoscaler
annotations:
prometheus.io/path: "/metrics"
prometheus.io/port: "8085"
prometheus.io/scrape: "true"
spec:
Expand All @@ -158,8 +157,10 @@ spec:
- --cloud-provider={{ $.CloudProvider }}
- --expander={{ .Expander }}
{{ range $name, $spec := GetNodeInstanceGroups }}
{{ if WithDefaultBool $spec.Autoscale true }}
- --nodes={{ $spec.MinSize }}:{{ $spec.MaxSize }}:{{ $name }}.{{ ClusterName }}
{{ end }}
{{ end }}
- --scale-down-utilization-threshold={{ .ScaleDownUtilizationThreshold }}
- --skip-nodes-with-local-storage={{ .SkipNodesWithLocalStorage }}
- --skip-nodes-with-system-pods={{ .SkipNodesWithSystemPods }}
Expand Down

0 comments on commit 8ba837f

Please sign in to comment.