qiangwum / blogs

0 stars 0 forks source link

k8s-dashborad pod is stack on CrashLoopBackOff #11

Open qiangwum opened 3 months ago

qiangwum commented 3 months ago

ubuntu@master:~$ kubectl logs kubernetes-dashboard-7b56f488df-qksf5 -n kube-system 2024/08/08 04:10:53 Starting overwatch 2024/08/08 04:10:53 Using namespace: kube-system 2024/08/08 04:10:53 Using in-cluster config to connect to apiserver 2024/08/08 04:10:53 Using secret token for csrf signing 2024/08/08 04:10:53 Initializing csrf token from kubernetes-dashboard-csrf secret panic: secrets "kubernetes-dashboard-csrf" is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot get resource "secrets" in API group "" in the namespace "kube-system"

goroutine 1 [running]: github.com/kubernetes/dashboard/src/app/backend/client/csrf.(csrfTokenManager).init(0xc00045fae8) /home/runner/work/dashboard/dashboard/src/app/backend/client/csrf/manager.go:41 +0x30e github.com/kubernetes/dashboard/src/app/backend/client/csrf.NewCsrfTokenManager(...) /home/runner/work/dashboard/dashboard/src/app/backend/client/csrf/manager.go:66 github.com/kubernetes/dashboard/src/app/backend/client.(clientManager).initCSRFKey(0xc000315280) /home/runner/work/dashboard/dashboard/src/app/backend/client/manager.go:527 +0x94 github.com/kubernetes/dashboard/src/app/backend/client.(*clientManager).init(0x19aba3a?) /home/runner/work/dashboard/dashboard/src/app/backend/client/manager.go:495 +0x32 github.com/kubernetes/dashboard/src/app/backend/client.NewClientManager(...) /home/runner/work/dashboard/dashboard/src/app/backend/client/manager.go:594 main.main() /home/runner/work/dashboard/dashboard/src/app/backend/dashboard.go:96 +0x1cf

ubuntu@master:~$ wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
--2024-08-08 04:07:46--  https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.111.133, 185.199.109.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4577 (4.5K) [text/plain]
Saving to: ‘kubernetes-dashboard.yaml’

kubernetes-dashboard.yaml                                   100%[========================================================================================================================================>]   4.47K  --.-KB/s    in 0.002s

2024-08-08 04:07:49 (2.87 MB/s) - ‘kubernetes-dashboard.yaml’ saved [4577/4577]

ubuntu@master:~$ grep image: kubernetes-dashboard.yaml
        image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
ubuntu@master:~$ sed -i s#k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1#swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/kubernetesui/dashboard:v2.7.0#g kubernetes-dashboard.yaml
ubuntu@master:~$ grep image: kubernetes-dashboard.yaml
        image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/kubernetesui/dashboard:v2.7.0
ubuntu@master:~$ kubectl apply -f kubernetes-dashboard.yaml
secret/kubernetes-dashboard-certs created
serviceaccount/kubernetes-dashboard created
role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
deployment.apps/kubernetes-dashboard created
service/kubernetes-dashboard created
ubuntu@master:~$ kubectl get pod -A
NAMESPACE     NAME                                      READY   STATUS             RESTARTS        AGE
kube-system   calico-kube-controllers-57b57c56f-jfxxf   1/1     Running            0               24h
kube-system   calico-node-2gswg                         1/1     Running            0               24h
kube-system   calico-node-4z84z                         1/1     Running            1 (4h19m ago)   24h
kube-system   calico-node-zb2nm                         1/1     Running            0               24h
kube-system   coredns-5bbd96d687-hhl6t                  1/1     Running            0               26h
kube-system   coredns-5bbd96d687-wkkd4                  1/1     Running            0               26h
kube-system   etcd-master                               1/1     Running            1               26h
kube-system   kube-apiserver-master                     1/1     Running            1               26h
kube-system   kube-controller-manager-master            1/1     Running            4 (4h19m ago)   26h
kube-system   kube-proxy-hrkvq                          1/1     Running            0               25h
kube-system   kube-proxy-kvnfl                          1/1     Running            0               25h
kube-system   kube-proxy-wn9pn                          1/1     Running            0               26h
kube-system   kube-scheduler-master                     1/1     Running            4 (4h19m ago)   26h
kube-system   kubernetes-dashboard-7b56f488df-qksf5     0/1     CrashLoopBackOff   1 (4s ago)      6s
kube-system   metrics-server-8696857f8b-78hvq           1/1     Running            1 (10h ago)     22h
qiangwum commented 3 months ago

I don't know exactly what is the root cause, I just changed another yaml and it works

qiangwum commented 3 months ago

the following command works kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml