• To check if kubelet is working

systemctl status kubelet
CODE
  • To check the Linux system logs when kubelet has an error

journalctl -xeu kubelet
CODE
  • To check the kubelet logs when it has any error

kubectl get events --all-namespaces  --sort-by='.metadata.creationTimestamp'
CODE
  • To check the Pod logs

kubectl logs <POD_NAME> -n <NAMESPACE> 
CODE
  • To check the previous Pod logs if it is seen it restarted at least one time

kubectl logs --previous <POD_NAME> -n apinizer
CODE
  • To check if there exist any general error on Pod or see the details of Pod

kubectl describe pod <POD_NAME> -n apinizer
CODE
  • To execute any command inside of a working Pod

kubectl exec -it  <POD_NAME> -n prod /bin/bash
CODE
  • To execute any command as it is from inside without getting inside of a working Pod

kubectl exec -it  <POD_NAME> -n prod -- curl x.y.gov.tr
CODE
  • To restart all pods under a specific deployment

kubectl rollout restart deployment manager -n apinizer
CODE
  • To delete a deployment as a whole

kubectl delete -f  apinizer-deployment.yaml
CODE
  • To force a Pod to delete if it stucks on status "terminating"

kubectl delete pod <POD_NAME> -n apinizer --grace-period=0 --force 
CODE
  • To update version when the necessary images loaded on the servers' dockers'. It is worked like "vi" editor which it needs to do ":wq" to save and exit and ":q!" to exit without save.

kubectl edit deployment manager -n apinizer
kubectl edit deployment cache -n prod
kubectl edit deployment worker -n prod
CODE
  • To clean up pods in the "Evicted" state

kubectl get pod -n prod | grep Evicted | awk '{print $1}' | xargs kubectl delete pod -n prod
CODE
  • Preventing Pod from Running on Specific Nodes Using Kubernetes Node Affinity

        affinity:
          nodeAffinity:
            requiredDuringSchedulingIgnoredDuringExecution:
              nodeSelectorTerms:
              - matchExpressions:
                - key: kubernetes.io/hostname
                  operator: NotIn
                  values:
                  - kuberdemo55
                  - kuberdemo56
CODE



Docker

  • Image listing

docker images
CODE
  • List All Containers

docker ps -a
CODE
  • Image Pull

sudo docker pull apinizercloud/manager:2024.xx.0
CODE
  • Image Export

sudo docker save apinizercloud/manager:2024.xx.0 > manager_2024.xx.0.tar
CODE
  • Image Import

sudo docker load < manager_2024.xx.0.tar
CODE



Containerd

  • Namespace Listing

sudo ctr namespaces list
CODE
  • Containers listing with namespace

sudo ctr --namespace k8s.io containers ls
CODE
  • Images of Apinizer listing with namespace

sudo ctr -n k8s.io images list | grep apinizer
CODE
  • Image Pull

sudo ctr --namespace k8s.io images pull docker.io/apinizercloud/manager:2024.05.0
CODE
  • Image Export

sudo ctr -n k8s.io images export /tmp/manager:2024.05.0.tar docker.io/apinizercloud/manager:2024.05.0
CODE
  • Image Import

sudo ctr --namespace k8s.io images import /tmp/manager:2024.05.0.tar
CODE