Last active
July 7, 2025 19:54
-
-
Save shantur/166f22c58cdc68e801a054b135b56129 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| sudo mkdir -p /etc/rancher/k3s/ | |
| nodeLabels="" | |
| nvmeDisks=$(lsblk | grep sda) | |
| [[ -n $nvmeDisks ]] && nodeLabels="--node-label storageNode=true" | |
| hostname=$(hostname) | |
| nodeRole="agent --token manag3m3ntClust3r" | |
| if [[ "$hostname" =~ inode[1-3] ]] | |
| then | |
| nodeRole="server " | |
| sudo cat << EOF | sudo tee /etc/rancher/k3s/config.yaml | |
| write-kubeconfig-mode: "0644" | |
| tls-san: | |
| - "k.m.lab.rathore.me" | |
| - "k8s.default.lab.rathore.me" | |
| disable: | |
| - servicelb | |
| - local-storage | |
| - traefik | |
| - metrics-server | |
| token: manag3m3ntClust3r | |
| disable-network-policy: true | |
| disable-kube-proxy: true | |
| disable-cloud-controller: true | |
| flannel-backend: none | |
| EOF | |
| fi | |
| [ "$hostname" == "inode1" ] && curl -sfL https://get.k3s.io | sh -s - --cluster-init $nodeLabels | |
| [ "$hostname" != "inode1" ] && curl -sfL https://get.k3s.io | sh -s - $nodeRole --server "https://inode1:6443" $nodeLabels |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment