calico: Calico Node Pod Failing - cni-installer/ : Unable to create token for CNI kubeconfig error=Unauthorized
Fresh Calico Operator(v3.27.0) Installation in 1.24 EKS cluster.
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/tigera-operator.yaml
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-6bf98f54bb-bqtmq 1/1 Running 0 15h
calico-node-47bvv 0/1 Init:CrashLoopBackOff 167 (75s ago) 13h
calico-node-7wll8 0/1 Init:CrashLoopBackOff 2 (23s ago) 70s
calico-node-br5qp 0/1 Init:CrashLoopBackOff 6 (2m26s ago) 8m16s
calico-node-gln78 0/1 Init:CrashLoopBackOff 8 (5m13s ago) 22m
calico-typha-5d4689887f-s9qkr 1/1 Running 0 15h
calico-typha-5d4689887f-wdgdg 1/1 Running 0 15h
csi-node-driver-26z8d 2/2 Running 0 15h
csi-node-driver-pzlhk 2/2 Running 0 15h
csi-node-driver-r4jtl 2/2 Running 0 71s
csi-node-driver-x8qn4 2/2 Running 0 15h
Expected Behavior
All Pods should we be running state
Current Behavior
calico-node pod throwing this Error.
2023-12-21 08:32:31.622 [ERROR][1] cni-installer/<nil> <nil>: Unable to create token for CNI kubeconfig error=Unauthorized
2023-12-21 08:32:31.622 [FATAL][1] cni-installer/<nil> <nil>: Unable to create token for CNI kubeconfig error=Unauthorized
Possible Solution
Steps to Reproduce (for bugs)
It’s Fresh installation
2023-12-21 08:32:31.622 [ERROR][1] cni-installer/<nil> <nil>: Unable to create token for CNI kubeconfig error=Unauthorized
2023-12-21 08:32:31.622 [FATAL][1] cni-installer/<nil> <nil>: Unable to create token for CNI kubeconfig error=Unauthorized
Context
Your Environment
- Calico version - v3.27.0
- Orchestrator version (e.g. kubernetes, mesos, rkt): EKS 1.24
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 30 (12 by maintainers)
For anyone encountering this issue, please run the following command to determine if your cluster’s RBAC is correct:
This should return
yes, indicating that calico-node is allowed to create tokens for the CNI plugin. If this returnsyes, then Calico’s RBAC is configured correctly and theUnauthorizedlikely means something else - for example, bad certificates being provided to the containers.If this returns
no, that indicates that something is wrong with the RBAC in the cluster.@oniubi please see this comment: https://github.com/projectcalico/calico/issues/8368#issuecomment-2120873448
If that doesn’t help, then please raise a new issue.
@ajaypraj
what address is
172.16.0.1:443attached to? as errordial tcp 172.16.0.1:443: i/o timeout\n"may be the issue and seperate to calicoother command that may assist in fault finding:
kubectl get endpoints -Aiptables -nvLpay particular attention to the chains prefixed withKUBE-i.e.KUBE-FORWARDcurl -k https://<service ip for kubernetes.default >:443/apishould return JSON stating unauthorized access. this is good as it shows api connectivity OK.This command checks if the CNI plugin has the necessary permissions. If it does not, it means the ClusterRole, ClusterRoleBinding, or ServiceAccount are not correctly configured or installed on the cluster.
For anyone experiencing this, please first verify that the Calico CNI plugin RBAC resources exist on the cluster:
If any of those do not exist, it means the tigera/operator is struggling to create them for some reason. Please look at the tigera-operator logs, and the output from
kubectl describe tigerastatus calicoto see what the issue might be.If those resources do exist, the next thing to check is whether they are stuck in a
Terminatingstate or not. You can do this by checking thedeletionTimestampfield on each of them.If you see a
deletionTimestmpfield on any of them, it means that the resource is trying to be deleted but is stuck. In this case, you need to edit each resource to remove thecni-protectorentry from thefinalizersfield to allow the resources to terminate and the tigera-operator to re-create them. Once that is done, you can restart calico/node and things should start to function.This is a result of a bug that is triggered often when deleting / re-creating the
Installationresource, or manually deleting the RBAC resources by hand. The former has been fixed in v3.28, and the latter should be simply be avoided. If you do need to delete these by hand without deleting theInstallation, know that you will need to manually remove the finalizer and that they will be recreated by the operator.@caseydavenport I am running on AWS (but not EKS)