在Cluster Config中部署在非默认名称空间中时无法获取pod [英] In Cluster Config is unable to get pods when deployed in a non-default namespace

查看:55
本文介绍了在Cluster Config中部署在非默认名称空间中时无法获取pod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将golang服务部署到除 default 名称空间以外的任何名称空间时,该服务将无法检索任何名称空间上的Pod.使用golang client-go api,部署在 default 命名空间上的同一服务可以完美运行.

When I deploy my golang service to any namespace but the default namespace, the service is unable to retrieve pods on any namespace. The same service deployed on the default namespace works perfectly, using the golang client-go api.

这是一个安全问题吗?

谢谢.

推荐答案

此问题是权限问题.由于您正在使用 rest.InClusterConfig(config)创建客户端.这意味着它使用pod的服务帐户作为凭据.因此,请检查该服务帐户是否具有在任何名称空间中获取Pod的权限.

This issue is permission issue. Since you are using rest.InClusterConfig(config) to create client. That means it using pod's service account as credential. So check whether that service account has the permission to get pods in any namespace.

如果未定义广告连播中的服务帐户,则它将使用默认服务帐户.

如果您的集群中启用了RBAC,请检查该命名空间中的角色绑定,以了解您的服务帐户是否具有该权限.

If RBAC is enabled in your cluster, then check the role binding in that namespace, to find out whether your service account has the permission.

# to see the list of role bindings in 'default' namespace
kubectl get rolebindings --namespace default

查看特定的角色绑定

kubectl get rolebindings ROLE-BINDING-NAME --namespace default -o yaml

还可以创建角色和角色绑定以授予权限.要了解RBAC角色和角色绑定,请参见此处: https://kubernetes.io/docs/reference/access-authn-authz/rbac/

Also you can create role and role binding to give permission. To know about RBAC role and role binding see here: https://kubernetes.io/docs/reference/access-authn-authz/rbac/

这篇关于在Cluster Config中部署在非默认名称空间中时无法获取pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆