mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Add Scheduler and ControllerManager profile grabbing
This commit is contained in:
parent
2ef2544faa
commit
a8193679fb
@ -32,7 +32,7 @@ function grab_profiles_from_component {
|
|||||||
for profile in ${requested_profiles}; do
|
for profile in ${requested_profiles}; do
|
||||||
case ${profile} in
|
case ${profile} in
|
||||||
cpu)
|
cpu)
|
||||||
go tool pprof "-pdf" "${binary}" "http://localhost:${tunnel_port}/${path}/profile" > "${output_prefix}-${profile}-profile-${timestamp}.pdf"
|
go tool pprof "-pdf" "${binary}" "http://localhost:${tunnel_port}${path}/debug/pprof/profile" > "${output_prefix}-${profile}-profile-${timestamp}.pdf"
|
||||||
;;
|
;;
|
||||||
mem)
|
mem)
|
||||||
# There are different kinds of memory profiles that are available that
|
# There are different kinds of memory profiles that are available that
|
||||||
@ -40,7 +40,7 @@ function grab_profiles_from_component {
|
|||||||
# --alloc-space, --alloc-objects. We need to iterate over all requested
|
# --alloc-space, --alloc-objects. We need to iterate over all requested
|
||||||
# kinds.
|
# kinds.
|
||||||
for flag in ${mem_pprof_flags}; do
|
for flag in ${mem_pprof_flags}; do
|
||||||
go tool pprof "-${flag}" "-pdf" "${binary}" "http://localhost:${tunnel_port}/${path}/heap" > "${output_prefix}-${profile}-${flag}-profile-${timestamp}.pdf"
|
go tool pprof "-${flag}" "-pdf" "${binary}" "http://localhost:${tunnel_port}${path}/debug/pprof/heap" > "${output_prefix}-${profile}-${flag}-profile-${timestamp}.pdf"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -53,22 +53,29 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
|||||||
server_addr=""
|
server_addr=""
|
||||||
kubelet_addreses=""
|
kubelet_addreses=""
|
||||||
kubelet_binary=""
|
kubelet_binary=""
|
||||||
|
master_binary=""
|
||||||
|
scheduler_binary=""
|
||||||
|
scheduler_port="10251"
|
||||||
|
controller_manager_port="10252"
|
||||||
|
controller_manager_binary=""
|
||||||
requested_profiles=""
|
requested_profiles=""
|
||||||
mem_pprof_flags=""
|
mem_pprof_flags=""
|
||||||
profile_components=""
|
profile_components=""
|
||||||
output_dir="."
|
output_dir="."
|
||||||
tunnel_port="${tunnel_port:-1234}"
|
tunnel_port="${tunnel_port:-1234}"
|
||||||
|
|
||||||
args=$(getopt -o s:mho:k: -l server:,master,heapster,output:,kubelet:,help,inuse-space,inuse-objects,alloc-space,alloc-objects,cpu,kubelet-binary: -- "$@")
|
args=$(getopt -o s:mho:k:c -l server:,master,heapster,output:,kubelet:,scheduler,controller-manager,help,inuse-space,inuse-objects,alloc-space,alloc-objects,cpu,kubelet-binary:,master-binary:,scheduler-binary:,controller-manager-binary:,scheduler-port:,controller-manager-port: -- "$@")
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
>&2 echo "Error in getopt"
|
>&2 echo "Error in getopt"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HEAPSTER_VERSION="v0.18.2"
|
HEAPSTER_VERSION="v0.18.2"
|
||||||
MASTER_PPROF_PATH="debug/pprof"
|
MASTER_PPROF_PATH=""
|
||||||
HEAPSTER_PPROF_PATH="api/v1/proxy/namespaces/kube-system/services/monitoring-heapster/debug/pprof"
|
HEAPSTER_PPROF_PATH="/api/v1/proxy/namespaces/kube-system/services/monitoring-heapster"
|
||||||
KUBELET_PPROF_PATH_PREFIX="api/v1/proxy/nodes"
|
KUBELET_PPROF_PATH_PREFIX="/api/v1/proxy/nodes"
|
||||||
|
SCHEDULER_PPROF_PATH_PREFIX="/api/v1/proxy/namespaces/kube-system/pods/kube-scheduler"
|
||||||
|
CONTROLLER_MANAGER_PPROF_PATH_PREFIX="/api/v1/proxy/namespaces/kube-system/pods/kube-controller-manager"
|
||||||
|
|
||||||
eval set -- "${args}"
|
eval set -- "${args}"
|
||||||
|
|
||||||
@ -87,19 +94,19 @@ while true; do
|
|||||||
shift
|
shift
|
||||||
profile_components="master ${profile_components}"
|
profile_components="master ${profile_components}"
|
||||||
;;
|
;;
|
||||||
|
--master-binary)
|
||||||
|
shift
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
>&2 echo "empty argumet to --master-binary flag"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
master_binary=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h|--heapster)
|
-h|--heapster)
|
||||||
shift
|
shift
|
||||||
profile_components="heapster ${profile_components}"
|
profile_components="heapster ${profile_components}"
|
||||||
;;
|
;;
|
||||||
-o|--output)
|
|
||||||
shift
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
>&2 echo "empty argument to --output flag"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
output_dir=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-k|--kubelet)
|
-k|--kubelet)
|
||||||
shift
|
shift
|
||||||
profile_components="kubelet ${profile_components}"
|
profile_components="kubelet ${profile_components}"
|
||||||
@ -119,6 +126,59 @@ while true; do
|
|||||||
kubelet_binary=$1
|
kubelet_binary=$1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--scheduler)
|
||||||
|
shift
|
||||||
|
profile_components="scheduler ${profile_components}"
|
||||||
|
;;
|
||||||
|
--scheduler-binary)
|
||||||
|
shift
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
>&2 echo "empty argumet to --scheduler-binary flag"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
scheduler_binary=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--scheduler-port)
|
||||||
|
shift
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
>&2 echo "empty argumet to --scheduler-port flag"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
scheduler_port=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-c|--controller-manager)
|
||||||
|
shift
|
||||||
|
profile_components="controller-manager ${profile_components}"
|
||||||
|
;;
|
||||||
|
--controller-manager-binary)
|
||||||
|
shift
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
>&2 echo "empty argumet to --controller-manager-binary flag"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
controller_manager_binary=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--controller-manager-port)
|
||||||
|
shift
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
>&2 echo "empty argumet to --controller-manager-port flag"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
controller-managerr_port=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-o|--output)
|
||||||
|
shift
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
>&2 echo "empty argument to --output flag"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
output_dir=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--inuse-space)
|
--inuse-space)
|
||||||
shift
|
shift
|
||||||
requested_profiles="mem ${requested_profiles}"
|
requested_profiles="mem ${requested_profiles}"
|
||||||
@ -202,7 +262,15 @@ for component in ${profile_components}; do
|
|||||||
case ${component} in
|
case ${component} in
|
||||||
master)
|
master)
|
||||||
path=${MASTER_PPROF_PATH}
|
path=${MASTER_PPROF_PATH}
|
||||||
binary=""
|
binary=${master_binary}
|
||||||
|
;;
|
||||||
|
controller-manager)
|
||||||
|
path="${CONTROLLER_MANAGER_PPROF_PATH_PREFIX}-${server_addr}:${controller_manager_port}"
|
||||||
|
binary=${controller_manager_binary}
|
||||||
|
;;
|
||||||
|
scheduler)
|
||||||
|
path="${SCHEDULER_PPROF_PATH_PREFIX}-${server_addr}:${scheduler_port}"
|
||||||
|
binary=${scheduler_binary}
|
||||||
;;
|
;;
|
||||||
heapster)
|
heapster)
|
||||||
rm heapster
|
rm heapster
|
||||||
@ -224,7 +292,7 @@ for component in ${profile_components}; do
|
|||||||
|
|
||||||
if [[ "${component}" == "kubelet" ]]; then
|
if [[ "${component}" == "kubelet" ]]; then
|
||||||
for node in $(echo ${kubelet_addreses} | sed 's/[,;]/\n/g'); do
|
for node in $(echo ${kubelet_addreses} | sed 's/[,;]/\n/g'); do
|
||||||
grab_profiles_from_component "${requested_profiles}" "${mem_pprof_flags}" "${binary}" "${tunnel_port}" "${path}/${node}/debug/pprof" "${output_dir}/${component}" "${timestamp}"
|
grab_profiles_from_component "${requested_profiles}" "${mem_pprof_flags}" "${binary}" "${tunnel_port}" "${path}/${node}" "${output_dir}/${component}" "${timestamp}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
grab_profiles_from_component "${requested_profiles}" "${mem_pprof_flags}" "${binary}" "${tunnel_port}" "${path}" "${output_dir}/${component}" "${timestamp}"
|
grab_profiles_from_component "${requested_profiles}" "${mem_pprof_flags}" "${binary}" "${tunnel_port}" "${path}" "${output_dir}/${component}" "${timestamp}"
|
||||||
|
Loading…
Reference in New Issue
Block a user