cleanup first control plane provisioning...

* move yaml to subdirectory of /tmp
* reformat loop waiting for /readyz endpoint
* add logging message
* split provisioner because sensitive var.hcloud_token prohibits
  log output
This commit is contained in:
phaer 2022-02-11 22:47:57 +01:00
parent c46e912d3e
commit 92937f0081
2 changed files with 19 additions and 9 deletions

View File

@ -70,13 +70,13 @@ resource "hcloud_server" "first_control_plane" {
# Upload kustomization.yaml, containing Hetzner CSI & CSM, as well as kured. # Upload kustomization.yaml, containing Hetzner CSI & CSM, as well as kured.
provisioner "file" { provisioner "file" {
content = local.post_install_kustomization content = local.post_install_kustomization
destination = "/tmp/kustomization.yaml" destination = "/tmp/post_install/kustomization.yaml"
} }
# Upload traefik config # Upload traefik config
provisioner "file" { provisioner "file" {
content = local.traefik_config content = local.traefik_config
destination = "/tmp/traefik.yaml" destination = "/tmp/post_install/traefik.yaml"
} }
# Run the first control plane # Run the first control plane
@ -95,15 +95,24 @@ resource "hcloud_server" "first_control_plane" {
echo "Initiating the cluster..." echo "Initiating the cluster..."
sleep 2 sleep 2
done done
timeout 120 bash <<EOF
while [[ "$(curl -s -o /dev/null -w ''%%{http_code}'' curl -k https://localhost:6443/readyz)" != "200" ]]
do
echo "Waiting for cluster to become ready"
sleep 1
done
EOF
EOT EOT
, <<-EOT ]
timeout 120 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%%{http_code}'' curl -k https://localhost:6443/readyz)" != "200" ]]; do sleep 1; done' }
EOT
, "kubectl -n kube-system create secret generic hcloud --from-literal=token=${var.hcloud_token} --from-literal=network=${hcloud_network.k3s.name}", # Provision kubernetes resources for CSI, CCM, kured, traefik, etc
provisioner "remote-exec" {
inline = [
"kubectl -n kube-system create secret generic hcloud --from-literal=token=${var.hcloud_token} --from-literal=network=${hcloud_network.k3s.name}",
"kubectl -n kube-system create secret generic hcloud-csi --from-literal=token=${var.hcloud_token}", "kubectl -n kube-system create secret generic hcloud-csi --from-literal=token=${var.hcloud_token}",
"kubectl apply -k /tmp/", "kubectl apply -k /tmp/post_install",
"kubectl apply -f /tmp/traefik.yaml", "rm -rf /tmp/post_install"
"rm /tmp/traefik.yaml /tmp/kustomization.yaml"
] ]
} }

View File

@ -6,6 +6,7 @@ resources:
- "https://github.com/hetznercloud/hcloud-cloud-controller-manager/releases/download/${ccm_version}/ccm-networks.yaml" - "https://github.com/hetznercloud/hcloud-cloud-controller-manager/releases/download/${ccm_version}/ccm-networks.yaml"
- "https://raw.githubusercontent.com/hetznercloud/csi-driver/${csi_version}/deploy/kubernetes/hcloud-csi.yml" - "https://raw.githubusercontent.com/hetznercloud/csi-driver/${csi_version}/deploy/kubernetes/hcloud-csi.yml"
- "https://github.com/weaveworks/kured/releases/download/${kured_version}/kured-${kured_version}-dockerhub.yaml" - "https://github.com/weaveworks/kured/releases/download/${kured_version}/kured-${kured_version}-dockerhub.yaml"
- ./traefik.yaml
patchesStrategicMerge: patchesStrategicMerge:
- |- - |-