What is POD and SERVICE in kubectl commands?

10/5/2016

I am probably missing some of the basic. kubectl logs command usage is the following:

"kubectl logs [-f] [-p] POD [-c CONTAINER] [options]"

list of my pods is the following:

ubuntu@master:~$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                    READY     STATUS             RESTARTS   AGE
kube-system   etcd-master                             1/1       Running            0          24m
kube-system   kube-apiserver-master                   1/1       Running            0          24m
kube-system   kube-controller-manager-master          1/1       Running            0          24m
kube-system   kube-discovery-982812725-3kt85          1/1       Running            0          24m
kube-system   kube-dns-2247936740-kimly               3/3       Running            0          24m
kube-system   kube-proxy-amd64-gwv99                  1/1       Running            0          20m
kube-system   kube-proxy-amd64-r08h9                  1/1       Running            0          24m
kube-system   kube-proxy-amd64-szl6w                  1/1       Running            0          14m
kube-system   kube-scheduler-master                   1/1       Running            0          24m
kube-system   kubernetes-dashboard-1655269645-x3uyt   1/1       Running            0          24m
kube-system   weave-net-4g1g8                         1/2       CrashLoopBackOff   7          14m
kube-system   weave-net-8zdm3                         1/2       CrashLoopBackOff   8          20m
kube-system   weave-net-qm3q5                         2/2       Running            0          24m

I assume POD for logs command is anything from the second "name" column above. So, I try the following commands.

ubuntu@master:~$ kubectl logs etcd-master
Error from server: pods "etcd-master" not found
ubuntu@master:~$ kubectl logs weave-net-4g1g8
Error from server: pods "weave-net-4g1g8" not found
ubuntu@master:~$ kubectl logs weave-net
Error from server: pods "weave-net" not found
ubuntu@master:~$ kubectl logs weave
Error from server: pods "weave" not found

So, what is the POD in the logs command?

I have got the same question about services as well. How to identify a SERVICE to supply into a command, for example for 'describe' command?

ubuntu@master:~$ kubectl get services --all-namespaces
NAMESPACE     NAME                   CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
default       kubernetes             100.64.0.1      <none>        443/TCP         40m
kube-system   kube-dns               100.64.0.10     <none>        53/UDP,53/TCP   39m
kube-system   kubernetes-dashboard   100.70.83.136   <nodes>       80/TCP          39m

ubuntu@master:~$ kubectl describe service kubernetes-dashboard
Error from server: services "kubernetes-dashboard" not found
ubuntu@master:~$ kubectl describe services kubernetes-dashboard
Error from server: services "kubernetes-dashboard" not found

Also, is it normal that weave-net-8zdm3 is in CrashLoopBackOff state? It seems I have got one for each connected worker. If it is not normal, how can I fix it? I have found similar question here: kube-dns and weave-net not starting but it does not give any practical answer.

Thanks for your help!

-- Andrew
kubernetes

1 Answer

10/5/2016

It seems you are running your pods in a different namespace than default.

ubuntu@master:~$ kubectl get pods --all-namespaces returns your pods but ubuntu@master:~$ kubectl logs etcd-masterreturns not found. Try running kubectl logs etcd-master --all-namespaces or if you know your namespace kubectl logs etcd-mastern --namespace=mynamespace.

The same thing goes for your services.

-- Dan Hoerst
Source: StackOverflow