CLI
View logs of a previous instance of a pod in Kubernetes¶
kubectl logs <pod-name> --previous
When a container crashes and Kubernetes restarts it, this flag shows logs from the crashed container instead of the current running one.
View all environment variables set in a Kubernetes resource¶
kubectl set env <resource>/<resource-name> --list
List all events sorted by timestamp¶
kubectl get events --sort-by=".lastTimestamp"
Port forward a Service in K8s¶
alias grafana="kubectl --namespace <namespace-name> port-forward svc/grafana 3000:<CONTAINER_PORT> & open http://localhost:3000"