如何在kubernetes集群中实现GCloud IAM角色的权限?

时间:2019-03-22 19:43:46

标签: kubernetes google-cloud-platform google-kubernetes-engine rbac google-iam

我正在GKE上运行Kubernetes应用程序。在GCP IAM控制台中,我可以看到几个内置角色,例如Imports System Imports System.Data Imports System.Linq Module Program Sub Main(args As String()) Dim MyTable As DataTable = New DataTable() MyTable.Columns.Add("Key", System.Type.GetType("System.Int32")) MyTable.Columns.Add("Enabled", System.Type.GetType("System.String")) Dim Row1 As DataRow Row1 = MyTable.NewRow() Row1.Item("Key") = 1 Row1.Item("Enabled") = "true" MyTable.Rows.Add(Row1) Dim Row2 As DataRow Row2 = MyTable.NewRow() Row2.Item("Key") = 2 Row2.Item("Enabled") = "True" MyTable.Rows.Add(Row2) Dim Row3 As DataRow Row3 = MyTable.NewRow() Row3.Item("Key") = 3 Row3.Item("Enabled") = "False" MyTable.Rows.Add(Row3) 'I wish this would work but I assume that the DataTable object's Filter method doesn't support embedded .NEt Functions? Dim MyFilteredTable As DataTable = Test(MyTable, "[Enabled].ToUpper ='TRUE'") 'So I am forced to check for reasonably likely literal combinations MyFilteredTable = Test(MyTable, "[Enabled] ='True' OR [Enabled] ='TRUE' OR [Enabled] ='true'") End Sub Private Function Test(Collection_In As DataTable, Select_Condition As String) Dim Collection_Out As DataTable Dim NewRow As DataRow Collection_Out = Collection_In.Clone For Each parentRow As DataRow In Collection_In.Select(Select_Condition) NewRow = Collection_Out.NewRow For Each c As DataColumn In NewRow.Table.Columns NewRow(c.ColumnName) = parentRow(c.ColumnName) Next Collection_Out.Rows.Add(NewRow) Next NewRow = Nothing Collection_In = Nothing Return Collection_Out End Function End Module 。每个角色都有一个ID和与其相关的权限-例如,Kubernetes Engine Admin具有ID Kubernetes Engine Admin和〜300个权限,每个权限都类似于roles/container.admin

在kubernetes集群中,我可以运行:

container.apiServices.create

这将返回以下内容:

kubectl get clusterrole | grep -v system:  # exclude system roles

我在此表中没有看到任何可反映GCP IAM中角色的角色。

在这种情况下,如何在群集中实施/加强GCP IAM角色?在进行权限检查时,除了使用RBAC之外,Kubernetes是否还会与GCP对话?

2 个答案:

答案 0 :(得分:0)

RBAC系统使您可以对用户访问群集上运行的API资源的方式进行细粒度控制。您可以使用RBAC为集群用户动态配置权限,并定义他们可以与之交互的资源的类型。

此外,GKE还使用Cloud Identity and Access Management (IAM)来控制对集群的访问。

希望这会有所帮助!

答案 1 :(得分:0)

RBAC继承了IAM的权限,因此请当心。例如,如果您在IAM中设置了集群管理员权限,则将无法通过RBAC授予更少的权限。

如果要使用RBAC,则需要为用户设置最低的权限(给定用例),然后通过RBAC精细地管理权限。