查看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/Jul/2019:08:08:24 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"

172.17.55.0 - - [18/Jul/2019:08:08:27 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"

172.17.46.1 - - [18/Jul/2019:08:14:37 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"

 

.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0" "-"

172.17.46.1 - - [18/Jul/2019:08:52:25 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0" "-"

172.17.46.1 - - [18/Jul/2019:08:52:25 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0" "-"

172.17.46.1 - - [18/Jul/2019:08:52:25 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10

转载于:https://www.cnblogs.com/zc1741845455/p/11208332.html

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐