5GSEC / 5G-Spector

An O-RAN compliant runtime intrusion detection system (xApp) for layer-3 (L3) celluar attack detection
https://www.5gsec.com
Apache License 2.0
35 stars 6 forks source link

K8s Certificate expired || error: You must be logged in to the server (Unauthorized) #7

Open bergen876 opened 1 day ago

bergen876 commented 1 day ago

I've discovered that the k8s certs have expired which has resulted in Kubectl failing with the titled error

image

Could you consider updating the VMs box image with the updated certificate?

However, I have included the following steps that I used to work around the issue.

**** Work Around ***

Firstly reset rke2 by running

sudo rke2 server --cluster-reset

Remove old data from the etcd data directory if you get a error when running the cluster reset
sudo rm -rf /var/lib/rancher/rke2/server/db/etcd image

The deployment uses rke2 as the Kubernetes manager. You will need to rotate the certificates there sudo rke2 certificate rotate

image

then restart rk2 by running

sudo systemctl restart rke2-server

Confirm that its started by sudo systemctl restart rke2-server

image

test that kubectl is working by running

sudo kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get pods --all-namespaces

Now to replace the Kubernetes configurations with the updated certificate information by modifying the Kube config file by updating it with the updated rke config

REPLACE vagrant@5g-spector:~/.kube$ config WITH /etc/rancher/rke2/rke2.yaml}

Test by running kubectl get pods -A

onehouwong commented 1 day ago

There seems to be another fix for this error: https://serverfault.com/questions/1032367/kubectl-get-nodes-error-you-must-be-logged-in-to-the-server-unauthorized-ho