在查看pod出现问题的时候,我们需要查看日志describe,或者logs来查看
查看pod日志
[root@k8s-master1 ~]# kubectl logs nginx-7cdbd8cdc9-2qrcw
Error from server (Forbidden): Forbidden (user=system:anonymous, verb=get, resource=nodes, subresource=proxy) ( pods/log nginx-7cdbd8cdc9-2qrcw)
如果出现报错这里说明缺少一个默认的绑定集群的角色
定义/opt/kubernetes/cfg/kubelet.config
追加以下配置
authentication:
anonymous:
enabled: true
并创建赋予系统集群一个角色
[root@k8s-master1 ~]# kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous
再次查看pod日志,成功输出
[root@k8s-master1 ~]# kubectl logs nginx-7cdbd8cdc9-2qrcw
172.17.55.0 - - [18/Jul/2019:08:08:22 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
172.17.55.0 - - [18/J