Repaso
Español
Cloud & DevOpsCoreOPS-45

Which kubectl commands apply a manifest, list Pods and read a Pod's logs?

Options

  1. kubectl apply -f x.yaml, get pods, logs <pod> (Correct option)
  2. kubectl run x.yaml, kubectl list, kubectl show
  3. kubectl build, kubectl push, kubectl read
  4. kubectl start, kubectl stop, kubectl delete

Answer

kubectl apply -f x.yaml, kubectl get pods, kubectl logs <pod>

Why

kubectl is the command line for Kubernetes.

  • kubectl apply -f deployment.yaml: create or update objects from a file (declarative).
  • kubectl get pods (also deploy, svc, -A for all namespaces).
  • kubectl describe pod <name>: details and events (why it is not starting).
  • kubectl logs <pod> (-f follow, --previous for the last crashed container).
  • kubectl exec -it <pod> -- sh: shell inside.
  • kubectl rollout undo deployment/<name>: roll back.

Remember

apply, get, describe, logs.

Key terms

Practice this question in Repaso