Skip to content

Setup K3s on Ubuntu

Learn how to set up K3s on Ubuntu for lightweight Kubernetes deployment.

  1. Install k3s as a service

    Bash
    curl -sfL https://get.k3s.io | sh -
    
  2. Fix k3s permission denied issues

    Bash
    mkdir ~/.kube 2> /dev/null
    export KUBECONFIG=~/.kube/config
    sudo k3s kubectl config view --raw > "$KUBECONFIG"
    chmod 600 "$KUBECONFIG"
    
    • More details in fixing k3s permission denied issues.
  3. export KUBECONFIG=~/.kube/config to either ~/.profile or ~/.bashrc to make it persist on reboot(Optional).

    Bash
    nano ~/.bashrc
    source ~/.bashrc
    

    Navigate to the last line

    ~/.bashrc
    # last line
    export KUBECONFIG=~/.kube/config
    
  4. Test connection

    Bash
    kubectl get all