Skip to content

Commit

Permalink
Merge pull request kubernetes#977 from mm4tt/apiserver_profiles
Browse files Browse the repository at this point in the history
Fix scraping kube-apiserver pprofs
  • Loading branch information
k8s-ci-robot authored Jan 9, 2020
2 parents 76de3c3 + 8a1cf4b commit b000148
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions clusterloader2/pkg/measurement/common/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,21 @@ func (p *profileMeasurement) gatherProfile(c clientset.Interface) ([]measurement
for _, host := range p.config.hosts {
profilePrefix := fmt.Sprintf("%s_%s_%s", host, p.config.componentName, p.name)

if p.config.componentName == "kube-apiserver" {
body, err := c.CoreV1().RESTClient().Get().AbsPath("/debug/pprof/" + p.config.kind).DoRaw()
if err != nil {
return nil, err
}
summary := measurement.CreateSummary(profilePrefix, "pprof", string(body))
summaries = append(summaries, summary)
break
}

// Get the profile data over SSH.
// Start by checking that the provider allows us to do so.
if p.config.provider == "gke" {
// SSH to master is not possible in gke, but if the component is
// kube-apiserver we can get the profile via k8s client.
// TODO(#246): This will connect to a random master in HA (multi-master) clusters, fix it.
if p.config.componentName == "kube-apiserver" {
body, err := c.CoreV1().RESTClient().Get().AbsPath("/debug/pprof/" + p.config.kind).DoRaw()
if err != nil {
return nil, err
}
summary := measurement.CreateSummary(profilePrefix, "pprof", string(body))
summaries = append(summaries, summary)
break
}
// Only logging error for gke. SSHing to gke master is not supported.
klog.Warningf("%s: failed to execute curl command on master through SSH", p.name)
return nil, nil
Expand All @@ -205,10 +207,12 @@ func getPortForComponent(componentName string) (int, error) {
switch componentName {
case "etcd":
return 2379, nil
case "kube-scheduler":
return 10251, nil
case "kube-apiserver":
return 443, nil
case "kube-controller-manager":
return 10252, nil
case "kube-scheduler":
return 10251, nil
}
return -1, fmt.Errorf("port for component %v unknown", componentName)
}

0 comments on commit b000148

Please sign in to comment.