calico: Failed to create pod sandbox: rpc - error getting ClusterInformation connection is unauthorized: Unauthorized

I have K8S up and running and able to deploy and run different Pods/containers. Today, I tried to deply mysql to it with PVC and PV After deploying, container get stuck in “ContainerCreating” status, gets terminated and recreated

When I d describe Pod I see this

Events:
  Type     Reason                  Age               From               Message
  ----     ------                  ----              ----               -------
  Normal   Scheduled               61s               default-scheduler  Successfully assigned default/mysql-74799d694c-j4mcr to chef-u16desk
  Warning  FailedCreatePodSandBox  60s               kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "d9f4c91394d548cca1b189e665fd0532f158bb5bb4407153aa48e1af40afe2f0": plugin type="calico" failed (add): error getting ClusterInformation: connection is unauthorized: Unauthorized
  Normal   SandboxChanged          5s (x5 over 60s)  kubelet            Pod sandbox changed, it will be killed and re-created.

Expected Behavior

Pod should run with persistent volume

Current Behavior

Pod get stuck in “ContainerCreating” status

Context

Enclosed the yaml files mysql-storage.txt mysql-deployment.txt for PV, PVC and mysql deployment

Your Environment

Calico version : as indicated above I used https://raw.githubusercontent.com/projectcalico/calico/master/manifests/calico.yaml Orchestrator version: kubernetes 1.26 Operating System and version: ubuntu 22.04

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 31 (23 by maintainers)

Most upvoted comments

Here is a small workaround script to monitor the problem, and kill the pods

while true; 
  do 
    kubectl get events --all-namespaces -o json --watch --watch-only | \
    jq 'select(.message | test(".*error getting ClusterInformation.*")) | .reportingInstance'  --unbuffered | \
    while read line; do 
      kubectl -n calico-system get pods --selector app.kubernetes.io/name=calico-node-windows; 
      kubectl -n calico-system delete pod --selector app.kubernetes.io/name=calico-node-windows --force;
      date;
    done; 
done

@coutinhop any workarounds? it is getting quite annoying to have to fix this manually every single day

Aha, yes that’s important context if it’s only happening on Windows nodes. Likely a bug in how the token refresh works on Windows nodes (or perhaps isn’t being enabled on Windows nodes?). CC @coutinhop

I had same problem after upgrade to 3.27.0, but a complete restart of calico solved it:

kubectl delete pods --all -n calico-system --force

@eliassal I’m curious how you ended up installing the newest code from github (back in ~April) rather than a production release - do you remember where you started installing from?

Generally speaking everyone should stick with a stable release unless you’re testing something out that hasn’t been released yet. https://docs.tigera.io/calico/latest/about/ has the docs for the current release (v3.27.0)

Restarting the node suggests there was some temporary state in place that had expired and was refreshed on reboot. The most likely thing would be the CNI plugin’s bearer token.

What version of Calico do you have installed?

e.g.,

kubectl get clusterinformations -o yaml

Newer versions of Calico should automatically update the token to prevent cases like this starting in v3.24 it seems: https://github.com/projectcalico/calico/pull/5910

However, you would need to be on v3.24 or greater and also have properly updated manifests that volume mount the necessary CNI configuration directory into calico/node so that it can provide refreshed tokens to the CNI plugin. Otherwise, I think the tokens expire after about a year.