其他分享
首页 > 其他分享> > kubernetes logs 命令错误记录

kubernetes logs 命令错误记录

作者:互联网

[root@k8s-master ~]# kubectl logs nginx-dbddb74b8-j9rdf
error: You must be logged in to the server (the server has asked for the client to provide credentials ( pods/log nginx-dbddb74b8-j9rdf))
解决办法修改:/opt/kubernetes/cfg/kubelet.config添加
authentication:
  anonymous:
    enabled: true
 [root@k8s-node1 cfg]# cat kubelet.config 
kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
address: 192.168.1.120
port: 10250
cgroupDriver: cgroupfs
clusterDNS:
- 10.0.0.2 
clusterDomain: cluster.local.
failSwapOn: false
authentication:
  anonymous:
    enabled: true

[root@k8s-master ~]# kubectl logs nginx-dbddb74b8-j9rdf
Error from server (Forbidden): Forbidden (user=system:anonymous, verb=get, resource=nodes, subresource=proxy) ( pods/log nginx-dbddb74b8-j9rdf)
解决办法:将system:anonymous绑定到cluster-admin角色中 起个cluster-system:anonymous名字
[root@k8s-master ~]# kubectl create clusterrolebinding cluster-system:anonymous --clusterrole=cluster-admin --user=system:anonymous
clusterrolebinding.rbac.authorization.k8s.io/cluster-system:anonymous created

  

标签:logs,错误,dbddb74b8,system,j9rdf,cluster,anonymous,kubernetes,k8s
来源: https://www.cnblogs.com/caonw/p/11638408.html