I setup kubernetes cluster by kubeadm, the pod network is flannel, I can get the log for pods which running on master.
$ kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
httpd-7448fc6b46-fgkp2 1/1 Running 0 1d 10.244.2.39 k8s-node2
httpd-7448fc6b46-njbh8 1/1 Running 0 1d 10.244.0.10 k8smaster
httpd-7448fc6b46-wq4zs 1/1 Running 0 1d 10.244.1.75 k8s-node1
$ kubectl logs httpd-7448fc6b46-njbh8
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.244.0.10. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.244.0.10. Set the 'ServerName' directive globally to suppress this message
[Wed Mar 21 10:10:21.568990 2018] [mpm_event:notice] [pid 1:tid 139992519874432] AH00489: Apache/2.4.32 (Unix) configured -- resuming normal operations
[Wed Mar 21 10:10:21.569204 2018] [core:notice] [pid 1:tid 139992519874432] AH00094: Command line: 'httpd -D FOREGROUND'
10.244.0.1 - - [21/Mar/2018:10:21:02 +0000] "GET / HTTP/1.1" 200 45
10.244.0.1 - - [21/Mar/2018:10:22:53 +0000] "GET / HTTP/1.1" 200 45
But I am unable to get the log of pod which running on slave node, the result looks like this:
"Error from server: Get https://192.168.18.111:10250/containerLogs/default/httpd-7448fc6b46-6pf7w/httpd?follow=true: cannotconnect"
How can I debug the issue? any ideas?
The issue has been solved, my cluster is behind the firewall and need to set proxy in order to download the image, so I set the proxy for the docker, but I didn't bypass the slave nodes when I set the proxy, so the request for the logs is mislead by the proxy setting in the docker.