Add support for Flatcar Linux on Azure

* Accept `os_image` "flatcar-stable" and "flatcar-beta" to
use Kinvolk's Flatcar Linux images from the Azure Marketplace

Note: Flatcar Linux Azure Marketplace images require terms be
accepted before use
This commit is contained in:
Dalton Hubble
2020-03-10 23:55:23 -07:00
parent ab7913a061
commit 4e1b8f22df
7 changed files with 46 additions and 8 deletions

View File

@ -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]

View File

@ -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" {

View File

@ -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 {