Can't access pod logs

I am trying to access the logs of a pod in a kubernetes cluster but get a 404 on sending the following rest request:

GET api/namespaces/myNamespace/pods/myPod/log

  • docker cp not working
  • How do you define a network in a version 2 docker-compose definition file?
  • What process signal does pod receive when executing `kubectl rolling-update`?
  • How to Add Docker to Django + Gunicorn + Nginx + Fabric
  • Update docker container when new image is getting released
  • How to run Alfresco Bundled Installer on Docker?
  • When I try to see the status of the pod I get the following:

    "metadata": {
            "name": "podtest",
            "generateName": "podtest-",
            "namespace": "podtest01734160-58f9-4042-8f38-3e55d7d5beb3",
            "selfLink": "/api/v1/namespaces/podtest01734160-58f9-4042-8f38-3e55d7d5beb3/pods/podtest-rc-no-env-hc5rl",
            "uid": "dba5c41f-8307-11e5-96f2-005056976c6f",
            "resourceVersion": "3595515",
            "creationTimestamp": "2015-11-04T15:22:27Z",
            "labels": {
              "name": "kube-pod"
            },
            "annotations": {
              "kubernetes.io/created-by": "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"ReplicationController\",\"namespace\":\"podtest01734160-58f9-4042-8f38-3e55d7d5beb3\",\"name\":\"podtest-rc-no-env\",\"uid\":\"dba55f97-8307-11e5-96f2-005056976c6f\",\"apiVersion\":\"v1\",\"resourceVersion\":\"3594964\"}}"
            }
          },
          "spec": {
            "containers": [
              {
                "name": "podtest01734160-58f9-4042-8f38-3e55d7d5beb3",
                "image": "dockertest",
                "resources": {},
                "terminationMessagePath": "/dev/termination-log",
                "imagePullPolicy": "IfNotPresent"
              }
            ],
            "restartPolicy": "Always",
            "dnsPolicy": "ClusterFirst",
            "nodeName": "node-n2"
          },
          "status": {
            "phase": "Running",
            "conditions": [
              {
                "type": "Ready",
                "status": "True"
              }
            ],
            "hostIP": "172.29.225.12",
            "podIP": "10.20.96.20",
            "startTime": "2015-11-04T15:25:51Z",
            "containerStatuses": [
              {
                "name": "podtest01734160-58f9-4042-8f38-3e55d7d5beb3",
                "state": {
                  "running": {
                    "startedAt": "2015-11-04T15:28:43Z"
                  }
                },
                "lastState": {},
                "ready": true,
                "restartCount": 0,
                "image": "dockertest",
                "imageID": "docker://62457b12fc411b13fcaa122a946aefcac0c66df05ce1158d8d618ebe3af95362",
                "containerID": "docker://baea3dc8cd7129704e205c76bf4ca57635659fec22774fcdcf197fb5c75ab433"
              }
            ]
          }
        },
    

    Why can’t I get to the logs?

  • Lets encrypt failed authorization procedure - docker
  • Cannot connect to Docker daemon in Azure Container Service
  • Ubuntu docker container with upstart and syslog
  • redirect log files created in a docker container to stdout / stderr
  • Link docker-compose to local docker daemon
  • docker swarm stop containers on quorum loss
  • 3 Solutions collect form web for “Can't access pod logs”

    This works from me /api/v1/namespaces/myNamespace/pods/myPod/log

    Yours doesn’t have the api version.

    I found these;
    When the pod status changes to Running you can use the kubectl logs command to view the output.

    kubectl logs podname

    https://github.com/kubernetes/kubernetes/blob/master/docs/getting-started-guides/logging.md

    kubectl cluster-info

    http://kubernetes.io/v1.0/docs/user-guide/accessing-the-cluster.html#accessing-the-api-from-a-pod
    How do I access the Kubernetes api from within a pod container?

    try
    GET api/v1/namespaces/”podtest01734160-58f9-4042-8f38-3e55d7d5beb3″/pods/myPod/log

    there are two points need to be aware:
    1. in metadata it shows “namespace”: “podtest01734160-58f9-4042-8f38-3e55d7d5beb3” but it is not myNamespace,
    2. as the answer from iocanel, the api version is necessary, more info
    could be check here :
    kubernetes.io/v1.1/docs/api-reference/v1/operations.html

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.