From 37c79a2e04782a4bed9ec05ea0daf058db61eb8c Mon Sep 17 00:00:00 2001 From: Nuru Date: Sat, 7 Sep 2019 16:27:51 -0700 Subject: [PATCH] [kops-private-topology] Align with current auto-scaler implementation (#43) --- .../kops/kops-private-topology.yaml.gotmpl | 50 ++++++++++++------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/templates/kops/kops-private-topology.yaml.gotmpl b/templates/kops/kops-private-topology.yaml.gotmpl index 7c99def..dd62fec 100644 --- a/templates/kops/kops-private-topology.yaml.gotmpl +++ b/templates/kops/kops-private-topology.yaml.gotmpl @@ -32,19 +32,6 @@ spec: "ec2:DescribeTags" ], "Resource": "*" - {{- if bool (getenv "KOPS_CLUSTER_AUTOSCALER_ENABLED" "false") }} - }, - { - "Effect": "Allow", - "Action": [ - "autoscaling:DescribeAutoScalingGroups", - "autoscaling:DescribeAutoScalingInstances", - "autoscaling:DescribeTags", - "autoscaling:SetDesiredCapacity", - "autoscaling:TerminateInstanceInAutoScalingGroup" - ], - "Resource": "*" - {{- end }} } ] api: @@ -92,10 +79,6 @@ spec: channel: stable cloudLabels: Cluster: {{ getenv "KOPS_CLUSTER_NAME" }} - {{- if bool (getenv "KOPS_CLUSTER_AUTOSCALER_ENABLED" "false") }} - k8s.io/cluster-autoscaler/enabled: "true" - kubernetes.io/cluster/{{ getenv "KOPS_CLUSTER_NAME" }}: "owned" - {{- end }} cloudProvider: aws configBase: {{ getenv "KOPS_STATE_STORE" }}/{{ getenv "KOPS_CLUSTER_NAME" }} {{- if getenv "KOPS_DNS_ZONE" }} @@ -328,6 +311,33 @@ spec: - {{ . }} {{- end }} +{{- if getenv "NODE_MAX_SIZE_PER_AZ" }} +{{ range (getenv "KOPS_NODES_AVAILABILITY_ZONES" ( getenv "KOPS_AVAILABILITY_ZONES" ) | strings.Split ",") }} +--- +apiVersion: kops/v1alpha2 +kind: InstanceGroup +metadata: + labels: + kops.k8s.io/cluster: {{ getenv "KOPS_CLUSTER_NAME" }} + name: nodes-{{ . }} +spec: + detailedInstanceMonitoring: {{ getenv "KOPS_CLOUDWATCH_DETAILED_MONITORING" "false" }} + associatePublicIp: false + {{- if bool (getenv "KOPS_CLUSTER_AUTOSCALER_ENABLED" "false") }} + cloudLabels: + k8s.io/cluster-autoscaler/enabled: "true" + k8s.io/cluster-autoscaler/{{ getenv "KOPS_CLUSTER_NAME" }}: "owned" + {{- end }} + image: {{ getenv "KOPS_BASE_IMAGE" }} + machineType: {{ getenv "NODE_MACHINE_TYPE" }} + maxSize: {{ getenv "NODE_MAX_SIZE_PER_AZ" }} + minSize: {{ getenv "NODE_MIN_SIZE_PER_AZ" "1" }} + role: Node + subnets: + - {{ . }} +{{- end }} + +{{- else }} --- apiVersion: kops/v1alpha2 kind: InstanceGroup @@ -338,6 +348,11 @@ metadata: spec: detailedInstanceMonitoring: {{ getenv "KOPS_CLOUDWATCH_DETAILED_MONITORING" "false" }} associatePublicIp: false + {{- if bool (getenv "KOPS_CLUSTER_AUTOSCALER_ENABLED" "false") }} + cloudLabels: + k8s.io/cluster-autoscaler/enabled: "true" + k8s.io/cluster-autoscaler/{{ getenv "KOPS_CLUSTER_NAME" }}: "owned" + {{- end }} image: {{ getenv "KOPS_BASE_IMAGE" }} machineType: {{ getenv "NODE_MACHINE_TYPE" }} maxSize: {{ getenv "NODE_MAX_SIZE" }} @@ -347,6 +362,7 @@ spec: {{- range (getenv "KOPS_NODES_AVAILABILITY_ZONES" ( getenv "KOPS_AVAILABILITY_ZONES" ) | strings.Split ",") }} - {{ . }} {{- end }} +{{- end }} {{/* Allow the manifest to be extended via a datasource */}} {{- if (datasourceExists "extensions") -}}