diff --git a/CHANGES.md b/CHANGES.md index 5c22af18..570ccd76 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,8 @@ Notable changes between versions. * Switch to Azure's new Linux VM and Linux VM Scale Set resources * Set controller's Azure disk caching to None * Associate subnets (in addition to NICs) with security groups (aesthetic) +* Add support for Flatcar Container Linux ([#664](https://github.com/poseidon/typhoon/pull/664)) + * Requires accepting Flatcar Linux Azure Marketplace terms #### Bare-Metal diff --git a/README.md b/README.md index 69b987f7..73bc89ca 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Typhoon is available for [Flatcar Container Linux](https://www.flatcar-linux.org | Platform | Operating System | Terraform Module | Status | |---------------|------------------|------------------|--------| | AWS | Flatcar Linux | [aws/container-linux/kubernetes](aws/container-linux/kubernetes) | stable | +| Azure | Flatcar Linux | [azure/container-linux/kubernetes](azure/container-linux/kubernetes) | alpha | | Bare-Metal | Flatcar Linux | [bare-metal/container-linux/kubernetes](bare-metal/container-linux/kubernetes) | stable | | Google Cloud | Flatcar Linux | [google-cloud/container-linux/kubernetes](google-cloud/container-linux/kubernetes) | alpha | | Digital Ocean | Flatcar Linux | [digital-ocean/container-linux/kubernetes](digital-ocean/container-linux/kubernetes) | alpha | diff --git a/azure/container-linux/kubernetes/controllers.tf b/azure/container-linux/kubernetes/controllers.tf index ea45c93a..f535ffcd 100644 --- a/azure/container-linux/kubernetes/controllers.tf +++ b/azure/container-linux/kubernetes/controllers.tf @@ -15,8 +15,10 @@ resource "azurerm_dns_a_record" "etcds" { } locals { - # Channel for a Container Linux derivative + # Container Linux derivative # coreos-stable -> Container Linux Stable + # flatcar-stable -> Flatcar Linux Stable + flavor = split("-", var.os_image)[0] channel = split("-", var.os_image)[1] } @@ -52,12 +54,23 @@ resource "azurerm_linux_virtual_machine" "controllers" { } source_image_reference { - publisher = "CoreOS" - offer = "CoreOS" + publisher = local.flavor == "flatcar" ? "Kinvolk" : "CoreOS" + offer = local.flavor == "flatcar" ? "flatcar-container-linux" : "CoreOS" sku = local.channel version = "latest" } + # Gross hack just for Flatcar Linux + dynamic "plan" { + for_each = local.flavor == "flatcar" ? [1] : [] + + content { + name = local.channel + publisher = "kinvolk" + product = "flatcar-container-linux" + } + } + # network network_interface_ids = [ azurerm_network_interface.controllers.*.id[count.index] diff --git a/azure/container-linux/kubernetes/variables.tf b/azure/container-linux/kubernetes/variables.tf index c86ab9aa..7200e82e 100644 --- a/azure/container-linux/kubernetes/variables.tf +++ b/azure/container-linux/kubernetes/variables.tf @@ -49,7 +49,7 @@ variable "worker_type" { variable "os_image" { type = string default = "coreos-stable" - description = "Channel for a Container Linux derivative (coreos-stable, coreos-beta, coreos-alpha)" + description = "Channel for a Container Linux derivative (coreos-stable, coreos-beta, coreos-alpha, flatcar-stable, flatcar-beta)" } variable "disk_size" { diff --git a/azure/container-linux/kubernetes/workers/workers.tf b/azure/container-linux/kubernetes/workers/workers.tf index ea41a0ca..1a102bd5 100644 --- a/azure/container-linux/kubernetes/workers/workers.tf +++ b/azure/container-linux/kubernetes/workers/workers.tf @@ -1,6 +1,7 @@ locals { - # Channel for a Container Linux derivative # coreos-stable -> Container Linux Stable + # flatcar-stable -> Flatcar Linux Stable + flavor = split("-", var.os_image)[0] channel = split("-", var.os_image)[1] } @@ -24,12 +25,23 @@ resource "azurerm_linux_virtual_machine_scale_set" "workers" { } source_image_reference { - publisher = "CoreOS" - offer = "CoreOS" + publisher = local.flavor == "flatcar" ? "Kinvolk" : "CoreOS" + offer = local.flavor == "flatcar" ? "flatcar-container-linux" : "CoreOS" sku = local.channel version = "latest" } + # Gross hack just for Flatcar Linux + dynamic "plan" { + for_each = local.flavor == "flatcar" ? [1] : [] + + content { + name = local.channel + publisher = "kinvolk" + product = "flatcar-container-linux" + } + } + # Azure requires setting admin_ssh_key, though Ignition custom_data handles it too admin_username = "core" admin_ssh_key { diff --git a/docs/cl/azure.md b/docs/cl/azure.md index 0ece179a..deb4b0a1 100644 --- a/docs/cl/azure.md +++ b/docs/cl/azure.md @@ -85,6 +85,15 @@ module "ramius" { Reference the [variables docs](#variables) or the [variables.tf](https://github.com/poseidon/typhoon/blob/master/azure/container-linux/kubernetes/variables.tf) source. +### Flatcar Linux Only + +Flatcar Linux publishes images to the Azure Marketplace and requires accepting their legal terms. + +``` +az vm image terms show --publish kinvolk --offer flatcar-container-linux --plan stable +az vm image terms accept --publish kinvolk --offer flatcar-container-linux --plan stable +``` + ## ssh-agent Initial bootstrapping requires `bootstrap.service` be started on one controller node. Terraform uses `ssh-agent` to automate this step. Add your SSH private key to `ssh-agent`. @@ -223,7 +232,7 @@ Reference the DNS zone with `azurerm_dns_zone.clusters.name` and its resource gr | worker_count | Number of workers | 1 | 3 | | controller_type | Machine type for controllers | "Standard_B2s" | See below | | worker_type | Machine type for workers | "Standard_DS1_v2" | See below | -| os_image | Channel for a Container Linux derivative | "coreos-stable" | coreos-stable, coreos-beta, coreos-alpha | +| os_image | Channel for a Container Linux derivative | "coreos-stable" | coreos-stable, coreos-beta, coreos-alpha, flatcar-stable, flatcar-beta | | disk_size | Size of the disk in GB | 40 | 100 | | worker_priority | Set priority to Spot to use reduced cost surplus capacity, with the tradeoff that instances can be deallocated at any time | Regular | Spot | | controller_clc_snippets | Controller Container Linux Config snippets | [] | [example](/advanced/customization/#usage) | diff --git a/docs/index.md b/docs/index.md index 8122b055..22ec8931 100644 --- a/docs/index.md +++ b/docs/index.md @@ -42,6 +42,7 @@ Typhoon is available for [Flatcar Container Linux](https://www.flatcar-linux.org | Platform | Operating System | Terraform Module | Status | |---------------|------------------|------------------|--------| | AWS | Flatcar Linux | [aws/container-linux/kubernetes](cl/aws.md) | stable | +| Azure | Flatcar Linux | [azure/container-linux/kubernetes](cl/azure.md) | alpha | | Bare-Metal | Flatcar Linux | [bare-metal/container-linux/kubernetes](cl/bare-metal.md) | stable | | Google Cloud | Flatcar Linux | [google-cloud/container-linux/kubernetes](cl/google-cloud.md) | alpha | | Digital Ocean | Flatcar Linux | [digital-ocean/container-linux/kubernetes](cl/digital-ocean.md) | alpha |