Kubectl logs pod code example

Example 1: kubectl list context

# list kubernets contexts
kubectl config get-contexts

Example 2: find logs in kubernetes pods

kubectl logs elasticsearch-master-1 --since=2m --timestamps

Example 3: kubernetes get logs from pod

kubectl logs <pod-name>

Example 4: kubectl get logs of deployment

kubectl logs -f deployment/<name-of-deployment>
or
kubectl logs deployment/<name-of-deployment>

Example 5: kubectl run pod

kubectl run <pod-name> --image=<image> --restart=Never

Example 6: kubectl logs with grep

kubectl log bino | grep "error unable-to-access-website" >> John/Doe/Bino/log.txt

Tags:

Go Example