Kubernetes (K8s) (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
Essential `kubectl` Commands for Daily Operations.
junior LevelCode ExamplekubernetesBasic
In Simple Words:
Essential daily kubectl commands allow engineers to inspect cluster topology, tail container logs, troubleshoot pod scheduling events, and apply declarative YAML configurations.
Code Example
bash
# 1. Listing resources with wide output (IPs, Nodes)
kubectl get pods -n production -o wide
# 2. Inspecting detailed event logs and failures (Vital for debugging)
kubectl describe pod payment-service-7d4bf-8xk9z -n production
# 3. Streaming live container stdout/stderr
kubectl logs -f deployment/payment-service -n production --tail=100
# 4. Opening an interactive shell inside a running pod
kubectl exec -it payment-service-7d4bf-8xk9z -c app -- /bin/sh
# 5. Port forwarding a cluster service to local machine (great for testing)
kubectl port-forward service/postgres-service 5432:5432 -n database
# 6. Checking cluster resource utilization (CPU/Memory)
kubectl top nodes
kubectl top pods -A