-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> fix: Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> add log upload functionality Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> changes Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> test Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> update permission Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> update permission Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> fail test Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> remove exit Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> update permission Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> update Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> update Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> add condition Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> test Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> test Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> Remove exit Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> test Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> fix pod name Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> Remove exit Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> refactor Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> test Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com> remove exit Signed-off-by: chahatsagarmain <chahatsagar2003@gmail.com>
- Loading branch information
1 parent
32bdbe8
commit f91c63f
Showing
8 changed files
with
227 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
NS="" | ||
OUTPUT_FILE="/tmp/tmp.log/tmp_pod_log.txt" | ||
|
||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--ns) NS="$2"; shift ;; | ||
--output) OUTPUT_FILE="$2"; shift ;; | ||
*) echo "Unknown parameter passed: $1"; exit 1 ;; | ||
esac | ||
shift | ||
done | ||
|
||
mkdir -p /tmp/tmp.log | ||
|
||
if [[ -z "$NS" ]]; then | ||
echo "Both --ns parameters are required." | ||
exit 1 | ||
fi | ||
|
||
function check_namespace { | ||
if ! kubectl get namespace "$1" &>/dev/null; then | ||
echo "Namespace '$1' does not exist." | ||
exit 1 | ||
fi | ||
} | ||
|
||
function display_pod_info { | ||
local NAMESPACE=$1 | ||
local POD_NAMES | ||
|
||
POD_NAMES=$(kubectl get pods -n "${NS}" -o custom-columns=":metadata.name" --no-headers) | ||
|
||
if [[ -z "${POD_NAMES}" ]]; then | ||
echo "No pods found in namespace '${NAMESPACE}'." | tee -a "$OUTPUT_FILE" | ||
return | ||
fi | ||
|
||
echo "Pod Information for Namespace: ${NAMESPACE}" > "$OUTPUT_FILE" | ||
|
||
for POD_NAME in ${POD_NAMES}; do | ||
{ | ||
echo "===== Pod: ${POD_NAME} in ${NAMESPACE} =====" | ||
echo "----- EVENTS -----" | ||
kubectl describe pod "${POD_NAME}" -n "${NAMESPACE}" | grep -A 100 Events || echo "No events found for pod ${POD_NAME}." | ||
|
||
echo "----- LOGS -----" | ||
kubectl logs "${POD_NAME}" -n "${NAMESPACE}" || echo "No logs found for pod ${POD_NAME}." | ||
|
||
echo "===========================" | ||
echo "" | ||
} | tee -a "$OUTPUT_FILE" | ||
done | ||
|
||
echo "Pod information stored in $OUTPUT_FILE" | ||
} | ||
|
||
check_namespace "$NS" | ||
display_pod_info "$NS" |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.