Kubernestes Interview questions

Frequently Asked Production Commands kubectl get all -A kubectl describe pod kubectl logs kubectl exec -it kubectl top nodes kubectl top pods kubectl get events kubectl rollout history kubectl cordon kubectl drain kubectl uncordon If you want, I can also provide: * Kubernetes scenario-based interview questions * Kubernetes troubleshooting questions * Kubernetes networking deep-dive * Kubernetes real-time production issues * Kubernetes interview answers in practical manner * Kubernetes mock interview for experienced meantime u have to give the commands for each questions Critical Kubernetes Interview Questions with Practical Commands 1. How do you check cluster information? Commands kubectl cluster-info kubectl get nodes kubectl get componentstatus kubectl version Purpose * Check API server * Check scheduler * Verify cluster health 2. How do you check all resources in Kubernetes? Commands kubectl get all -A kubectl get pods -A kubectl get svc -A kubectl get deployments -A kubectl get ingress -A 3. Pod is not coming up. How do you troubleshoot? Commands kubectl get pods kubectl describe pod kubectl logs kubectl get events --sort-by=.metadata.creationTimestamp Additional Commands kubectl logs -f kubectl logs --previous 4. Pod is in CrashLoopBackOff. What will you do? Commands kubectl describe pod kubectl logs kubectl logs --previous Check Resource Usage kubectl top pod kubectl top nodes 5. How do you access inside a pod? Commands kubectl exec -it -- /bin/bash If bash not available: kubectl exec -it -- /bin/sh 6. How do you expose deployment externally? NodePort kubectl expose deployment nginx \ --type=NodePort \ --port=80 LoadBalancer kubectl expose deployment nginx \ --type=LoadBalancer \ --port=80 7. How do you scale applications? Commands kubectl scale deployment nginx --replicas=5 Verify kubectl get pods kubectl get deployment 8. How do you perform rolling updates? Update Image kubectl set image deployment/nginx \ nginx=nginx:1.25 Check Rollout Status kubectl rollout status deployment/nginx 9. How do you rollback deployment? Commands kubectl rollout undo deployment/nginx Rollback History kubectl rollout history deployment/nginx 10. Node is NotReady. How will you troubleshoot? Commands kubectl get nodes kubectl describe node Check Kubelet systemctl status kubelet journalctl -u kubelet Check Container Runtime systemctl status containerd docker ps Check Disk Space df -h free -m 11. How do you cordon/drain nodes? Cordon kubectl cordon Drain kubectl drain --ignore-daemonsets --delete-emptydir-data Uncordon kubectl uncordon 12. How do you check Kubernetes events? Commands kubectl get events kubectl get events --sort-by=.metadata.creationTimestamp 13. How do you create ConfigMap? Commands kubectl create configmap app-config \ --from-literal=env=prod Verify kubectl get configmap kubectl describe configmap app-config 14. How do you create Secrets? Commands kubectl create secret generic db-secret \ --from-literal=username=admin \ --from-literal=password=admin123 Verify kubectl get secrets kubectl describe secret db-secret 15. How do you check networking issues? Check Service kubectl get svc kubectl describe svc Check Endpoints kubectl get ep DNS Testing kubectl exec -it busybox -- nslookup kubernetes.default Connectivity Test kubectl exec -it busybox -- ping curl 16. How do you troubleshoot ingress? Commands kubectl get ingress kubectl describe ingress Check Ingress Controller kubectl get pods -n ingress-nginx kubectl logs -n ingress-nginx 17. How do you check resource utilization? Commands kubectl top nodes kubectl top pods Describe Resources kubectl describe pod 18. How do you check persistent volume issues? Commands kubectl get pv kubectl get pvc kubectl describe pvc Storage Class kubectl get storageclass 19. How do you backup ETCD? Commands ETCDCTL_API=3 etcdctl snapshot save backup.db \ --endpoints=https://127.0.0.1:2379 \ --cacert=/etc/kubernetes/pki/etcd/ca.crt \ --cert=/etc/kubernetes/pki/etcd/server.crt \ --key=/etc/kubernetes/pki/etcd/server.key 20. How do you restore ETCD? Commands ETCDCTL_API=3 etcdctl snapshot restore backup.db 21. How do you deploy YAML files? Commands kubectl apply -f deployment.yaml kubectl create -f deployment.yaml Delete kubectl delete -f deployment.yaml 22. How do you generate YAML from running resource? Commands kubectl get deployment nginx -o yaml Export YAML: kubectl get deployment nginx -o yaml > nginx.yaml 23. How do you monitor logs continuously? Commands kubectl logs -f Multiple containers: kubectl logs -c 24. How do you check API resources? Commands kubectl api-resources kubectl api-versions 25. How do you debug scheduling issues? Commands kubectl describe pod kubectl get events Check Taints kubectl describe node 26. How do you check labels and selectors? Commands kubectl get pods --show-labels Filter by Label kubectl get pods -l app=nginx 27. How do you perform Kubernetes upgrades? Commands kubeadm upgrade plan kubeadm upgrade apply v1.xx.x Restart Services systemctl restart kubelet 28. How do you restart deployment? Commands kubectl rollout restart deployment nginx 29. How do you check certificates expiration? Commands kubeadm certs check-expiration 30. How do you create namespace? Commands kubectl create namespace dev Deploy into Namespace kubectl apply -f app.yaml -n dev 31. How do you switch namespaces? Commands kubectl config set-context --current --namespace=dev 32. How do you delete stuck resources? Force Delete Pod kubectl delete pod --force --grace-period=0 33. How do you check cluster roles and RBAC? Commands kubectl get roles kubectl get rolebindings kubectl get clusterroles kubectl get clusterrolebindings 34. How do you check kube-system components? Commands kubectl get pods -n kube-system 35. How do you troubleshoot DNS issues? Commands kubectl get pods -n kube-system kubectl logs -n kube-system -l k8s-app=kube-dns DNS Test: nslookup kubernetes.default

Comments

Popular posts from this blog

Linux interview questions

Aws Interview Questions