Kubernetes: kubectl returns 404 not found when fetch pod logs

5/10/2016

I'm trying to get logs from my pod, but it doesn't work for some reason though kubectl describe pod works well, docker logs works well. I have Kubernetes 1.2.3 Debian 8 x64 installed manually on a single node

  $ kubectl logs -f web-backend-alzc1 --namespace=my-namespace --v=6
  round_trippers.go:286] GET http://localhost:8080/api 200 OK in 0 milliseconds
  round_trippers.go:286] GET http://localhost:8080/apis 200 OK in 0 milliseconds
  round_trippers.go:286] GET http://localhost:8080/api/v1/namespaces/my-namespace/pods/web-backend-alzc1 200 OK in 1 milliseconds
  round_trippers.go:286] GET http://localhost:8080/api 200 OK in 0 milliseconds
  round_trippers.go:286] GET http://localhost:8080/apis 200 OK in 0 milliseconds
  round_trippers.go:286] GET http://localhost:8080/api/v1/namespaces/my-namespace/pods/web-backend-alzc1/log?follow=true 404 Not Found in 1 milliseconds
  helpers.go:172] server response object: [{
    "metadata": {},
    "status": "Failure",
    "message": "the server could not find the requested resource ( pods/log web-backend-alzc1)",
    "reason": "NotFound",
    "details": {
      "name": "web-backend-alzc1",
      "kind": "pods/log"
    },
    "code": 404
  }]
  helpers.go:107] Error from server: the server could not find the requested resource ( pods/log web-backend-alzc1)

Is there something I should describe in RC scheme to enable logs for this pod?

I tried to recreate RC and look at journalctl, I see these messages:

  hyperkube[443]: I0510 12:14:13.754922     443 hairpin.go:51] Unable to find pair interface, setting up all interfaces: exec: "ethtool": executable file not found in $PATH
  hyperkube[443]: I0510 12:14:13.756866     443 provider.go:91] Refreshing cache for provider: *credentialprovider.defaultDockerConfigProvider
  hyperkube[435]: W0510 12:14:38.835863     435 request.go:344] Field selector: v1 - serviceaccounts - metadata.name - default: need to check if this is versioned correctly.
-- chingis
kubernetes

1 Answer

5/11/2016

This is caused by the --enable-debugging-handlers flag being set to false, which prevents the kubelet from attaching to containers and fetching the logs. Restarting the kubelet without this flag (it defaults to true) should fix it.

-- Tim Allclair
Source: StackOverflow