Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #600 from alphagov/add-cluster-autoscaler
Browse files Browse the repository at this point in the history
Add cluster autoscaler
  • Loading branch information
philandstuff authored Oct 4, 2019
2 parents 108c164 + 8518e7a commit b8ee096
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 14 deletions.
Binary file not shown.
19 changes: 11 additions & 8 deletions charts/gsp-cluster/requirements.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
dependencies:
- name: fluentd-cloudwatch
repository: https://kubernetes-charts-incubator.storage.googleapis.com/
version: 0.6.4
- name: cluster-autoscaler
repository: https://kubernetes-charts.storage.googleapis.com/
version: 5.1.0
- name: concourse
repository: https://kubernetes-charts.storage.googleapis.com/
version: 8.2.5
- name: kiam
repository: https://kubernetes-charts.storage.googleapis.com/
version: 2.5.1
- name: fluentd-cloudwatch
repository: https://kubernetes-charts-incubator.storage.googleapis.com/
version: 0.6.4
- name: harbor
repository: https://helm.goharbor.io/
version: 1.1.3
digest: sha256:2a0c1a7ffb5abc8ef64db2ccae629ff037e75e250cd1dc40ad41836a72d03476
generated: "2019-09-23T10:02:21.19228+01:00"
- name: kiam
repository: https://kubernetes-charts.storage.googleapis.com/
version: 2.5.1
digest: sha256:151b4ed228617b41d7793f2edd1eb92039d9b243f87ee4d2c893406ea3a67e6f
generated: "2019-10-02T10:55:58.447495+01:00"
16 changes: 10 additions & 6 deletions charts/gsp-cluster/requirements.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
dependencies:
- name: "fluentd-cloudwatch"
version: 0.6.4
repository: https://kubernetes-charts-incubator.storage.googleapis.com/
- name: "cluster-autoscaler"
version: 5.1.0
repository: https://kubernetes-charts.storage.googleapis.com/
condition: global.runningOnAws
- name: "concourse"
version: 8.2.5
repository: https://kubernetes-charts.storage.googleapis.com/
- name: "kiam"
version: 2.5.1
repository: https://kubernetes-charts.storage.googleapis.com/
- name: "fluentd-cloudwatch"
version: 0.6.4
repository: https://kubernetes-charts-incubator.storage.googleapis.com/
condition: global.runningOnAws
- name: "harbor"
version: 1.1.3
repository: https://helm.goharbor.io/
- name: "kiam"
version: 2.5.1
repository: https://kubernetes-charts.storage.googleapis.com/
condition: global.runningOnAws
9 changes: 9 additions & 0 deletions charts/gsp-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ httpEgressSafelist: []
# requiredApprovalCount: 2
# scope: cluster

cluster-autoscaler:
extraArgs:
balance-similar-node-groups: true
image:
tag: v1.14.5 # upgrade this when upgrading kubernetes
priorityClassName: system-cluster-critical
serviceMonitor:
enabled: true

kiam:
nameOverride:
fullnameOverride:
Expand Down
37 changes: 37 additions & 0 deletions modules/gsp-cluster/cluster-autoscaler.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
resource "aws_iam_role" "cluster_autoscaler" {
name = "cluster-autoscaler"

assume_role_policy = "${data.aws_iam_policy_document.trust_kiam_server.json}"
}

data "aws_iam_policy_document" "cluster_autoscaler_policy" {
statement {
effect = "Allow"

actions = [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeTags",
]

resources = ["*"]
}

statement {
effect = "Allow"

actions = [
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
]

condition = {
test = "Null"
variable = "autoscaling:ResourceTag/k8s.io/cluster-autoscaler/${var.cluster_name}"
values = ["false"]
}

resources = ["*"]
}
}
8 changes: 8 additions & 0 deletions modules/gsp-cluster/data/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ notary:
delegationPassphrase: ${notary_delegation_passphrase}
delegationKey: ${notary_delegation_key}

cluster-autoscaler:
cloudProvider: aws
awsRegion: eu-west-2
autoDiscovery:
clusterName: ${cluster_name}
podAnnotations:
iam.amazonaws.com/role: ${cluster_autoscaler_role_name}

concourseMainTeamGithubTeams: ${concourse_main_team_github_teams}
concourse:
secrets:
Expand Down
2 changes: 2 additions & 0 deletions modules/gsp-cluster/values.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data "template_file" "values" {
sre_role_arns = "${jsonencode(var.sre_role_arns)}"
sre_user_arns = "${jsonencode(var.sre_user_arns)}"
bootstrap_role_arns = "${jsonencode(module.k8s-cluster.bootstrap_role_arns)}"
cluster_autoscaler_role_name = "${aws_iam_role.cluster_autoscaler.name}"
concourse_admin_password = "${random_string.concourse_password.result}"
concourse_teams = "${jsonencode(concat(list("main"), var.concourse_teams))}"
concourse_main_team_github_teams = "${jsonencode(var.concourse_main_team_github_teams)}"
Expand Down Expand Up @@ -57,6 +58,7 @@ data "template_file" "values" {

permitted_roles_regex = "^(${join("|", list(
aws_iam_role.cloudwatch_log_shipping_role.name,
aws_iam_role.cluster_autoscaler.name,
aws_iam_role.concourse.name,
aws_iam_role.grafana.name,
aws_iam_role.gsp-service-operator.name,
Expand Down
6 changes: 6 additions & 0 deletions modules/k8s-cluster/data/nodegroup-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ Resources:
- Key: !Sub kubernetes.io/cluster/${ClusterName}
Value: owned
PropagateAtLaunch: true
- Key: k8s.io/cluster-autoscaler/enabled
Value: true
PropagateAtLaunch: true
- Key: !Sub k8s.io/cluster-autoscaler/${ClusterName}
Value: true
PropagateAtLaunch: true
UpdatePolicy:
AutoScalingRollingUpdate:
MaxBatchSize: 2
Expand Down

0 comments on commit b8ee096

Please sign in to comment.