# Cluster infokubectl cluster-info# List all nodeskubectl get nodeskubectl get nodes -o wide# Node detailskubectl describe node <node-name># Check component statuskubectl get componentstatuses
Namespaces
# List namespaceskubectl get namespaceskubectl get ns# Create namespacekubectl create namespace <name># Delete namespace (deletes everything inside)kubectl delete namespace <name># Set default namespace for sessionkubectl config set-context --current --namespace=<name>
Pods
# List podskubectl get podskubectl get pods -n <namespace>kubectl get pods -A # All namespaceskubectl get pods -o wide # Show node, IPkubectl get pods -w # Watch modekubectl get pods -l app=seaweedfs # Filter by label# Pod detailskubectl describe pod <pod-name> -n <namespace># Pod logskubectl logs <pod-name> -n <namespace>kubectl logs <pod-name> -n <namespace> --tail=50kubectl logs <pod-name> -n <namespace> -f # Followkubectl logs -l component=mount -n <namespace> # By label# Execute command in podkubectl exec -it <pod-name> -n <namespace> -- shkubectl exec -it <pod-name> -n <namespace> -- bashkubectl exec <pod-name> -n <namespace> -- ls -la /data# Delete pod (will recreate if managed by controller)kubectl delete pod <pod-name> -n <namespace>kubectl delete pods -l component=mount -n <namespace> # By label# Run debug podkubectl run debug --rm -it --image=busybox -n <namespace> -- sh
# Get YAML of existing resourcekubectl get <type> <name> -n <namespace> -o yamlkubectl get pod <name> -n <namespace> -o yaml# Get JSONkubectl get <type> <name> -n <namespace> -o json# Get specific fieldkubectl get pod <name> -n <namespace> -o jsonpath='{.status.podIP}'kubectl get pods -n <namespace> -o jsonpath='{.items[*].metadata.name}'# Get all resourceskubectl get all -n <namespace># Get eventskubectl get events -n <namespace>kubectl get events -n <namespace> --sort-by='.lastTimestamp'
Labels & Selectors
# Add labelkubectl label pod <name> env=prod -n <namespace># Remove labelkubectl label pod <name> env- -n <namespace># Filter by labelkubectl get pods -l app=seaweedfs -n <namespace>kubectl get pods -l 'app in (nginx, redis)' -n <namespace>kubectl get pods -l app!=nginx -n <namespace># Show labelskubectl get pods --show-labels -n <namespace>