From ad65e6f67419ce899e39852a7874eb63a78f43f5 Mon Sep 17 00:00:00 2001 From: GigiaJ Date: Sun, 24 Aug 2025 23:32:44 -0500 Subject: [PATCH] Add nodeport --- iac/src/js/core.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/iac/src/js/core.js b/iac/src/js/core.js index f64ca3d..43ffc2b 100644 --- a/iac/src/js/core.js +++ b/iac/src/js/core.js @@ -11,11 +11,34 @@ exports.createCluster = function() { const sshKeyName = config.require("sshKeyName"); const privateKey = config.requireSecret("privateKeySsh"); - const installMasterScript = (publicIp) => ` + const installMasterScript = (publicIp) => ` + # Create the directory for custom manifests if it doesn't exist + mkdir -p /var/lib/rancher/k3s/server/manifests + + # Create the Traefik configuration file to use NodePort + cat < /var/lib/rancher/k3s/server/manifests/traefik-config.yaml +apiVersion: helm.cattle.io/v1 +kind: HelmChartConfig +metadata: + name: traefik + namespace: kube-system +spec: + valuesContent: |- + service: + spec: + type: NodePort + ports: + web: + nodePort: 30080 + websecure: + nodePort: 30443 +EOF + # Install k3s if it's not already present. if ! command -v k3s >/dev/null; then curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--flannel-backend=wireguard-native --node-external-ip=${publicIp}" sh - fi + # Wait until the kubeconfig is readable and a kubectl command succeeds. until sudo k3s kubectl get node > /dev/null 2>&1; do echo "Waiting for master node to be ready..."