From 9037d7311b949439b217cd9c657d4500eab3e16b Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Sat, 17 Oct 2020 14:53:44 -0700 Subject: [PATCH] Remove asset_dir variable and optional asset writes * Originally, generated TLS certificates, manifests, and cluster "assets" written to local disk (`asset_dir`) during terraform apply cluster bootstrap * Typhoon v1.17.0 introduced bootstrapping using only Terraform state to store cluster assets, to avoid ever writing sensitive materials to disk and improve automated use-cases. `asset_dir` was changed to optional and defaulted to "" (no writes) * Typhoon v1.18.0 deprecated the `asset_dir` variable, removed docs, and announced it would be deleted in future. * Remove the `asset_dir` variable Cluster assets are now stored in Terraform state only. For those who wish to write those assets to local files, this is possible doing so explicitly. ``` resource local_file "assets" { for_each = module.bootstrap.assets_dist filename = "some-assets/${each.key}" content = each.value } ``` Related: * https://github.com/poseidon/typhoon/pull/595 * https://github.com/poseidon/typhoon/pull/678 --- README.md | 12 +++++-- auth.tf | 15 -------- conditional.tf | 23 ------------ manifests.tf | 16 --------- tls-aggregation.tf | 30 ---------------- tls-etcd.tf | 88 ---------------------------------------------- tls-k8s.tf | 56 ----------------------------- variables.tf | 6 ---- versions.tf | 1 - 9 files changed, 10 insertions(+), 237 deletions(-) diff --git a/README.md b/README.md index 56fc3ec..85a13b3 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ module "bootstrap" { } ``` -Generate the assets. +Generate assets in Terraform state. ```sh terraform init @@ -28,5 +28,13 @@ terraform plan terraform apply ``` -Find bootstrap assets rendered to the `asset_dir` path. That's it. +To inspect and write assets locally (e.g. debugging) use the `assets_dist` Terraform output. + +``` +resource local_file "assets" { + for_each = module.bootstrap.assets_dist + filename = "some-assets/${each.key}" + content = each.value +} +``` diff --git a/auth.tf b/auth.tf index fdbf111..557b7fc 100644 --- a/auth.tf +++ b/auth.tf @@ -45,18 +45,3 @@ data "template_file" "kubeconfig-admin" { } } -# Generated admin kubeconfig to bootstrap control plane -resource "local_file" "kubeconfig-admin" { - count = var.asset_dir == "" ? 0 : 1 - - content = data.template_file.kubeconfig-admin.rendered - filename = "${var.asset_dir}/auth/kubeconfig" -} - -# Generated admin kubeconfig in a file named after the cluster -resource "local_file" "kubeconfig-admin-named" { - count = var.asset_dir == "" ? 0 : 1 - - content = data.template_file.kubeconfig-admin.rendered - filename = "${var.asset_dir}/auth/${var.cluster_name}-config" -} diff --git a/conditional.tf b/conditional.tf index fc05a9a..9ccfad9 100644 --- a/conditional.tf +++ b/conditional.tf @@ -57,26 +57,3 @@ locals { } } -# flannel manifests -resource "local_file" "flannel-manifests" { - for_each = var.asset_dir == "" ? {} : local.flannel_manifests - - filename = "${var.asset_dir}/${each.key}" - content = each.value -} - -# Calico manifests -resource "local_file" "calico-manifests" { - for_each = var.asset_dir == "" ? {} : local.calico_manifests - - filename = "${var.asset_dir}/${each.key}" - content = each.value -} - -# Cilium manifests -resource "local_file" "cilium-manifests" { - for_each = var.asset_dir == "" ? {} : local.cilium_manifests - - filename = "${var.asset_dir}/${each.key}" - content = each.value -} diff --git a/manifests.tf b/manifests.tf index 0043f82..e4c659a 100644 --- a/manifests.tf +++ b/manifests.tf @@ -43,22 +43,6 @@ locals { } } -# Kubernetes static pod manifests -resource "local_file" "static-manifests" { - for_each = var.asset_dir == "" ? {} : local.static_manifests - - content = each.value - filename = "${var.asset_dir}/${each.key}" -} - -# Kubernetes control plane manifests -resource "local_file" "manifests" { - for_each = var.asset_dir == "" ? {} : local.manifests - - content = each.value - filename = "${var.asset_dir}/${each.key}" -} - locals { aggregation_flags = <