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博客

相关推荐
fengyehongWorld2 小时前
TeraTerm ttl脚本登录wsl
linux·teraterm
乌托邦的逃亡者2 小时前
Linux中如何检测IP冲突
linux·运维·tcp/ip
一曦的后花园2 小时前
linux搭建promethes并对接node-exporter指标
linux·运维·服务器
乌托邦的逃亡者3 小时前
CentOS/Openeuler主机中,为一个网卡设置多个IP地址
linux·运维·网络·tcp/ip·centos
念恒123064 小时前
进程控制---自定义Shell
linux·c语言
Java后端的Ai之路4 小时前
Kubernetes是什么?(小白入门版)
云原生·容器·kubernetes·教程
风曦Kisaki4 小时前
# Linux Shell 编程入门 Day02:条件测试、if 判断、循环与随机数
linux·运维·chrome
木雷坞4 小时前
视觉算法环境 Docker 镜像拉取失败排查
运维·人工智能·docker·容器
李日灐4 小时前
< 6 > Linux 自动化构建工具:makefile 详解 + 进度条实战小项目
linux·运维·服务器·后端·自动化·进度条·makefile
瀚高PG实验室5 小时前
安全版V4.5版本docker容器license过期问题处理步骤
安全·docker·容器·瀚高数据库