Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix first control planed depending on kustomization_backup #916

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion control_planes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ resource "null_resource" "control_planes" {
inline = [
"systemctl start k3s 2> /dev/null",
<<-EOT
timeout 120 bash <<EOF
timeout 360 bash <<EOF
mysticaltech marked this conversation as resolved.
Show resolved Hide resolved
until systemctl status k3s > /dev/null; do
systemctl start k3s 2> /dev/null
echo "Waiting for the k3s server to start..."
Expand Down
31 changes: 1 addition & 30 deletions init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,36 +124,7 @@ resource "null_resource" "kustomization" {

# Upload kustomization.yaml, containing Hetzner CSI & CSM, as well as kured.
provisioner "file" {
content = yamlencode({
apiVersion = "kustomize.config.k8s.io/v1beta1"
kind = "Kustomization"

resources = concat(
[
"https://github.com/hetznercloud/hcloud-cloud-controller-manager/releases/download/${local.ccm_version}/ccm-networks.yaml",
"https://github.com/weaveworks/kured/releases/download/${local.kured_version}/kured-${local.kured_version}-dockerhub.yaml",
"https://raw.githubusercontent.com/rancher/system-upgrade-controller/master/manifests/system-upgrade-controller.yaml",
],
var.disable_hetzner_csi ? [] : [
"hcloud-csi.yml"
],
lookup(local.ingress_controller_install_resources, local.ingress_controller, []),
lookup(local.cni_install_resources, var.cni_plugin, []),
var.enable_longhorn ? ["longhorn.yaml"] : [],
var.enable_csi_driver_smb ? ["csi-driver-smb.yaml"] : [],
var.enable_cert_manager || var.enable_rancher ? ["cert_manager.yaml"] : [],
var.enable_rancher ? ["rancher.yaml"] : [],
var.rancher_registration_manifest_url != "" ? [var.rancher_registration_manifest_url] : []
),
patchesStrategicMerge = concat(
[
file("${path.module}/kustomize/system-upgrade-controller.yaml"),
"kured.yaml",
"ccm.yaml",
],
lookup(local.cni_install_resource_patches, var.cni_plugin, [])
)
})
content = local.kustomization_backup_yaml
destination = "/var/post_install/kustomization.yaml"
}

Expand Down
15 changes: 1 addition & 14 deletions kustomization_backup.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
data "remote_file" "kustomization_backup" {
conn {
host = module.control_planes[keys(module.control_planes)[0]].ipv4_address
port = var.ssh_port
user = "root"
private_key = var.ssh_private_key
agent = var.ssh_private_key == null
}
path = "/var/post_install/kustomization.yaml"

depends_on = [null_resource.kustomization]
mysticaltech marked this conversation as resolved.
Show resolved Hide resolved
}

resource "local_file" "kustomization_backup" {
count = var.create_kustomization ? 1 : 0
content = data.remote_file.kustomization_backup.content
content = local.kustomization_backup_yaml
filename = "${var.cluster_name}_kustomization_backup.yaml"
file_permission = "600"
mysticaltech marked this conversation as resolved.
Show resolved Hide resolved
}
30 changes: 30 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,36 @@ locals {
["timeout 180s /bin/sh -c 'while ! ping -c 1 ${var.address_for_connectivity_test} >/dev/null 2>&1; do echo \"Ready for k3s installation, waiting for a successful connection to the internet...\"; sleep 5; done; echo Connected'"]
)

kustomization_backup_yaml = yamlencode({
apiVersion = "kustomize.config.k8s.io/v1beta1"
kind = "Kustomization"

resources = concat(
[
"https://github.com/hetznercloud/hcloud-cloud-controller-manager/releases/download/${local.ccm_version}/ccm-networks.yaml",
"https://github.com/weaveworks/kured/releases/download/${local.kured_version}/kured-${local.kured_version}-dockerhub.yaml",
"https://raw.githubusercontent.com/rancher/system-upgrade-controller/master/manifests/system-upgrade-controller.yaml",
],
var.disable_hetzner_csi ? [] : [
"hcloud-csi.yml"
],
lookup(local.ingress_controller_install_resources, local.ingress_controller, []),
lookup(local.cni_install_resources, var.cni_plugin, []),
var.enable_longhorn ? ["longhorn.yaml"] : [],
var.enable_csi_driver_smb ? ["csi-driver-smb.yaml"] : [],
var.enable_cert_manager || var.enable_rancher ? ["cert_manager.yaml"] : [],
var.enable_rancher ? ["rancher.yaml"] : [],
var.rancher_registration_manifest_url != "" ? [var.rancher_registration_manifest_url] : []
),
patchesStrategicMerge = concat(
[
file("${path.module}/kustomize/system-upgrade-controller.yaml"),
"kured.yaml",
"ccm.yaml",
],
lookup(local.cni_install_resource_patches, var.cni_plugin, [])
)
})

apply_k3s_selinux = ["/sbin/semodule -v -i /usr/share/selinux/packages/k3s.pp"]

Expand Down