mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-16 03:19:18 +00:00
🔧 Improve mk8s Terraform configuration
- instead of using 'kubectl wait nodes', we now use a simpler 'kubectl get nodes -o name' and check if there is anything in the output. This seems to work better (as the previous method would sometimes remain stuck because the kubectl process would never get stopped by SIGPIPE). - the shpod SSH NodePort is no longer hard-coded to 32222, which allows us to use e.g. vcluster to deploy multiple Kubernetes labs on a single 'home' (or 'outer') Kubernetes cluster.
This commit is contained in:
@@ -62,7 +62,7 @@ resource "null_resource" "wait_for_nodes" {
|
||||
}
|
||||
command = <<-EOT
|
||||
while sleep 1; do
|
||||
kubectl get nodes --watch | grep --silent --line-buffered . &&
|
||||
kubectl get nodes -o name | grep --silent . &&
|
||||
kubectl wait node --for=condition=Ready --all --timeout=10m &&
|
||||
break
|
||||
done
|
||||
|
||||
@@ -90,7 +90,6 @@ resource "kubernetes_service" "shpod_${index}" {
|
||||
name = "ssh"
|
||||
port = 22
|
||||
target_port = 22
|
||||
node_port = 32222
|
||||
}
|
||||
type = "NodePort"
|
||||
}
|
||||
@@ -222,7 +221,10 @@ output "ip_addresses_of_nodes" {
|
||||
value = join("\n", [
|
||||
%{ for index, cluster in clusters ~}
|
||||
join("\t", concat(
|
||||
[ random_string.shpod_${index}.result, "ssh -l k8s -p 32222" ],
|
||||
[
|
||||
random_string.shpod_${index}.result,
|
||||
"ssh -l k8s -p $${kubernetes_service.shpod_${index}.spec[0].port[0].node_port}"
|
||||
],
|
||||
split(" ", file("./externalips.${index}"))
|
||||
)),
|
||||
%{ endfor ~}
|
||||
|
||||
Reference in New Issue
Block a user