K8S - 各节点的kube-flannel-ds-amd64-xxxxx不能正常启动的问题

- kubectl get pods -A -o wide

- 查看日志发现

  • pods "kube-flannel-ds-amd64-xxxxx" is forbidden: User "system:serviceaccount:kube-system:flannel" cannot get resource "pods" in API group "" in the namespace "kube-system"

  • 也就是说flannel用户不能访问kube-system空间下的pods资源

  • 但kube-flannel空间下的pod都正常,说明这个集群角色绑定需要再把kube-system空间再绑一下即可

  • kubectl describe clusterrolebinding -A

    kubectl get clusterrole -A |grep flannel

    flannel

    kubectl describe clusterrole flannel

    Name: flannel
    Labels: k8s-app=flannel
    Annotations: <none>
    PolicyRule:
    Resources Non-Resource URLs Resource Names Verbs
    --------- ----------------- -------------- -----
    nodes [] [] [get list watch]
    pods [] [] [get]
    clustercidrs.networking.k8s.io [] [] [list watch]
    nodes/status [] [] [patch]

  • 查到有一个clusterrole=flannel 集群角色,直接给他们绑定即可

    • kubectl create clusterrolebinding add-on-flannel
    • --clusterrole=flannel
    • --serviceaccount=kube-system:flannel

kubectl describe clusterrolebinding -A

  • #新添加的clusterrolebinding将flannel用户绑定到了kube-system空间,解决上面的异常

  • Name: add-on-flannel

  • Labels: <none>

  • Annotations: <none>

  • Role:

  • Kind: ClusterRole

  • Name: flannel

  • Subjects:

  • Kind Name Namespace

  • ServiceAccount flannel kube-system

  • #之前有一个clusterrolebinding将flannel用户绑定到了kube-flannel空间

  • Name: flannel

  • Labels: k8s-app=flannel

  • Annotations: <none>

  • Role:

  • Kind: ClusterRole

  • Name: flannel

  • Subjects:

  • Kind Name Namespace

  • ServiceAccount flannel kube-flannel

  • 三个节点上的kube-flannel-ds-amd64-xxxxx容器过会都自动启动了

参考:k8s--普通k8s集群---使用rolebinding限制或增加访问命名空间以及可执行操作权限-CSDN博客

相关推荐
zyu671 小时前
03-Docker存储和网络
网络·docker·容器
正在学习前端的---小方同学1 小时前
Harbor部署教程
linux·运维
牛奔2 小时前
Docker Compose 两种安装与使用方式详解(适用于 Docker 19.03 版本)
运维·docker·云原生·容器·eureka
Sean X2 小时前
Ubuntu24.04安装向日葵
linux·ubuntu
木童6623 小时前
Kubernetes 操作管理完全指南:从陈述式到声明式,覆盖全生命周期
云原生·容器·kubernetes
IT 乔峰4 小时前
脚本部署MHA集群
linux·shell
dz小伟4 小时前
execve() 系统调用深度解析:从用户空间到内核的完整加载过程
linux
不想画图4 小时前
Kubernetes(三)——组网概念和基础操作指令
云原生·容器·kubernetes
Mr_Xuhhh4 小时前
博客标题:深入理解Shell:从进程控制到自主实现一个微型Shell
linux·运维·服务器
JoyCheung-4 小时前
Free底层是怎么释放内存的
linux·c语言