From 5fc606103caf2a6b8d375b01e12305261f82f5ee Mon Sep 17 00:00:00 2001 From: nxtcoder17 Date: Sun, 28 Jul 2024 10:46:40 +0530 Subject: [PATCH] feat: disabling systemd-resolved on k8s nodes - we are exposing our own DNS server, which needs to be exposed on port 53/udp to work --- terraform/modules/gcp/machine/main.tf | 1 - .../kloudlite/k3s/k3s-templates/k3s-agent-setup.sh.tpl | 8 ++++---- .../modules/kloudlite/k3s/k3s-templates/vm-setup.sh.tpl | 8 +++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/terraform/modules/gcp/machine/main.tf b/terraform/modules/gcp/machine/main.tf index 00a8cdb..abbee00 100644 --- a/terraform/modules/gcp/machine/main.tf +++ b/terraform/modules/gcp/machine/main.tf @@ -56,7 +56,6 @@ resource "google_compute_instance" "standard" { block-project-ssh-keys = "TRUE" enable-oslogin = "TRUE" "ssh-keys" = "ubuntu:${var.ssh_key}" - # join("\n", [for user, key in var.ssh_keys : "${user}:${key}"]) } network_interface { diff --git a/terraform/modules/kloudlite/k3s/k3s-templates/k3s-agent-setup.sh.tpl b/terraform/modules/kloudlite/k3s/k3s-templates/k3s-agent-setup.sh.tpl index 96afb9d..33c0a7c 100644 --- a/terraform/modules/kloudlite/k3s/k3s-templates/k3s-agent-setup.sh.tpl +++ b/terraform/modules/kloudlite/k3s/k3s-templates/k3s-agent-setup.sh.tpl @@ -19,9 +19,9 @@ ${jsonencode({ })} EOF2 -if [ "${tf_use_cloudflare_nameserver}" = "true" ]; then -lineNo=$(sudo cat /etc/resolv.conf -n | grep "nameserver" | awk '{print $1}') -sudo sed -i "$lineNo i nameserver 1.1.1.1" /etc/resolv.conf -fi +{{- /* if [ "${tf_use_cloudflare_nameserver}" = "true" ]; then */}} +{{- /* lineNo=$(sudo cat /etc/resolv.conf -n | grep "nameserver" | awk '{print $1}') */}} +{{- /* sudo sed -i "$lineNo i nameserver 1.1.1.1" /etc/resolv.conf */}} +{{- /* fi */}} sudo systemctl restart kloudlite-k3s.service diff --git a/terraform/modules/kloudlite/k3s/k3s-templates/vm-setup.sh.tpl b/terraform/modules/kloudlite/k3s/k3s-templates/vm-setup.sh.tpl index 7b5290d..f8e25d1 100644 --- a/terraform/modules/kloudlite/k3s/k3s-templates/vm-setup.sh.tpl +++ b/terraform/modules/kloudlite/k3s/k3s-templates/vm-setup.sh.tpl @@ -10,7 +10,7 @@ KLOUDLITE_RUNNER_DOWNLOAD_URL="${kloudlite_runner_download_url}" # LOG_FILE=$KLOUDLITE_CONFIG_DIRECTORY/execution.log debug() { - echo "[#] $*" >>"$KLOUDLITE_CONFIG_DIRECTORY/execution.log" + echo "[#] $*" >>"$KLOUDLITE_CONFIG_DIRECTORY/execution.log" } debug "ensuring $KLOUDLITE_CONFIG_DIRECTORY exists" @@ -61,4 +61,10 @@ WantedBy=multi-user.target EOF systemctl enable --now kloudlite-k3s.service + +systemctl stop systemd-resolved +systemctl disable systemd-resolved + +rm /etc/resolv.conf +echo "nameserver 1.1.1.1" >/etc/resolv.conf debug "----------------- execution finished at $(date) ----------------------"