DISCLAIMER: This is an unofficial guide. If you mess things up then you may lock yourself out of TrueNAS or even worse, make it unusable. There's also no guarantee that this works in the future.
Currently the easiest way to access kubectl
is through ssh and k3s tool. If
you have ssh access enabled then you can ssh to your TrueNAS server and use it
using k3s kubectl get pods -A
. This guide shows how to access kubectl
without SSH-ing to the server.
- SSH to your TrueNAS scale instance:
ssh root@TRUENAS-IP
- Copy the kubectl from:
cat /etc/rancher/k3s/k3s.yaml
- Add the configuration to your ~/.kube/config
- In your local ~/.kube/config change:
- server: use your TrueScale server IP
- (optional) Instead of
default
use some identifier likehomelab
. This is only useful when you have multiple kubernetes clusters.
- In the TrueNAS server open port 6443:
iptables -I INPUT -p tcp -s YOUR-IP --dport 6443 -j ACCEPT -m comment --comment 'Allow kubectl access from remote computer' --wait
- Replace YOUR-IP with your computer IP (e.g. 192.168.1.42).
That's it. Now if you do kubectl --context=homelab get pods -A
you should see all running pods.
NOTE: TrueNAS resets the firewall settings after a restart. If you restart your server, then you need to re-run the steps 1 and 5.
NOTE: If you don't have kubectl
installed then I'd recommend using
asdf with asdf-kubectl plugin. At the time of the writing, the Kubernetes
version used by TrueNas was 1.23.
Thx 👍