diff --git a/k8s/kubeadm_config.yaml b/k8s/kubeadm_config.yaml index da2bd3e..dadec95 100644 --- a/k8s/kubeadm_config.yaml +++ b/k8s/kubeadm_config.yaml @@ -39,3 +39,4 @@ networking: dnsDomain: cluster.local podSubnet: ${pod_cidr} scheduler: {} + diff --git a/k8s/main.tf b/k8s/main.tf index 80c87a0..d479798 100644 --- a/k8s/main.tf +++ b/k8s/main.tf @@ -24,6 +24,21 @@ resource "null_resource" "k8s" { private_key = file(format("/home/%s/.ssh/id_rsa", var.ssh_user)) } + provisioner "local-exec" { + # Loop through the list of IP addresses and ping each one. + command = <<-EOT + for ip in "${join("\" \"", var.node_list)}"; do + until ping -c1 -W 1 "$ip"; do sleep 5; done + done + EOT + } + + provisioner "remote-exec" { + inline = [ + "cloud-init status --wait" + ] + } + provisioner "file" { content = templatefile("${path.module}/kubeadm_config.yaml", { diff --git a/k8s/master.sh b/k8s/master.sh index 3ccfcd8..f427260 100644 --- a/k8s/master.sh +++ b/k8s/master.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -xe # Initialize the Kubernetes cluster with the provided configuration file sudo kubeadm init --config /tmp/kubeadm_config.yaml diff --git a/k8s/node.sh b/k8s/node.sh index 1dc150a..eb08e10 100644 --- a/k8s/node.sh +++ b/k8s/node.sh @@ -39,9 +39,9 @@ function wait_for_api_server() { if ! grep -qa container=lxc /proc/1/environ; then enable_ip_forwarding - set_huge_pages "${nr_hugepages}" - sudo apt-get -y install linux-modules-extra-$(uname -r) - add_kernel_modules nvme-tcp nvmet + #set_huge_pages "${nr_hugepages}" + #sudo apt-get -y install linux-modules-extra-$(uname -r) + #add_kernel_modules nvme-tcp nvmet fi wait_for_api_server "${master_ip}" "${token}" diff --git a/k8s/repo.sh b/k8s/repo.sh index 686201d..aa60893 100644 --- a/k8s/repo.sh +++ b/k8s/repo.sh @@ -1,4 +1,5 @@ #!/bin/bash + set -x curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/docker.gpg --yes @@ -38,6 +39,16 @@ sudo sysctl --system sudo mkdir -p /etc/containerd sudo containerd config default | sudo tee /etc/containerd/config.toml + +# add registry +# +cat << EOF | sudo tee -a /etc/containerd/config.toml +[plugins."io.containerd.grpc.v1.cri".registry.mirrors."192.168.1.4:5000"] +endpoint = ["http://192.168.1.4:5000"] +[plugins."io.containerd.grpc.v1.cri".registry.configs."192.168.1.4:5000"] +insecure = true +EOF + # ensure reboot does not take forever sudo mkdir -p /etc/systemd/system/containerd.service.d sudo tee /etc/systemd/system/containerd.service.d/override.conf >/dev/null <