Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
03e79876
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
03e79876
编写于
7月 31, 2020
作者:
H
hongming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
initial role differentiation of DevOps project and namespace
Signed-off-by:
N
hongming
<
talonwan@yunify.com
>
上级
74533cb5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
7 deletion
+15
-7
pkg/apis/iam/v1alpha2/types.go
pkg/apis/iam/v1alpha2/types.go
+2
-0
pkg/controller/namespace/namespace_controller.go
pkg/controller/namespace/namespace_controller.go
+11
-3
pkg/models/resources/v1alpha3/role/roles.go
pkg/models/resources/v1alpha3/role/roles.go
+2
-4
未找到文件。
pkg/apis/iam/v1alpha2/types.go
浏览文件 @
03e79876
...
...
@@ -60,6 +60,7 @@ const (
ClusterRoleAnnotation
=
"iam.kubesphere.io/clusterrole"
RoleAnnotation
=
"iam.kubesphere.io/role"
RoleTemplateLabel
=
"iam.kubesphere.io/role-template"
ScopeLabelFormat
=
"scope.kubesphere.io/%s"
UserReferenceLabel
=
"iam.kubesphere.io/user-ref"
IdentifyProviderLabel
=
"iam.kubesphere.io/identify-provider"
PasswordEncryptedAnnotation
=
"iam.kubesphere.io/password-encrypted"
...
...
@@ -68,6 +69,7 @@ const (
ScopeWorkspace
=
"workspace"
ScopeCluster
=
"cluster"
ScopeNamespace
=
"namespace"
ScopeDevOps
=
"devops"
PlatformAdmin
=
"platform-admin"
NamespaceAdmin
=
"admin"
WorkspaceAdminFormat
=
"%s-admin"
...
...
pkg/controller/namespace/namespace_controller.go
浏览文件 @
03e79876
...
...
@@ -25,6 +25,7 @@ import (
rbacv1
"k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/yaml"
...
...
@@ -206,7 +207,6 @@ func (r *ReconcileNamespace) bindWorkspace(namespace *corev1.Namespace) error {
func
(
r
*
ReconcileNamespace
)
deleteRouter
(
namespace
string
)
error
{
routerName
:=
constants
.
IngressControllerPrefix
+
namespace
// delete service first
found
:=
corev1
.
Service
{}
err
:=
r
.
Get
(
context
.
TODO
(),
types
.
NamespacedName
{
Namespace
:
constants
.
IngressControllerNamespace
,
Name
:
routerName
},
&
found
)
...
...
@@ -246,7 +246,16 @@ func (r *ReconcileNamespace) deleteRouter(namespace string) error {
func
(
r
*
ReconcileNamespace
)
initRoles
(
namespace
*
corev1
.
Namespace
)
error
{
var
roleBases
iamv1alpha2
.
RoleBaseList
err
:=
r
.
List
(
context
.
Background
(),
&
roleBases
)
var
labelKey
string
// filtering initial roles by label
if
namespace
.
Labels
[
constants
.
DevOpsProjectLabelKey
]
!=
""
{
// scope.kubesphere.io/devops: ""
labelKey
=
fmt
.
Sprintf
(
iamv1alpha2
.
ScopeLabelFormat
,
iamv1alpha2
.
ScopeDevOps
)
}
else
{
// scope.kubesphere.io/namespace: ""
labelKey
=
fmt
.
Sprintf
(
iamv1alpha2
.
ScopeLabelFormat
,
iamv1alpha2
.
ScopeNamespace
)
}
err
:=
r
.
List
(
context
.
Background
(),
&
roleBases
,
client
.
MatchingLabelsSelector
{
Selector
:
labels
.
SelectorFromSet
(
labels
.
Set
{
labelKey
:
""
})})
if
err
!=
nil
{
klog
.
Error
(
err
)
return
err
...
...
@@ -254,7 +263,6 @@ func (r *ReconcileNamespace) initRoles(namespace *corev1.Namespace) error {
for
_
,
roleBase
:=
range
roleBases
.
Items
{
var
role
rbacv1
.
Role
if
err
=
yaml
.
NewYAMLOrJSONDecoder
(
bytes
.
NewBuffer
(
roleBase
.
Role
.
Raw
),
1024
)
.
Decode
(
&
role
);
err
==
nil
&&
role
.
Kind
==
iamv1alpha2
.
ResourceKindRole
{
var
old
rbacv1
.
Role
err
:=
r
.
Client
.
Get
(
context
.
Background
(),
types
.
NamespacedName
{
Namespace
:
namespace
.
Name
,
Name
:
role
.
Name
},
&
old
)
...
...
pkg/models/resources/v1alpha3/role/roles.go
浏览文件 @
03e79876
...
...
@@ -105,18 +105,16 @@ func (d *rolesGetter) fetchAggregationRoles(namespace, name string) ([]*rbacv1.R
if
annotation
:=
obj
.
(
*
rbacv1
.
Role
)
.
Annotations
[
iamv1alpha2
.
AggregationRolesAnnotation
];
annotation
!=
""
{
var
roleNames
[]
string
if
err
=
json
.
Unmarshal
([]
byte
(
annotation
),
&
roleNames
);
err
==
nil
{
for
_
,
roleName
:=
range
roleNames
{
role
,
err
:=
d
.
Get
(
namespace
,
roleName
)
if
err
!=
nil
{
if
errors
.
IsNotFound
(
err
)
{
klog
.
Warning
f
(
"invalid aggregation role found: %s, %s"
,
name
,
roleName
)
klog
.
V
(
6
)
.
Info
f
(
"invalid aggregation role found: %s, %s"
,
name
,
roleName
)
continue
}
klog
.
Error
(
err
)
return
nil
,
err
}
roles
=
append
(
roles
,
role
.
(
*
rbacv1
.
Role
))
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录