Enhance collect tool with k8s orchestration information
Add a script to collect information about container orchestration. Get k8s orchestration information. Get helm information. Get chart overrides from /opt/platform/helm_charts. Dump etcd database as json. Story: 2006536 Task: 36596 Change-Id: Ib622e8a77616c77434e760c38578b8e363992201 Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
This commit is contained in:
parent
2e7d2550b9
commit
75f0d4f19b
@ -1,2 +1,2 @@
|
|||||||
SRC_DIR="scripts"
|
SRC_DIR="scripts"
|
||||||
TIS_PATCH_VER=30
|
TIS_PATCH_VER=31
|
||||||
|
@ -47,6 +47,7 @@ install -m 755 collect_coredump.sh %{buildroot}%{_sysconfdir}/collect.d/collect_
|
|||||||
install -m 755 collect_crash.sh %{buildroot}%{_sysconfdir}/collect.d/collect_crash
|
install -m 755 collect_crash.sh %{buildroot}%{_sysconfdir}/collect.d/collect_crash
|
||||||
install -m 755 collect_ima.sh %{buildroot}%{_sysconfdir}/collect.d/collect_ima
|
install -m 755 collect_ima.sh %{buildroot}%{_sysconfdir}/collect.d/collect_ima
|
||||||
install -m 755 collect_fm.sh %{buildroot}%{_sysconfdir}/collect.d/collect_fm
|
install -m 755 collect_fm.sh %{buildroot}%{_sysconfdir}/collect.d/collect_fm
|
||||||
|
install -m 755 collect_containerization.sh %{buildroot}%{_sysconfdir}/collect.d/collect_containerization
|
||||||
|
|
||||||
install -m 755 etc.exclude %{buildroot}%{_sysconfdir}/collect/etc.exclude
|
install -m 755 etc.exclude %{buildroot}%{_sysconfdir}/collect/etc.exclude
|
||||||
install -m 755 run.exclude %{buildroot}%{_sysconfdir}/collect/run.exclude
|
install -m 755 run.exclude %{buildroot}%{_sysconfdir}/collect/run.exclude
|
||||||
|
82
tools/collector/scripts/collect_containerization.sh
Executable file
82
tools/collector/scripts/collect_containerization.sh
Executable file
@ -0,0 +1,82 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 Wind River Systems, Inc.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# Loads Up Utilities and Commands Variables
|
||||||
|
|
||||||
|
source /usr/local/sbin/collect_parms
|
||||||
|
source /usr/local/sbin/collect_utils
|
||||||
|
|
||||||
|
SERVICE="containerization"
|
||||||
|
LOGFILE="${extradir}/${SERVICE}.info"
|
||||||
|
HELM_DIR="${extradir}/helm"
|
||||||
|
ETCD_DB_FILE="${extradir}/etcd_database.json"
|
||||||
|
KUBE_CONFIG_FILE="/etc/kubernetes/admin.conf"
|
||||||
|
KUBE_CONFIG="--kubeconfig ${KUBE_CONFIG_FILE}"
|
||||||
|
echo "${hostname}: Containerization Info ...: ${LOGFILE}"
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# All nodes
|
||||||
|
###############################################################################
|
||||||
|
mkdir -p ${HELM_DIR}
|
||||||
|
source_openrc_if_needed
|
||||||
|
|
||||||
|
CMD="docker image ls -a"
|
||||||
|
delimiter ${LOGFILE} "${CMD}"
|
||||||
|
${CMD} 2>>${COLLECT_ERROR_LOG} >>${LOGFILE}
|
||||||
|
|
||||||
|
CMD="docker container ps -a"
|
||||||
|
delimiter ${LOGFILE} "${CMD}"
|
||||||
|
${CMD} 2>>${COLLECT_ERROR_LOG} >>${LOGFILE}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Active Controller
|
||||||
|
###############################################################################
|
||||||
|
if [ "$nodetype" = "controller" -a "${ACTIVE}" = true ] ; then
|
||||||
|
|
||||||
|
declare -a KUBE_CMDS=(
|
||||||
|
"kubectl ${KUBE_CONFIG} version"
|
||||||
|
"kubectl ${KUBE_CONFIG} api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl ${KUBE_CONFIG} get --show-kind --ignore-not-found --all-namespaces"
|
||||||
|
"kubectl ${KUBE_CONFIG} api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl ${KUBE_CONFIG} get --show-kind --ignore-not-found --all-namespaces -o yaml"
|
||||||
|
"kubectl ${KUBE_CONFIG} get pvc --all-namespaces"
|
||||||
|
"kubectl ${KUBE_CONFIG} get pvc --all-namespaces -o yaml"
|
||||||
|
"kubectl ${KUBE_CONFIG} get pv --all-namespaces"
|
||||||
|
"kubectl ${KUBE_CONFIG} get pv --all-namespaces -o yaml"
|
||||||
|
"kubectl ${KUBE_CONFIG} get events --all-namespaces --sort-by='.metadata.creationTimestamp' -o go-template='{{range .items}}{{printf \"%s %s\t%s\t%s\t%s\t%s\n\" .firstTimestamp .involvedObject.name .involvedObject.kind .message .reason .type}}{{end}}'"
|
||||||
|
)
|
||||||
|
|
||||||
|
for CMD in "${KUBE_CMDS[@]}" ; do
|
||||||
|
delimiter ${LOGFILE} "${CMD}"
|
||||||
|
eval ${CMD} 2>>${COLLECT_ERROR_LOG} >>${LOGFILE}
|
||||||
|
done
|
||||||
|
|
||||||
|
CMD="helm ${KUBE_CONFIG} version"
|
||||||
|
delimiter ${LOGFILE} "${CMD}"
|
||||||
|
${CMD} 2>>${COLLECT_ERROR_LOG} >>${LOGFILE}
|
||||||
|
|
||||||
|
CMD="helm ${KUBE_CONFIG} list -a"
|
||||||
|
delimiter ${LOGFILE} "${CMD}"
|
||||||
|
APPLIST=$(${CMD} 2>>${COLLECT_ERROR_LOG} | tee -a ${LOGFILE})
|
||||||
|
APPLIST=$(echo "${APPLIST}" | awk '{if (NR!=1) {print}}')
|
||||||
|
while read -r app; do
|
||||||
|
APPNAME=$(echo ${app} | awk '{print $1}')
|
||||||
|
APPREVISION=$(echo ${app} | awk '{print $2}')
|
||||||
|
helm ${KUBE_CONFIG} status ${APPNAME} > ${HELM_DIR}/${APPNAME}.status
|
||||||
|
helm ${KUBE_CONFIG} get values ${APPNAME} --revision ${APPREVISION} \
|
||||||
|
> ${HELM_DIR}/${APPNAME}.v${APPREVISION}
|
||||||
|
done <<< "${APPLIST}"
|
||||||
|
|
||||||
|
CMD="cp -r /opt/platform/helm_charts ${HELM_DIR}/"
|
||||||
|
delimiter ${LOGFILE} "${CMD}"
|
||||||
|
${CMD} 2>>${COLLECT_ERROR_LOG}
|
||||||
|
|
||||||
|
CMD="curl -L http://localhost:2379/v2/keys/?recursive=true -o ${ETCD_DB_FILE}"
|
||||||
|
delimiter ${LOGFILE} "${CMD}"
|
||||||
|
${CMD} 2>>${COLLECT_ERROR_LOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user