Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save coltenkrauter/a37fa277ef83a8fc3ab706746cec1a6b to your computer and use it in GitHub Desktop.
Save coltenkrauter/a37fa277ef83a8fc3ab706746cec1a6b to your computer and use it in GitHub Desktop.
TrueNas Scale Kubernetes Commands
# 1. Get service information such as IP addresses and ports across all namespaces
k3s kubectl get services --all-namespaces
# 2. Get pod information such as name, health, and age across all namespaces
k3s kubectl get pods --all-namespaces
# 3. List all nodes in the cluster along with their status and roles
k3s kubectl get nodes
# 4. Get detailed information about all deployments across all namespaces
k3s kubectl get deployments --all-namespaces
# 5. Display all ReplicaSets available in all namespaces
k3s kubectl get replicasets --all-namespaces
# 6. View all persistent volume claims across all namespaces
k3s kubectl get pvc --all-namespaces
# 7. Show all persistent volumes and their corresponding status and claims
k3s kubectl get pv
# 8. List all namespaces within the cluster
k3s kubectl get namespaces
# 9. Get detailed information about all jobs across all namespaces
k3s kubectl get jobs --all-namespaces
# 10. Display all events in all namespaces to check for errors, warnings, and other system messages
k3s kubectl get events --all-namespaces
# 11. Get pods that are in a failed state across all namespaces
k3s kubectl get pods --all-namespaces --field-selector=status.phase=Failed
# 12. Show pods that have restarted more than a specified number of times, indicating instability or crashes
k3s kubectl get pods --all-namespaces --field-selector=status.restartCount>5
# 13. List events sorted by timestamp in all namespaces to quickly find recent issues
k3s kubectl get events --all-namespaces --sort-by='.metadata.creationTimestamp'
# 14. Display all pods with their status conditions to identify those with issues such as 'Ready' being 'False'
k3s kubectl get pods --all-namespaces -o custom-columns='NAME:.metadata.name,NAMESPACE:.metadata.namespace,STATUS:.status.conditions[*].status,TYPE:.status.conditions[*].type'
# 15. Get details of nodes to identify conditions that might indicate problems like memory pressure or disk pressure
k3s kubectl get nodes -o custom-columns='NAME:.metadata.name,CONDITIONS:.status.conditions[*].type,STATUS:.status.conditions[*].status'
# 16. Display failed jobs across all namespaces which can indicate issues with scheduled tasks or batch processing
k3s kubectl get jobs --all-namespaces --field-selector=status.failed>0
# 17. Find services with endpoints that might be missing or not functioning, which could indicate underlying pod or network issues
k3s kubectl get services --all-namespaces -o custom-columns='NAME:.metadata.name,NAMESPACE:.metadata.namespace,ENDPOINTS:.subsets[*].addresses[*].ip' | grep '<none>'
# 18. Examine resource quotas and their usage to identify any that are exceeded, potentially causing pod deployment failures
k3s kubectl describe quota --all-namespaces
# 19. Check for any nodes under disk pressure, which could lead to pod eviction or scheduling failures
k3s kubectl get nodes -o custom-columns='NAME:.metadata.name,DISK_PRESSURE:.status.conditions[?(@.type=="DiskPressure")].status'
# 20. Look at all config maps across all namespaces for anomalies or misconfigurations
k3s kubectl get configmaps --all-namespaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment