mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	Make logdump work for GKE with 'use_custom_instance_list' defined
This commit is contained in:
		@@ -39,6 +39,7 @@ fi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
readonly master_ssh_supported_providers="gce aws"
 | 
					readonly master_ssh_supported_providers="gce aws"
 | 
				
			||||||
readonly node_ssh_supported_providers="gce gke aws"
 | 
					readonly node_ssh_supported_providers="gce gke aws"
 | 
				
			||||||
 | 
					readonly gcloud_supported_providers="gce gke"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
readonly master_logfiles="kube-apiserver kube-scheduler rescheduler kube-controller-manager etcd etcd-events glbc cluster-autoscaler kube-addon-manager fluentd"
 | 
					readonly master_logfiles="kube-apiserver kube-scheduler rescheduler kube-controller-manager etcd etcd-events glbc cluster-autoscaler kube-addon-manager fluentd"
 | 
				
			||||||
readonly node_logfiles="kube-proxy fluentd node-problem-detector"
 | 
					readonly node_logfiles="kube-proxy fluentd node-problem-detector"
 | 
				
			||||||
@@ -55,11 +56,6 @@ readonly systemd_services="kubelet docker"
 | 
				
			|||||||
# file descriptors for large clusters.
 | 
					# file descriptors for large clusters.
 | 
				
			||||||
readonly max_scp_processes=25
 | 
					readonly max_scp_processes=25
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This template spits out the external IPs and images for each node in the cluster in a format like so:
 | 
					 | 
				
			||||||
# 52.32.7.85 gcr.io/google_containers/kube-apiserver:1355c18c32d7bef16125120bce194fad gcr.io/google_containers/kube-controller-manager:46365cdd8d28b8207950c3c21d1f3900 [...]
 | 
					 | 
				
			||||||
echo "Obtaining IPs and images for cluster nodes"
 | 
					 | 
				
			||||||
readonly ips_and_images='{range .items[*]}{@.status.addresses[?(@.type == "ExternalIP")].address} {@.status.images[*].names[*]}{"\n"}{end}'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function setup() {
 | 
					function setup() {
 | 
				
			||||||
  if [[ -z "${use_custom_instance_list}" ]]; then
 | 
					  if [[ -z "${use_custom_instance_list}" ]]; then
 | 
				
			||||||
    KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
 | 
					    KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
 | 
				
			||||||
@@ -68,6 +64,8 @@ function setup() {
 | 
				
			|||||||
    source "${KUBE_ROOT}/cluster/kube-util.sh"
 | 
					    source "${KUBE_ROOT}/cluster/kube-util.sh"
 | 
				
			||||||
    echo "Detecting project"
 | 
					    echo "Detecting project"
 | 
				
			||||||
    detect-project 2>&1
 | 
					    detect-project 2>&1
 | 
				
			||||||
 | 
					  elif [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
 | 
				
			||||||
 | 
					    echo "Using 'use_custom_instance_list' with gke, skipping check for LOG_DUMP_SSH_KEY and LOG_DUMP_SSH_USER"
 | 
				
			||||||
  elif [[ -z "${LOG_DUMP_SSH_KEY:-}" ]]; then
 | 
					  elif [[ -z "${LOG_DUMP_SSH_KEY:-}" ]]; then
 | 
				
			||||||
    echo "LOG_DUMP_SSH_KEY not set, but required when using log_dump_custom_get_instances"
 | 
					    echo "LOG_DUMP_SSH_KEY not set, but required when using log_dump_custom_get_instances"
 | 
				
			||||||
    exit 1
 | 
					    exit 1
 | 
				
			||||||
@@ -105,20 +103,17 @@ function copy-logs-from-node() {
 | 
				
			|||||||
    # Comma delimit (even the singleton, or scp does the wrong thing), surround by braces.
 | 
					    # Comma delimit (even the singleton, or scp does the wrong thing), surround by braces.
 | 
				
			||||||
    local -r scp_files="{$(printf "%s," "${files[@]}")}"
 | 
					    local -r scp_files="{$(printf "%s," "${files[@]}")}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ -n "${use_custom_instance_list}" ]]; then
 | 
					    if [[ "${gcloud_supported_providers}" =~ "${KUBERNETES_PROVIDER}" ]]; then
 | 
				
			||||||
      scp -oLogLevel=quiet -oConnectTimeout=30 -oStrictHostKeyChecking=no -i "${LOG_DUMP_SSH_KEY}" "${LOG_DUMP_SSH_USER}@${node}:${scp_files}" "${dir}" > /dev/null || true
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      case "${KUBERNETES_PROVIDER}" in
 | 
					 | 
				
			||||||
        gce|gke)
 | 
					 | 
				
			||||||
      # get-serial-port-output lets you ask for ports 1-4, but currently (11/21/2016) only port 1 contains useful information
 | 
					      # get-serial-port-output lets you ask for ports 1-4, but currently (11/21/2016) only port 1 contains useful information
 | 
				
			||||||
      gcloud compute instances get-serial-port-output --project "${PROJECT}" --zone "${ZONE}" --port 1 "${node}" > "${dir}/serial-1.log" || true
 | 
					      gcloud compute instances get-serial-port-output --project "${PROJECT}" --zone "${ZONE}" --port 1 "${node}" > "${dir}/serial-1.log" || true
 | 
				
			||||||
      gcloud compute scp --recurse --project "${PROJECT}" --zone "${ZONE}" "${node}:${scp_files}" "${dir}" > /dev/null || true
 | 
					      gcloud compute scp --recurse --project "${PROJECT}" --zone "${ZONE}" "${node}:${scp_files}" "${dir}" > /dev/null || true
 | 
				
			||||||
          ;;
 | 
					    elif  [[ "${KUBERNETES_PROVIDER}" == "aws" ]]; then
 | 
				
			||||||
        aws)
 | 
					 | 
				
			||||||
      local ip=$(get_ssh_hostname "${node}")
 | 
					      local ip=$(get_ssh_hostname "${node}")
 | 
				
			||||||
      scp -oLogLevel=quiet -oConnectTimeout=30 -oStrictHostKeyChecking=no -i "${AWS_SSH_KEY}" "${SSH_USER}@${ip}:${scp_files}" "${dir}" > /dev/null || true
 | 
					      scp -oLogLevel=quiet -oConnectTimeout=30 -oStrictHostKeyChecking=no -i "${AWS_SSH_KEY}" "${SSH_USER}@${ip}:${scp_files}" "${dir}" > /dev/null || true
 | 
				
			||||||
          ;;
 | 
					    elif  [[ -n "${use_custom_instance_list}" ]]; then
 | 
				
			||||||
      esac
 | 
					      scp -oLogLevel=quiet -oConnectTimeout=30 -oStrictHostKeyChecking=no -i "${LOG_DUMP_SSH_KEY}" "${LOG_DUMP_SSH_USER}@${node}:${scp_files}" "${dir}" > /dev/null || true
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      echo "Unknown cloud-provider '${KUBERNETES_PROVIDER}' and use_custom_instance_list is unset too - skipping logdump for '${node}'"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user