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

  

上一篇:如何将匿名类(不是实例)作为参数传递给期望Java中类型为Class的方法


下一篇:在JavaScript中为匿名函数放置参数