Last active
April 18, 2022 18:20
-
-
Save caffeinetiger/ff27c698fccf538bd19b3f2c44ccfd25 to your computer and use it in GitHub Desktop.
Some tips and tricks on getting logs using kubectl. ### Sources
- [stack overflow - kubectl logs - continously](https://stackoverflow.com/questions/39454962/kubectl-logs-continuously)
- [Krew - kubectl plugin manager](https://krew.sigs.k8s.io/)
- [s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ( | |
| set -x; cd "$(mktemp -d)" && | |
| OS="$(uname | tr '[:upper:]' '[:lower:]')" && | |
| ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" && | |
| KREW="krew-${OS}_${ARCH}" && | |
| curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" && | |
| tar zxvf "${KREW}.tar.gz" && | |
| ./"${KREW}" install krew | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Getting logs from all containers/replica sets/pods for a given time range | |
| kubectl logs deployment/<name of deployment> --all-containers=true --since=10m | |
| # Follow (will update based on time range settings) logs from all containers/replica sets/pods for a given time range | |
| kubectl logs deployment/<name of deployment> --all-containers=true --since=10m | |
| # Follow logs for a given pod based on pod id | |
| kubectl logs -f <pod-id> | |
| # Stern plugin - follow all logs for a given resource | |
| # REQUIRES Stern plugin install see description for installation instructions and Github page for documentation | |
| kubectl stern tektelic-broker --since 10m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment