# K3S Commands

`k3s crictl pull <imageName>`

`k3s kubectl get pods -n <ix-appname>`

`k3s kubectl get pods --all-namespaces`

`k3s kubectl get <appname>`

`sudo k3s kubectl get events -n ix-APPNAME`

1. **Check Cluster Health:**
    
    <div aria-labelledby="message-username-1216589008805560350 uid_1 message-content-1216589008805560350 uid_2 message-timestamp-1216589008805560350" aria-roledescription="Message" aria-setsize="-1" class="message__80c10 cozyMessage__64ce7 groupStart__56db5 wrapper__09ecc cozy_f5c119 zalgo__39311" data-list-item-id="chat-messages___chat-messages-1216588896947798107-1216589008805560350" role="article" tabindex="-1"><div class="contents_f41bb2"><div class="markup_a7e664 messageContent__21e69"><div class="codeContainer__1ded4">`k3s kubectl get nodes`</div></div></div></div>This command checks the health and status of all nodes in the cluster.
    
    <div aria-labelledby="message-username-1216589008805560350 uid_1 message-content-1216589008805560350 uid_2 message-timestamp-1216589008805560350" aria-roledescription="Message" aria-setsize="-1" class="message__80c10 cozyMessage__64ce7 groupStart__56db5 wrapper__09ecc cozy_f5c119 zalgo__39311" data-list-item-id="chat-messages___chat-messages-1216588896947798107-1216589008805560350" role="article" tabindex="-1"><div class="contents_f41bb2"><div class="markup_a7e664 messageContent__21e69" id="bkmrk-list-all-pods%3A-k3s-k">
    2. **List All Pods:**<div class="codeContainer__1ded4">`k3s kubectl get pods --all-namespaces`</div>This command lists all pods across all namespaces, which can help identify any pods that are not running as expected.
    
    
    3. **Describe a Pod:**<div class="codeContainer__1ded4">`k3s kubectl describe pod <pod-name> -n <namespace>`</div>Replace `<pod-name>` with the name of the pod and `<namespace>` with the namespace it resides in. This command provides detailed information about a specific pod, which can be useful for diagnosing issues.
    
    
    4. **View Logs for a Pod:**<div class="codeContainer__1ded4">`k3s kubectl logs <pod-name> -n <namespace>`</div>This command shows the logs for a specific pod. If the pod has multiple containers, you may need to specify the container name with the `-c` flag.
    
    
    5. **Check Deployments:**<div class="codeContainer__1ded4">`k3s kubectl get deployments -n <namespace>`</div>This command lists all deployments in a specific namespace, showing their desired and current states.
    
    
    6. **Describe a Deployment:**<div class="codeContainer__1ded4">`k3s kubectl describe deployment <deployment-name> -n <namespace>`</div>This command provides detailed information about a specific deployment.
    
    
    7. **Check Services:**<div class="codeContainer__1ded4">`k3s kubectl get svc -n <namespace>`</div>This command lists all services in a specific namespace, which can help troubleshoot networking and access issues.
    
    
    8. **Check Persistent Volume Claims (PVCs):**<div class="codeContainer__1ded4">`k3s kubectl get pvc -n <namespace>`</div>This command lists all PVCs in a specific namespace, which can help troubleshoot storage-related issues.
    
    
    9. **Check ConfigMaps:**<div class="codeContainer__1ded4">`k3s kubectl get configmaps -n <namespace>`</div>
    
    </div></div><div class="buttonContainer_dd4b62"><div aria-label="Message Actions" class="buttons__3766a container__9d616 isHeader__4c092" role="group"><div class="buttonsInner_bca8fa wrapper_c727b6">  
    </div></div></div><div class="contents_f41bb2"><div class="markup_a7e664 messageContent__21e69" id="bkmrk-this-command-lists-a">This command lists all ConfigMaps in a specific namespace, which can be useful for troubleshooting configuration issues. 
    10. **Check Ingress Resources:**<div class="codeContainer__1ded4">`k3s kubectl get ingress -n <namespace>`</div>This command lists all ingress resources in a specific namespace, which can help troubleshoot external access to services.
    
    
    11. **Delete a Pod:**<div class="codeContainer__1ded4">`k3s kubectl delete pod <pod-name> -n <namespace>`</div>This command deletes a specific pod. Kubernetes will attempt to recreate the pod if it is managed by a controller like a Deployment or StatefulSet.
    
    
    12. **Scale a Deployment:**<div class="codeContainer__1ded4">`k3s kubectl scale deployment <deployment-name> -n <namespace> --replicas=<number>`</div>Replace `<number>` with the desired number of replicas. This command adjusts the number of replicas for a deployment, which can be useful for scaling up or down.
    
    Remember to replace placeholders like `<pod-name>`, `<namespace>`, `<deployment-name>`, and `<number>` with actual values relevant to your environment. Also, please note that manually scaling or deleting Kubernetes objects can have unintended consequences, especially if they are managed by Helm or other automation tools. Always ensure you understand the impact of these commands before executing them.</div></div></div>