Skip to content

Commit

Permalink
Allow Flatcar Linux os_channel on AWS
Browse files Browse the repository at this point in the history
* Change AWS optional os_channel variable to represent an AMI
channel for a Container Linux derivative
* Allow the Flatcar Linux Container Linux derivative os_channel
on AWS with `flatcar-stable`, `flatcar-beta`, `flatcar-alpha`
* Require values `stable`, `beta`, `alpha` be changed to `coreos-stable`
(default), `coreos-beta`, `coreos-alpha` if they were set
  • Loading branch information
dghubble committed May 10, 2018
1 parent f2ee75a commit 38f2516
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Notable changes between versions.
* Add `worker_price` to allow worker spot instances. Defaults to empty string for the worker autoscaling group to use regular on-demand instances.
* Add `spot_price` to internal `workers` module for spot [worker pools](https://typhoon.psdn.io/advanced/worker-pools/)
* Note: Unlike GCP `preemptible` workers, spot instances require you to pick a bid price.
* Change `os_channel` variable to represent an AMI channel for a Container Linux derivative
* If set, switch values `stable`, `beta`, `alpha` to `coreos-stable` (default), `coreos-beta`, `coreos-alpha`. (breaking)
* Allow the [Flatcar Linux](https://docs.flatcar-linux.org/) Container Linux derivative with `flatcar-stable`, `flatcar-beta`, `flatcar-alpha`.

#### Addons

Expand Down
32 changes: 31 additions & 1 deletion aws/container-linux/kubernetes/ami.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
locals {
# Pick a CoreOS Container Linux derivative
# coreos-stable -> Container Linux AMI
# flatcar-stable -> Flatcar Linux AMI
ami_id = "${local.flavor == "flatcar" ? data.aws_ami.flatcar.image_id : data.aws_ami.coreos.image_id}"
flavor = "${element(split("-", var.os_channel), 0)}"
channel = "${element(split("-", var.os_channel), 1)}"
}

data "aws_ami" "coreos" {
most_recent = true
owners = ["595879546273"]
Expand All @@ -14,6 +23,27 @@ data "aws_ami" "coreos" {

filter {
name = "name"
values = ["CoreOS-${var.os_channel}-*"]
values = ["CoreOS-${local.channel}-*"]
}
}

data "aws_ami" "flatcar" {
most_recent = true
owners = ["075585003325"]

filter {
name = "architecture"
values = ["x86_64"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

filter {
name = "name"
values = ["Flatcar-${local.channel}-*"]
}
}

2 changes: 1 addition & 1 deletion aws/container-linux/kubernetes/controllers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "aws_instance" "controllers" {

instance_type = "${var.controller_type}"

ami = "${data.aws_ami.coreos.image_id}"
ami = "${local.ami_id}"
user_data = "${element(data.ct_config.controller_ign.*.rendered, count.index)}"

# storage
Expand Down
4 changes: 2 additions & 2 deletions aws/container-linux/kubernetes/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ variable "worker_type" {

variable "os_channel" {
type = "string"
default = "stable"
description = "Container Linux AMI channel (stable, beta, alpha)"
default = "coreos-stable"
description = "AMI channel for a Container Linux derivative (coreos-stable, coreos-beta, coreos-alpha, flatcar-stable, flatcar-beta, flatcar-alpha)"
}

variable "disk_size" {
Expand Down
32 changes: 31 additions & 1 deletion aws/container-linux/kubernetes/workers/ami.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
locals {
# Pick a CoreOS Container Linux derivative
# coreos-stable -> Container Linux AMI
# flatcar-stable -> Flatcar Linux AMI
ami_id = "${local.flavor == "flatcar" ? data.aws_ami.flatcar.image_id : data.aws_ami.coreos.image_id}"
flavor = "${element(split("-", var.os_channel), 0)}"
channel = "${element(split("-", var.os_channel), 1)}"
}

data "aws_ami" "coreos" {
most_recent = true
owners = ["595879546273"]
Expand All @@ -14,6 +23,27 @@ data "aws_ami" "coreos" {

filter {
name = "name"
values = ["CoreOS-${var.os_channel}-*"]
values = ["CoreOS-${local.channel}-*"]
}
}

data "aws_ami" "flatcar" {
most_recent = true
owners = ["075585003325"]

filter {
name = "architecture"
values = ["x86_64"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

filter {
name = "name"
values = ["Flatcar-${local.channel}-*"]
}
}

4 changes: 2 additions & 2 deletions aws/container-linux/kubernetes/workers/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ variable "instance_type" {

variable "os_channel" {
type = "string"
default = "stable"
description = "Container Linux AMI channel (stable, beta, alpha)"
default = "coreos-stable"
description = "AMI channel for a Container Linux derivative (coreos-stable, coreos-beta, coreos-alpha, flatcar-stable, flatcar-beta, flatcar-alpha)"
}

variable "disk_size" {
Expand Down
2 changes: 1 addition & 1 deletion aws/container-linux/kubernetes/workers/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ resource "aws_autoscaling_group" "workers" {

# Worker template
resource "aws_launch_configuration" "worker" {
image_id = "${data.aws_ami.coreos.image_id}"
image_id = "${local.ami_id}"
instance_type = "${var.instance_type}"
spot_price = "${var.spot_price}"

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/worker-pools.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module "tempest-worker-pool" {
count = 2
instance_type = "m5.large"
os_channel = "beta"
os_channel = "coreos-beta"
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/cl/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Reference the DNS zone id with `"${aws_route53_zone.zone-for-clusters.zone_id}"`
| worker_count | Number of workers | 1 | 3 |
| controller_type | EC2 instance type for controllers | "t2.small" | See below |
| worker_type | EC2 instance type for workers | "t2.small" | See below |
| os_channel | Container Linux AMI channel | stable | stable, beta, alpha |
| os_channel | AMI channel for a Container Linux derivative | coreos-stable | coreos-stable, coreos-beta, coreos-alpha, flatcar-stable, flatcar-beta, flatcar-alpha |
| disk_size | Size of the EBS volume in GB | "40" | "100" |
| disk_type | Type of the EBS volume | "gp2" | standard, gp2, io1 |
| worker_price | Spot price in USD for workers. Leave as default empty string for regular on-demand instances | "" | "0.10" |
Expand Down

0 comments on commit 38f2516

Please sign in to comment.