From 07822ea3f2239cf9cd3335ad2d7fb0aab7a3e1dc Mon Sep 17 00:00:00 2001 From: makefunstuff Date: Thu, 18 Jul 2024 22:09:37 +0300 Subject: infra updates --- terraform/cloud-init.cfg | 9 +++++++ terraform/configure-k3s.sh | 22 +++++++++++++++++ terraform/main.tf | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 terraform/cloud-init.cfg create mode 100755 terraform/configure-k3s.sh create mode 100644 terraform/main.tf diff --git a/terraform/cloud-init.cfg b/terraform/cloud-init.cfg new file mode 100644 index 0000000..75fa7c7 --- /dev/null +++ b/terraform/cloud-init.cfg @@ -0,0 +1,9 @@ + +#cloud-config +hostname: k3s-node +ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAr9Y6...your-public-key... user@hostname +runcmd: + - echo "#!/bin/bash" > /usr/local/bin/k3s-install.sh + - echo "curl -sfL https://get.k3s.io | sh -" >> /usr/local/bin/k3s-install.sh + - chmod +x /usr/local/bin/k3s-install.sh diff --git a/terraform/configure-k3s.sh b/terraform/configure-k3s.sh new file mode 100755 index 0000000..76076d7 --- /dev/null +++ b/terraform/configure-k3s.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Get the IP addresses from Terraform output +MASTER_IP=$(terraform output -json k8s_node_ips | jq -r '.[0]') +WORKER_IPS=$(terraform output -json k8s_node_ips | jq -r '.[1,2]') + +# Set up the master node +ssh ubuntu@$MASTER_IP < i.network_interface[0].addresses[0] + } +} -- cgit 1.4.1-2-gfad0