KevsRobots Learning Platform
40% Percent Complete
By Kevin McAleer, 2 Minutes
Page last updated May 24, 2025

With your K3s cluster up and running, itβs time to interact with it using kubectl β the command-line tool for managing Kubernetes.
This lesson will walk you through the basics of exploring and managing your cluster.
kubectl AccessOn the master node, or from your development machine:
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
Or copy the config to your local system:
scp pi@pi-master:/etc/rancher/k3s/k3s.yaml ~/.kube/config
Replace pi@pi-master with your actual master node address.
Ensure correct file permissions:
chmod 600 ~/.kube/config
List all nodes:
kubectl get nodes
List all running pods (across namespaces):
kubectl get pods -A
Check system components (K3s uses kube-system namespace):
kubectl get pods -n kube-system
Create a simple deployment:
kubectl create deployment hello-world --image=nginx
Expose it as a service:
kubectl expose deployment hello-world --port=80 --type=NodePort
Find the assigned NodePort:
kubectl get svc hello-world
Access it via any nodeβs IP and the port listed.
| Command | Description |
|---|---|
kubectl get pods |
List all pods in the current namespace |
kubectl describe pod <name> |
Show detailed info about a pod |
kubectl logs <pod> |
View logs from a pod |
kubectl exec -it <pod> -- bash |
Open a shell inside a pod (if it has bash) |
kubectl delete pod <name> |
Delete a pod |
kubectl apply -f <file.yaml> |
Apply resources from a YAML file |
-A to view resources across all namespacesAdd bash completion for kubectl:
source <(kubectl completion bash)
kubectl get all to quickly see services, pods, deploymentskubectl describe node pi-master
Look at:
You now know how to:
kubectlNext up: Dashboard and Monitoring
You can use the arrows β β on your keyboard to navigate between lessons.
Comments