From 4fb3ea2c7efabb7ae88720ef31798a1cc4c4ade8 Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Mon, 1 May 2017 17:52:48 -0700 Subject: [PATCH] examples/terraform: Rename coreos-install to container-linux-install * Add container-linux-install profile to install Container Linux * Add cached-container-linux-install profile to install Container Linux from cached matchbox assets --- .gitignore | 2 -- examples/terraform/.gitignore | 3 +- .../terraform/bootkube-install/bootkube.tf | 12 +++---- examples/terraform/etcd3-install/etcd3.tf | 11 +++--- ...tmpl => container-linux-install.yaml.tmpl} | 3 +- .../terraform/modules/profiles/outputs.tf | 8 +++-- .../terraform/modules/profiles/profiles.tf | 36 +++++++++++++++---- .../terraform/modules/profiles/variables.tf | 11 ++++-- 8 files changed, 59 insertions(+), 27 deletions(-) rename examples/terraform/modules/profiles/cl/{coreos-install.yaml.tmpl => container-linux-install.yaml.tmpl} (80%) diff --git a/.gitignore b/.gitignore index 9bcf2850..840a65d0 100644 --- a/.gitignore +++ b/.gitignore @@ -32,5 +32,3 @@ bin/ _output/ tools/ contrib/registry/data - -terraform.tfvars diff --git a/examples/terraform/.gitignore b/examples/terraform/.gitignore index d57f9c5b..d631edd7 100644 --- a/examples/terraform/.gitignore +++ b/examples/terraform/.gitignore @@ -1,3 +1,4 @@ -*.tfstate* +terraform.tfvars .terraform +*.tfstate* assets diff --git a/examples/terraform/bootkube-install/bootkube.tf b/examples/terraform/bootkube-install/bootkube.tf index c890d000..b9c1c4da 100644 --- a/examples/terraform/bootkube-install/bootkube.tf +++ b/examples/terraform/bootkube-install/bootkube.tf @@ -2,17 +2,18 @@ module "profiles" { source = "../modules/profiles" matchbox_http_endpoint = "http://matchbox.example.com:8080" - coreos_version = "1298.7.0" + container_linux_version = "1298.7.0" + container_linux_channel = "stable" } -// Install CoreOS to disk before provisioning +// Install Container Linux to disk before provisioning resource "matchbox_group" "default" { name = "default" - profile = "${module.profiles.coreos-install}" + profile = "${module.profiles.cached-container-linux-install}" // No selector, matches all nodes metadata { - coreos_channel = "stable" - coreos_version = "1298.7.0" + container_linux_channel = "stable" + container_linux_version = "1298.7.0" ignition_endpoint = "http://matchbox.example.com:8080/ignition" baseurl = "http://matchbox.example.com:8080/assets/coreos" ssh_authorized_key = "${var.ssh_authorized_key}" @@ -67,4 +68,3 @@ resource "matchbox_group" "node3" { ssh_authorized_key = "${var.ssh_authorized_key}" } } - diff --git a/examples/terraform/etcd3-install/etcd3.tf b/examples/terraform/etcd3-install/etcd3.tf index 76865836..a04aa305 100644 --- a/examples/terraform/etcd3-install/etcd3.tf +++ b/examples/terraform/etcd3-install/etcd3.tf @@ -2,17 +2,18 @@ module "profiles" { source = "../modules/profiles" matchbox_http_endpoint = "http://matchbox.example.com:8080" - coreos_version = "1298.7.0" + container_linux_version = "1298.7.0" + container_linux_channel = "stable" } -// Install CoreOS to disk before provisioning +// Install Container Linux to disk before provisioning resource "matchbox_group" "default" { name = "default" - profile = "${module.profiles.coreos-install}" + profile = "${module.profiles.cached-container-linux-install}" // No selector, matches all nodes metadata { - coreos_channel = "stable" - coreos_version = "1298.7.0" + container_linux_channel = "stable" + container_linux_version = "1298.7.0" ignition_endpoint = "http://matchbox.example.com:8080/ignition" baseurl = "http://matchbox.example.com:8080/assets/coreos" ssh_authorized_key = "${var.ssh_authorized_key}" diff --git a/examples/terraform/modules/profiles/cl/coreos-install.yaml.tmpl b/examples/terraform/modules/profiles/cl/container-linux-install.yaml.tmpl similarity index 80% rename from examples/terraform/modules/profiles/cl/coreos-install.yaml.tmpl rename to examples/terraform/modules/profiles/cl/container-linux-install.yaml.tmpl index 815c26de..0843515d 100644 --- a/examples/terraform/modules/profiles/cl/coreos-install.yaml.tmpl +++ b/examples/terraform/modules/profiles/cl/container-linux-install.yaml.tmpl @@ -21,7 +21,7 @@ storage: inline: | #!/bin/bash -ex curl "{{.ignition_endpoint}}?{{.request.raw_query}}&os=installed" -o ignition.json - coreos-install -d /dev/sda -C {{.coreos_channel}} -V {{.coreos_version}} -i ignition.json {{if index . "baseurl"}}-b {{.baseurl}}{{end}} + coreos-install -d /dev/sda -C {{.container_linux_channel}} -V {{.container_linux_version}} -i ignition.json {{if index . "baseurl"}}-b {{.baseurl}}{{end}} udevadm settle systemctl reboot passwd: @@ -29,3 +29,4 @@ passwd: - name: core ssh_authorized_keys: - {{.ssh_authorized_key}} + diff --git a/examples/terraform/modules/profiles/outputs.tf b/examples/terraform/modules/profiles/outputs.tf index c6e5d749..4c00256e 100644 --- a/examples/terraform/modules/profiles/outputs.tf +++ b/examples/terraform/modules/profiles/outputs.tf @@ -1,5 +1,9 @@ -output "coreos-install" { - value = "${matchbox_profile.coreos-install.name}" +output "container-linux-install" { + value = "${matchbox_profile.container-linux-install.name}" +} + +output "cached-container-linux-install" { + value = "${matchbox_profile.cached-container-linux-install.name}" } output "etcd3" { diff --git a/examples/terraform/modules/profiles/profiles.tf b/examples/terraform/modules/profiles/profiles.tf index 7ee27056..c323cc35 100644 --- a/examples/terraform/modules/profiles/profiles.tf +++ b/examples/terraform/modules/profiles/profiles.tf @@ -1,17 +1,39 @@ -// CoreOS Install Profile -resource "matchbox_profile" "coreos-install" { - name = "coreos-install" - kernel = "/assets/coreos/${var.coreos_version}/coreos_production_pxe.vmlinuz" +// Container Linux Install profile (from release.core-os.net) +resource "matchbox_profile" "container-linux-install" { + name = "container-linux-install" + kernel = "http://${var.container_linux_channel}.release.core-os.net/amd64-usr/${var.container_linux_version}/coreos_production_pxe.vmlinuz" + initrd = [ - "/assets/coreos/${var.coreos_version}/coreos_production_pxe_image.cpio.gz" + "http://${var.container_linux_channel}.release.core-os.net/amd64-usr/${var.container_linux_version}/coreos_production_pxe_image.cpio.gz", ] + args = [ "coreos.config.url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}", "coreos.first_boot=yes", "console=tty0", - "console=ttyS0" + "console=ttyS0", ] - container_linux_config = "${file("${path.module}/cl/coreos-install.yaml.tmpl")}" + + container_linux_config = "${file("${path.module}/cl/container-linux-install.yaml.tmpl")}" +} + +// Container Linux Install profile (from matchbox /assets cache) +// Note: Admin must have downloaded container_linux_version into matchbox assets. +resource "matchbox_profile" "cached-container-linux-install" { + name = "cached-container-linux-install" + kernel = "/assets/coreos/${var.container_linux_version}/coreos_production_pxe.vmlinuz" + initrd = [ + "/assets/coreos/${var.container_linux_version}/coreos_production_pxe_image.cpio.gz", + ] + + args = [ + "coreos.config.url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}", + "coreos.first_boot=yes", + "console=tty0", + "console=ttyS0", + ] + + container_linux_config = "${file("${path.module}/cl/container-linux-install.yaml.tmpl")}" } // etcd3 profile diff --git a/examples/terraform/modules/profiles/variables.tf b/examples/terraform/modules/profiles/variables.tf index a9ba59b8..c01489e4 100644 --- a/examples/terraform/modules/profiles/variables.tf +++ b/examples/terraform/modules/profiles/variables.tf @@ -3,7 +3,12 @@ variable "matchbox_http_endpoint" { description = "Matchbox HTTP read-only endpoint (e.g. http://matchbox.example.com:8080)" } -variable "coreos_version" { - type = "string" - description = "CoreOS kernel/initrd version to PXE boot. Must be present in matchbox assets." +variable "container_linux_version" { + type = "string" + description = "Container Linux version of the kernel/initrd to PXE or the image to install" +} + +variable "container_linux_channel" { + type = "string" + description = "Container Linux channel corresponding to the container_linux_version" }