Expose kubeconfig in outputs...

* To do so, we need to ensure that the generated kubeconfig is part of
  terraforms dependency graph. This has the additional benefit of not
  depending on local files anymore which should enable multi-user
  setups.

* This also means that we can't deploy CCM, CSI & Traefik from our local
  host, because we don't have kubeconfig.yaml locally while provisioning
  the control plane, only afterwards.

* So we just run kubectl apply on the control plane itself, after k3s is
  ready.

* To do so, we need to deploy all manifests. I've merged the patches
  into a single kustomization.yaml file, because that makes the
  deployment of those files to the control-plane server easier.

* we could also put the traefik config into the same kustomization file,
  which would save us one of the file provisioner blocks. I didn't want
  this PR to get any bigger, and will consider merging this config later
  on. kustomization.yaml is small enough that we could yamlencode() for
  it and store the patches in separate files again, not as
  inline-strings which is kind of ugly.
This commit is contained in:
phaer
2022-02-11 12:45:03 +01:00
parent dd69220c58
commit 9dc4952665
15 changed files with 226 additions and 226 deletions

43
main.tf
View File

@@ -144,49 +144,6 @@ resource "hcloud_firewall" "k3s" {
}
resource "local_file" "hetzner_ccm_config" {
content = templatefile("${path.module}/templates/hetzner_ccm.yaml.tpl", {
ccm_version = var.hetzner_ccm_version != null ? var.hetzner_ccm_version : data.github_release.hetzner_ccm.release_tag
patch_name = var.hetzner_ccm_containers_latest ? "patch_latest" : "patch"
})
filename = "${path.module}/hetzner/ccm/kustomization.yaml"
file_permission = "0644"
directory_permission = "0755"
}
resource "local_file" "hetzner_csi_config" {
content = templatefile("${path.module}/templates/hetzner_csi.yaml.tpl", {
csi_version = var.hetzner_csi_version != null ? var.hetzner_csi_version : data.github_release.hetzner_csi.release_tag
patch_name = var.hetzner_csi_containers_latest ? "patch_latest" : ""
})
filename = "${path.module}/hetzner/csi/kustomization.yaml"
file_permission = "0644"
directory_permission = "0755"
}
resource "local_file" "kured_config" {
content = templatefile("${path.module}/templates/kured.yaml.tpl", {
version = data.github_release.kured.release_tag
})
filename = "${path.module}/kured/kustomization.yaml"
file_permission = "0644"
directory_permission = "0755"
}
resource "local_file" "traefik_config" {
content = templatefile("${path.module}/templates/traefik_config.yaml.tpl", {
lb_disable_ipv6 = var.lb_disable_ipv6
lb_server_type = var.lb_server_type
location = var.location
traefik_acme_tls = var.traefik_acme_tls
traefik_acme_email = var.traefik_acme_email
})
filename = "${path.module}/templates/rendered/traefik_config.yaml"
file_permission = "0644"
directory_permission = "0755"
}
resource "hcloud_placement_group" "k3s" {
name = "k3s"
type = "spread"