Repository: akash-network/provider-playbooks
Pull request #40: feat: k3s option when building provider
Author: login: Zblocker64
Created: 2025-04-23T19:51:40Z | Merged: 2025-04-25T16:53:08Z

Adds k3s playbook to script


Diff:
diff --git a/playbooks.yml b/playbooks.yml
index 2106115..042fdc5 100644
--- a/playbooks.yml
+++ b/playbooks.yml
@@ -1,9 +1,13 @@
 ---
 - name: k3s Playbook
-  hosts: "{{ host }}"
+  hosts: all
   become: true
   become_user: root
   serial: "{{ serial_hosts | default(1) }}"
+  pre_tasks:
+    - name: Set node role
+      ansible.builtin.set_fact:
+        is_control_plane: "{{ inventory_hostname in groups['kube_control_plane'] }}"
   roles:
     - k3s
   tags:
diff --git a/roles/gpu/tasks/main.yml b/roles/gpu/tasks/main.yml
index b5acdc0..cd2f920 100644
--- a/roles/gpu/tasks/main.yml
+++ b/roles/gpu/tasks/main.yml
@@ -15,6 +15,23 @@
     msg: "No NVIDIA GPU detected on this node. Skipping GPU tasks."
   when: not has_gpu
 
+- name: Check current Helm version (if any)
+  ansible.builtin.command: helm version --short
+  register: helm_version
+  failed_when: false
+
+- name: Download Helm install script
+  ansible.builtin.get_url:
+    url: https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
+    dest: /tmp/get_helm.sh
+    mode: '0755'
+
+- name: Run Helm install script for v3.17.3
+  environment:
+    HELM_INSTALL_VERSION: "v3.17.3"
+  ansible.builtin.command: /tmp/get_helm.sh
+  when: helm_version.stdout is not defined or 'v3.17.3' not in helm_version.stdout
+
 - name: Include GPU tasks only if GPU is present
   ansible.builtin.include_tasks: apt_update.yml
   when: has_gpu
diff --git a/roles/gpu/tasks/nvdp.yml b/roles/gpu/tasks/nvdp.yml
index bfb09f3..cff151b 100644
--- a/roles/gpu/tasks/nvdp.yml
+++ b/roles/gpu/tasks/nvdp.yml
@@ -1,4 +1,27 @@
 ---
+- name: Check current Helm version (if any)
+  ansible.builtin.command: helm version --short
+  register: helm_version
+  failed_when: false
+  delegate_to: node1
+  run_once: true
+
+- name: Download Helm install script
+  ansible.builtin.get_url:
+    url: https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
+    dest: /tmp/get_helm.sh
+    mode: '0755'
+  delegate_to: node1
+  run_once: true
+
+- name: Run Helm install script for v3.17.3
+  environment:
+    HELM_INSTALL_VERSION: "v3.17.3"
+  ansible.builtin.command: /tmp/get_helm.sh
+  when: helm_version.stdout is not defined or 'v3.17.3' not in helm_version.stdout
+  delegate_to: node1
+  run_once: true
+
 - name: Create installation directory on control plane
   ansible.builtin.file:
     path: "{{ install_dir }}"
@@ -6,7 +29,6 @@
     mode: '0755'
   delegate_to: node1
   run_once: true
-  when: inventory_hostname != 'node1'
 
 - name: Create NVIDIA RuntimeClass manifest on control plane
   ansible.builtin.copy:
@@ -14,7 +36,6 @@
     dest: "{{ install_dir }}/nvidia-runtime-class.yml"
   delegate_to: node1
   run_once: true
-  when: inventory_hostname != 'node1'
 
 - name: Apply NVIDIA RuntimeClass from control plane
   kubernetes.core.k8s:
@@ -22,7 +43,6 @@
     src: "{{ install_dir }}/nvidia-runtime-class.yml"
   delegate_to: node1
   run_once: true
-  when: inventory_hostname != 'node1'
 
 - name: Label GPU nodes for NVIDIA support
   kubernetes.core.k8s:
diff --git a/roles/k3s/defaults/main.yml b/roles/k3s/defaults/main.yml
index 44c868b..3ec2e70 100644
--- a/roles/k3s/defaults/main.yml
+++ b/roles/k3s/defaults/main.yml
@@ -8,4 +8,4 @@ k3s_data_dir: "/data/k3s"
 calico_version: "v3.29.3"
 calico_manifest_url: "https://raw.githubusercontent.com/projectcalico/calico/refs/tags/{{ calico_version }}/manifests/calico.yaml"
 scheduler_config_path: "{{ k3s_data_dir }}/server/etc/scheduler-config.yaml"
-tls_san: "{{ groups['control_plane'][0] }}"
+tls_san: "{{ hostvars[groups['kube_control_plane'][0]]['internal_ip'] }}"
diff --git a/roles/k3s/tasks/k3s-master.yml b/roles/k3s/tasks/k3s-master.yml
index fcfddbe..0d28be7 100644
--- a/roles/k3s/tasks/k3s-master.yml
+++ b/roles/k3s/tasks/k3s-master.yml
@@ -29,13 +29,13 @@
   ansible.builtin.stat:
     path: "{{ k3s_data_dir }}/server/token"
   register: token_file
-  delegate_to: "{{ groups['control_plane'][0] }}"
+  delegate_to: "{{ groups['kube_control_plane'][0] }}"
   run_once: true
   failed_when: false
 
 - name: Set is_first_master fact
   ansible.builtin.set_fact:
-    is_first_master: "{{ inventory_hostname == groups['control_plane'][0] or token_file.stat is not defined or not token_file.stat.exists }}"
+    is_first_master: "{{ inventory_hostname == groups['kube_control_plane'][0] or token_file.stat is not defined or not token_file.stat.exists }}"
 
 - name: Debug node role
   ansible.builtin.debug:
@@ -45,7 +45,7 @@
   ansible.builtin.slurp:
     src: "{{ k3s_data_dir }}/server/token"
   register: k3s_token_b64
-  delegate_to: "{{ groups['control_plane'][0] }}"
+  delegate_to: "{{ groups['kube_control_plane'][0] }}"
   run_once: true
   when: not is_first_master and token_file.stat is defined and token_file.stat.exists
   failed_when: false
@@ -57,12 +57,12 @@
 
 - name: Show all IPv4 addresses
   ansible.builtin.set_fact:
-    master_ip: "{{ groups['control_plane'][0] }}"
+    master_ip: "{{ hostvars[groups['kube_control_plane'][0]]['internal_ip'] }}"
   when: not is_first_master
 
 - name: Set install exec parameters for additional control plane
   ansible.builtin.set_fact:
-    install_exec: "--node-ip={{ internal_ip }} {{ tls_san_arg }}"
+    install_exec: "--node-ip={{ internal_ip }} --node-name={{ inventory_hostname }} {{ tls_san_arg }}"
   when: not is_first_master
 
 - name: Add external IP if provided
@@ -85,7 +85,8 @@
     INSTALL_K3S_CHANNEL={{ k3s_version_channel }}
     INSTALL_K3S_EXEC='server {{ k3s_common_args }}
     {{ cluster_init }}
-    --node-ip={{ internal_ip }}
+    --node-ip={{ hostvars[inventory_hostname].internal_ip }}
+    --node-name={{ inventory_hostname }}
     {{ tls_san_arg }}
     {{ nodefs_dir }}
     {{ imagefs_dir }}
@@ -95,11 +96,12 @@
     INSTALL_K3S_CHANNEL={{ latestk3s | default(false) | ternary('latest', k3s_version_channel) }}
     INSTALL_K3S_EXEC='server {{ k3s_common_args }}
     --node-ip={{ internal_ip }}
+    --node-name={{ inventory_hostname }}
     {% if external_ip is defined and external_ip != '' %}--node-external-ip={{ external_ip }}{% endif %}
     {{ nodefs_dir }}
     {{ imagefs_dir }}
     {{ scheduler_config }}'
-    K3S_URL="https://{{ groups['control_plane'][0] | default(master_ip) }}:6443"
+    K3S_URL="https://{{ master_ip }}:6443"
     K3S_TOKEN="{{ k3s_token | default(token) }}" sh -"
     {% endif %}
   args:
@@ -122,3 +124,4 @@
     owner: "{{ ansible_user }}"
     group: "{{ ansible_user }}"
     mode: '0755'
+  when: is_first_master
\ No newline at end of file
diff --git a/roles/k3s/tasks/k3s-worker.yml b/roles/k3s/tasks/k3s-worker.yml
index 9550815..05c2b24 100644
--- a/roles/k3s/tasks/k3s-worker.yml
+++ b/roles/k3s/tasks/k3s-worker.yml
@@ -14,7 +14,7 @@
   ansible.builtin.slurp:
     src: "{{ k3s_data_dir }}/server/token"
   register: k3s_token_b64
-  delegate_to: "{{ groups['control_plane'][0] }}"  # Runs on first master node
+  delegate_to: "{{ groups['kube_control_plane'][0] }}"  # Runs on first master node
   run_once: true                           # Only needs to run once  
 
 - name: Set token as variable
@@ -23,7 +23,7 @@
 
 - name: Show all IPv4 addresses
   ansible.builtin.set_fact:
-    master_ip: "{{ groups['control_plane'][0] }}"
+    master_ip: "{{ hostvars[groups['kube_control_plane'][0]]['ansible_host'] }}"
 
 - name: Verify required variables are set
   ansible.builtin.fail:
@@ -44,6 +44,7 @@
     K3S_TOKEN={{ k3s_token }}
     K3S_DATA_DIR="{{ k3s_data_dir }}"
     K3S_KUBELET_ARG="--root-dir={{ kubelet_root_dir }}"
+    INSTALL_K3S_EXEC='agent --node-name={{ inventory_hostname }}'
     sh -"
   args:
     creates: /usr/local/bin/k3s
diff --git a/roles/k3s/tasks/main.yml b/roles/k3s/tasks/main.yml
index 2d76e73..af7d920 100644
--- a/roles/k3s/tasks/main.yml
+++ b/roles/k3s/tasks/main.yml
@@ -1,16 +1,22 @@
 ---
+- name: Import K3s installation tasks
+  ansible.builtin.include_tasks: "{{ 'k3s-master.yml' if is_control_plane else 'k3s-worker.yml' }}"
+  vars:
+    k3s_control_plane: "{{ groups['kube_control_plane'] | map('extract', hostvars, 'ansible_host') | list }}"
+    k3s_workers: "{{ groups['kube_node'] | map('extract', hostvars, 'ansible_host') | list }}"
+
 - name: import K3s installation tasks
   ansible.builtin.import_tasks: prechecks.yml
-  when: inventory_hostname in groups['control_plane']
+  when: inventory_hostname in groups['kube_control_plane']
 
 - name: import K3s installation tasks
   ansible.builtin.import_tasks: k3s-master.yml
-  when: inventory_hostname in groups['control_plane']
+  when: inventory_hostname in groups['kube_control_plane']
 
 - name: import Calico installation tasks
   ansible.builtin.import_tasks: calico.yml
-  when: inventory_hostname in groups['control_plane'][0]
+  when: inventory_hostname == groups['kube_control_plane'][0]
 
 - name: import K3s Worker tasks
   ansible.builtin.import_tasks: k3s-worker.yml
-  when: inventory_hostname in groups['workers']
+  when: not is_control_plane
diff --git a/roles/k3s/tasks/prechecks.yml b/roles/k3s/tasks/prechecks.yml
index dde632c..66aabb9 100644
--- a/roles/k3s/tasks/prechecks.yml
+++ b/roles/k3s/tasks/prechecks.yml
@@ -1,3 +1,7 @@
+- name: Set internal_ip from inventory
+  ansible.builtin.set_fact:
+    internal_ip: "{{ ansible_host }}"
+
 - name: Extract first two octets of the internal network
   ansible.builtin.set_fact:
     internal_network: "{{ internal_ip.split('/')[0].split('.')[:2] | join('.') }}"
@@ -19,5 +23,5 @@
   
 - name: Fail if the specific IP is not found
   ansible.builtin.fail:
-    msg: "The required IP address {{ internal_ip }} was not found on this host.Please enter the right Internal IP"
+    msg: "The required IP address {{ internal_ip }} was not found on this host. Please enter the right Internal IP"
   when: not ip_exists
diff --git a/roles/rook-ceph/defaults/main.yaml b/roles/rook-ceph/defaults/main.yaml
index 7ccade6..81c0bed 100644
--- a/roles/rook-ceph/defaults/main.yaml
+++ b/roles/rook-ceph/defaults/main.yaml
@@ -16,4 +16,4 @@ zfs_for_ephemeral: "false"
 kubelet_dir_path: "/data/kubelet"
 
 # Node configuration (will be set by setup_provider.sh)
-storage_nodes: []
+storage_nodes: []
\ No newline at end of file
diff --git a/roles/tailscale/defaults/main.yml b/roles/tailscale/defaults/main.yml
index 663abe3..3a7c679 100644
--- a/roles/tailscale/defaults/main.yml
+++ b/roles/tailscale/defaults/main.yml
@@ -32,4 +32,4 @@ tailscale_service: tailscaled
 tailscale_statefile_name: ".ocl-tailscale"
 tailscale_apt_keyring_path: /usr/share/keyrings/tailscale-archive-keyring.gpg
 tailscale_apt_repo: deb [signed-by={{ tailscale_apt_keyring_path }}] https://pkgs.tailscale.com/{{ tailscale_release | lower }}/{{ tailscale_distro | lower }} {{ ansible_distribution_release | lower }} main
-tailscale_apt_signkey: https://pkgs.tailscale.com/{{ tailscale_release | lower }}/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}.noarmor.gpg
+tailscale_apt_signkey: https://pkgs.tailscale.com/{{ tailscale_release | lower }}/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}.noarmor.gpg
\ No newline at end of file
diff --git a/scripts/setup_provider.sh b/scripts/setup_provider.sh
index b1a9fc6..0401f94 100755
--- a/scripts/setup_provider.sh
+++ b/scripts/setup_provider.sh
@@ -129,7 +129,9 @@ display_welcome() {
 # Function to select playbooks to run
 select_playbooks() {
     # Initialize selected playbooks
-    SELECTED_KUBESPRAY=true  # Default to true for all playbooks
+    SELECTED_KUBERNETES=false  # New variable to track if Kubernetes is selected
+    SELECTED_KUBESPRAY=false   # Changed from true to false
+    SELECTED_K3S=false         # New variable for K3s
     SELECTED_OS=true
     SELECTED_GPU=true
     SELECTED_PROVIDER=true
@@ -137,7 +139,9 @@ select_playbooks() {
     SELECTED_ROOK_CEPH=false  # New variable for Rook-Ceph
     
     # Define playbook explanations
-    KUBESPRAY_DESC="Kubernetes installation using Kubespray (required for a new cluster)"
+    KUBERNETES_DESC="Kubernetes installation (required for a new cluster)"
+    K8S_DESC="Kubernetes installation using Kubespray (production-grade, full-featured)"
+    K3S_DESC="Kubernetes installation using K3s (lightweight, single binary, ideal for edge/IoT)"
     OS_DESC="Basic OS configuration and optimizations"
     GPU_DESC="Are there GPU nodes in the cluster?"
     PROVIDER_DESC="Akash Provider service installation and configuration"
@@ -149,17 +153,34 @@ select_playbooks() {
     echo -e "${YELLOW}Select which playbooks you want to run:${NC}"
     echo
     
-    # Kubespray
+    # Kubernetes Installation
     while true; do
-        echo -n -e "${BLUE}[?]${NC} Run Kubespray for Kubernetes installation? (Recommended for new setup) [y/n]: "
+        echo -n -e "${BLUE}[?]${NC} Install Kubernetes? (Required for new setup) [y/n]: "
         read -r response
         case $response in
-            [Yy]* ) SELECTED_KUBESPRAY=true; break;;
-            [Nn]* ) SELECTED_KUBESPRAY=false; break;;
+            [Yy]* ) SELECTED_KUBERNETES=true; break;;
+            [Nn]* ) SELECTED_KUBERNETES=false; break;;
             * ) echo "Please answer y or n.";;
         esac
     done
     
+    if $SELECTED_KUBERNETES; then
+        # Choose between K8s and K3s
+        echo -e "\n${YELLOW}Choose your Kubernetes distribution:${NC}"
+        echo -e "${BLUE}[1]${NC} K8s (Kubespray) - Production-grade, full-featured Kubernetes"
+        echo -e "${BLUE}[2]${NC} K3s - Lightweight, single binary, ideal for edge/IoT"
+        echo
+        while true; do
+            echo -n -e "${BLUE}[?]${NC} Select distribution (1/2) [1]: "
+            read -r response
+            case $response in
+                1|"") SELECTED_KUBESPRAY=true; SELECTED_K3S=false; break;;
+                2) SELECTED_KUBESPRAY=false; SELECTED_K3S=true; break;;
+                * ) echo "Please answer 1 or 2.";;
+            esac
+        done
+    fi
+    
     # OS
     while true; do
         echo -n -e "${BLUE}[?]${NC} Run OS playbook for system optimizations? [y/n]: "
@@ -219,7 +240,15 @@ select_playbooks() {
     echo
     echo -e "${YELLOW}You have selected the following playbooks:${NC}"
     echo
-    if $SELECTED_KUBESPRAY; then print_menu_item "✓" "Kubespray - ${KUBESPRAY_DESC}"; else print_menu_item "✗" "Kubespray - ${KUBESPRAY_DESC}"; fi
+    if $SELECTED_KUBERNETES; then
+        if $SELECTED_KUBESPRAY; then
+            print_menu_item "✓" "K8s - ${K8S_DESC}"
+        else
+            print_menu_item "✓" "K3s - ${K3S_DESC}"
+        fi
+    else
+        print_menu_item "✗" "Kubernetes - ${KUBERNETES_DESC}"
+    fi
     if $SELECTED_OS; then print_menu_item "✓" "OS - ${OS_DESC}"; else print_menu_item "✗" "OS - ${OS_DESC}"; fi
     if $SELECTED_GPU; then print_menu_item "✓" "GPU - ${GPU_DESC}"; else print_menu_item "✗" "GPU - ${GPU_DESC}"; fi
     if $SELECTED_PROVIDER; then print_menu_item "✓" "Provider - ${PROVIDER_DESC}"; else print_menu_item "✗" "Provider - ${PROVIDER_DESC}"; fi
@@ -975,9 +1004,13 @@ copy_inventory() {
     cd ~/kubespray
     # Create the directory if it doesn't exist
     mkdir -p inventory/akash
-    # Copy sample inventory to the correct location
-    cp -rfp inventory/sample/* inventory/akash/
-    print_status "Inventory copied successfully"
+    # Only copy if the hosts.yaml doesn't exist
+    if [ ! -f inventory/akash/hosts.yaml ]; then
+        cp -rfp inventory/sample/* inventory/akash/
+        print_status "Sample inventory copied successfully"
+    else
+        print_status "Using existing inventory file"
+    fi
 }
 
 # Create inventory using Kubespray's inventory builder
@@ -1012,6 +1045,7 @@ for i in "${!nodes[@]}"; do
       ansible_host: ${node_ip}
       ip: ${node_ip}
       access_ip: ${node_ip}
+      internal_ip: ${node_ip}
 EOF
 done
 
@@ -1389,14 +1423,34 @@ print_status "Hosts configuration verified"
 # Run the playbook
 print_status "Running playbooks based on your selections..."
 
-# Run Kubespray if selected
+# Run Kubernetes installation if selected
+if $SELECTED_KUBERNETES; then
 if $SELECTED_KUBESPRAY; then
     print_status "Running Kubespray to set up Kubernetes cluster..."
     cd ~/kubespray
     source venv/bin/activate
     ansible-playbook -i inventory/akash/hosts.yaml cluster.yml -t kubespray -v
 else
-    print_status "Skipping Kubespray as it was not selected"
+    print_status "Running K3s installation..."
+    
+    # Simple and direct approach - force add internal_ip to host_vars files
+    print_status "Adding internal_ip to host_vars files..."
+    NODE_IP=$(grep -A 1 'node1:' ~/kubespray/inventory/akash/hosts.yaml | grep 'ansible_host' | awk '{print $2}')
+    
+    # Ensure host_vars directory exists
+    mkdir -p ~/provider-playbooks/host_vars
+    
+    # Simply force append the variable to each file
+    for i in $(seq 1 $(grep -c "node[0-9]\+:" ~/kubespray/inventory/akash/hosts.yaml | grep -A1 "hosts:" | grep -v "hosts:" | wc -l)); do
+        NODE_NAME="node$i"
+        echo -e "\n# K3s specific variables\ninternal_ip: \"$NODE_IP\"" >> ~/provider-playbooks/host_vars/${NODE_NAME}.yml
+        print_status "Added internal_ip to host_vars file for $NODE_NAME"
+    done
+    
+    ansible-playbook -i ~/kubespray/inventory/akash/hosts.yaml playbooks.yml -t k3s -v
+fi
+else
+    print_status "Skipping Kubernetes installation as it was not selected"
     print_status "Note: Make sure you have a working Kubernetes cluster before proceeding"
 fi
 
@@ -1408,6 +1462,29 @@ if $SELECTED_OS || $SELECTED_GPU || $SELECTED_PROVIDER || $SELECTED_TAILSCALE ||
     # Activate the virtual environment
     source ~/kubespray/venv/bin/activate
     
+    # Check if K3s is running on node1
+    NODE_IP=$(grep -A 1 'node1:' ~/kubespray/inventory/akash/hosts.yaml | grep 'ansible_host' | awk '{print $2}')
+    if ssh -o StrictHostKeyChecking=no root@${NODE_IP} "systemctl is-active k3s" 2>/dev/null | grep -q "active"; then
+        print_status "K3s is running on node1, setting up kubeconfig..."
+        
+        # Create .kube directory if it doesn't exist
+        mkdir -p /root/.kube
+        
+        # Create symlink to k3s.yaml
+        ln -sf /etc/rancher/k3s/k3s.yaml /root/.kube/config
+        
+        # Set KUBECONFIG
+        export KUBECONFIG=/root/.kube/config
+        
+        # Verify kubeconfig
+        if ! kubectl get nodes; then
+            print_error "Failed to verify kubeconfig. Please check the configuration."
+            exit 1
+        fi
+    else
+        print_status "K3s is not running on node1, skipping kubeconfig setup"
+    fi
+    
     # Run OS playbook if selected
     if $SELECTED_OS; then
         print_status "Running OS configuration playbook..."
@@ -1487,4 +1564,4 @@ while true; do
 done
 
 print_status "Setup process completed!"
-print_status "Thank you for using the Akash Provider Setup Script!" 
+print_status "Thank you for using the Akash Provider Setup Script!"


Reviews:
user: login: vigneshv-ocl
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-24T15:46:10Z
user: login: vigneshv-ocl
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-24T15:53:13Z
user: login: Zblocker64
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-24T15:59:45Z
user: login: Zblocker64
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-24T20:07:13Z
state: CHANGES_REQUESTED
author_association: NONE
submitted_at: 2025-04-25T13:52:15Z
user: login: Zblocker64
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-25T13:55:54Z
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-25T14:14:20Z
state: APPROVED
author_association: NONE
submitted_at: 2025-04-25T14:15:18Z
state: APPROVED
author_association: NONE
submitted_at: 2025-04-25T16:52:36Z

Review comments:
diff_hunk: @@ -1,9 +1,29 @@
 ---
+- name: Setup K3s groups
+  hosts: all
+  gather_facts: false
+  tasks:
+    - name: Create control_plane group
+      ansible.builtin.add_host:
path: playbooks.yml
user: login: vigneshv-ocl
body: I'd not prefer to dynamically modifying the inventory during the execution
the reason being - I want to have an ability to run the ansible-playbook even without the wrapper script
created_at: 2025-04-24T15:46:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,3 +1,7 @@
+- name: Set internal_ip from inventory
+  ansible.builtin.set_fact:
+    internal_ip: "{{ ansible_host }}"
path: roles/k3s/tasks/prechecks.yml
user: login: vigneshv-ocl
body: i think we may have multiple ips from multiple n/w interface
created_at: 2025-04-24T15:53:13Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,3 +1,7 @@
+- name: Set internal_ip from inventory
+  ansible.builtin.set_fact:
+    internal_ip: "{{ ansible_host }}"
path: roles/k3s/tasks/prechecks.yml
user: login: Zblocker64
body: This grabs it from the inventory file that you specify. We should be good 
created_at: 2025-04-24T15:59:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,9 +1,29 @@
 ---
+- name: Setup K3s groups
+  hosts: all
+  gather_facts: false
+  tasks:
+    - name: Create control_plane group
+      ansible.builtin.add_host:
path: playbooks.yml
user: login: Zblocker64
body: Fixed
created_at: 2025-04-24T20:07:13Z
author_association: CONTRIBUTOR
diff_hunk: @@ -20,6 +20,7 @@
   kubernetes.core.k8s:
     state: present
     src: "{{ install_dir }}/nvidia-runtime-class.yml"
+    kubeconfig: "{{ kubeconfig_path }}"
path: roles/gpu/tasks/nvdp.yml
body: Rather than specifying individual `kubeconfig` vars (and `--kubeconfig` flags) each time, would it make sense to export the `KUBECONFIG` environment variable globally once instead? It might simplify the commands and reduce repetition.

created_at: 2025-04-25T13:47:50Z
author_association: NONE
diff_hunk: @@ -2,4 +2,5 @@
 # defaults file for GPU
 install_dir: "/root/ansible.tmp/"
 nvidia_version: 565.57.01
-cruntime_toml_path: '/etc/nvidia-container-runtime/config.toml'
\ No newline at end of file
+cruntime_toml_path: '/etc/nvidia-container-runtime/config.toml'
path: roles/gpu/defaults/main.yml
body: What's `cruntime_toml_path` used for?
created_at: 2025-04-25T13:48:55Z
author_association: NONE
diff_hunk: @@ -122,3 +124,43 @@
     owner: "{{ ansible_user }}"
     group: "{{ ansible_user }}"
     mode: '0755'
+  when: is_first_master
+
+- name: Create kubernetes directory
+  ansible.builtin.file:
+    path: "/etc/kubernetes"
+    state: directory
+    mode: '0755'
+  when: is_first_master
+
+- name: Copy K3s kubeconfig to standard location
path: roles/k3s/tasks/k3s-master.yml
body: This approach feels like an anti-pattern. Copying the K3s kubeconfig into the Kubespray-standard path (`/etc/kubernetes/admin.conf`) can lead to confusion or issues down the line—especially if the original becomes outdated or mismatched. 

Instead, we should detect whether it's a K3s or Kubespray-based Kubernetes install and export the appropriate `KUBECONFIG` environment variable globally. That way, other scripts or tooling don't make incorrect assumptions based on the presence of `admin.conf`, and the setup remains agnostic and maintainable across different deployment types.
created_at: 2025-04-25T13:51:43Z
author_association: NONE
diff_hunk: @@ -2,4 +2,5 @@
 # defaults file for GPU
 install_dir: "/root/ansible.tmp/"
 nvidia_version: 565.57.01
-cruntime_toml_path: '/etc/nvidia-container-runtime/config.toml'
\ No newline at end of file
+cruntime_toml_path: '/etc/nvidia-container-runtime/config.toml'
path: roles/gpu/defaults/main.yml
user: login: Zblocker64
body: Was already there. @vigneshv-ocl Would know
created_at: 2025-04-25T13:55:54Z
author_association: CONTRIBUTOR
diff_hunk: @@ -2,4 +2,5 @@
 # defaults file for GPU
 install_dir: "/root/ansible.tmp/"
 nvidia_version: 565.57.01
-cruntime_toml_path: '/etc/nvidia-container-runtime/config.toml'
\ No newline at end of file
+cruntime_toml_path: '/etc/nvidia-container-runtime/config.toml'
path: roles/gpu/defaults/main.yml
body: Found it. 
https://github.com/akash-network/provider-playbooks/blob/581151dda3d02ae3741c67b5f454f96b4fc85b5e/roles/gpu/tasks/nvidia_ctoolkit.yml#L4

That's okay.
created_at: 2025-04-25T14:14:20Z
author_association: NONE

PR comments:
user: login: ghost
created_at: 2025-04-24T15:44:08Z
body: Wouldn't it be cleaner to set the KUBECONFIG environment variable globally—based on whether k3s or Kubespray is in use—instead of repeating the explicit kubeconfig: "/etc/kubernetes/admin.conf" declaration multiple times?
author_association: NONE
user: login: Zblocker64
created_at: 2025-04-24T15:46:50Z
body: > Wouldn't it be cleaner to set the KUBECONFIG environment variable globally—based on whether k3s or Kubespray is in use—instead of repeating the explicit kubeconfig: "/etc/kubernetes/admin.conf" declaration multiple times?

Yeah it would. I tried that at first and it didn't work for whatever reason. Will dig back into it today and find a better solution

author_association: CONTRIBUTOR
user: login: vigneshv-ocl
created_at: 2025-04-24T15:49:58Z
body: we can add an variable for /etc/kubernetes/admin.conf in `<role>/defaults/main.yml` instead of hardcoding it
author_association: CONTRIBUTOR
user: login: Zblocker64
created_at: 2025-04-24T15:59:55Z
body: > we can add an variable for /etc/kubernetes/admin.conf in `<role>/defaults/main.yml` instead of hardcoding it

Will do
author_association: CONTRIBUTOR
user: login: Zblocker64
created_at: 2025-04-24T20:09:06Z
body: @andy108369 @vigneshv-ocl Fixed your suggested edits 
author_association: CONTRIBUTOR
user: login: Zblocker64
created_at: 2025-04-25T14:15:42Z
body: Still needs some work

author_association: CONTRIBUTOR