I recently created a cluster on EKS with eksctl. kubectl logs -f mypod-0
bumps into Authorization error:
Error from server (InternalError): Internal error occurred: Authorization error (user=kube-apiserver-kubelet-client, verb=get, resource=nodes, subresource=proxy)
Any advice and insight is appreciated
To get Kubectl pod logs, you can access them by adding the -p flag. Kubectl will then get all of the logs stored for the pod. This includes lines that were emitted by containers that were terminated.
Kubernetes authorizes API requests using the API server. It evaluates all of the request attributes against all policies and allows or denies the request. All parts of an API request must be allowed by some policy in order to proceed. This means that permissions are denied by default.
The default logging tool is the command ( kubectl logs ) for retrieving logs from a specific pod or container. Running this command with the --follow flag streams logs from the specified resource, allowing you to live tail its logs from your terminal.
You would need to create a ClusterRoleBinding with a Role pointing towards the user : kube-apiserver-kubelet-client
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: kubelet-api-admin
subjects:
- kind: User
name: kube-apiserver-kubelet-client
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: system:kubelet-api-admin
apiGroup: rbac.authorization.k8s.io
kubelet-api-admin is usually a role that has the necessary permissions, but you can replace this with an apt role.
On a prem cluster, I had an issue where I changed the DNS address of the master. You will need to change the dns name in the /etc/kubernetes/kubelet.conf
on each node then sudo systemctl restart kublet.service.
I could solve this issue by editing the aws-auth
configmap. I added the clusterrole system:node
in the worker role.
apiVersion: v1
data:
mapRoles: |
- rolearn: 'WORKER ROLE'
username: 'NAME'
groups:
- ...
- system:nodes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With