Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
1cb582a0
Commit
1cb582a0
authored
Feb 28, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add roles and bindings for bootstrap controllers
parent
e24b1c0c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
185 additions
and
1 deletion
+185
-1
namespace_policy.go
.../auth/authorizer/rbac/bootstrappolicy/namespace_policy.go
+32
-0
namespace-role-bindings.yaml
...bac/bootstrappolicy/testdata/namespace-role-bindings.yaml
+55
-1
namespace-roles.yaml
...orizer/rbac/bootstrappolicy/testdata/namespace-roles.yaml
+82
-0
helpers.go
staging/src/k8s.io/client-go/pkg/apis/rbac/helpers.go
+16
-0
No files found.
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/namespace_policy.go
View file @
1cb582a0
...
@@ -78,6 +78,38 @@ func init() {
...
@@ -78,6 +78,38 @@ func init() {
rbac
.
NewRule
(
"get"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"configmaps"
)
.
Names
(
"extension-apiserver-authentication"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"get"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"configmaps"
)
.
Names
(
"extension-apiserver-authentication"
)
.
RuleOrDie
(),
},
},
})
})
addNamespaceRole
(
metav1
.
NamespaceSystem
,
rbac
.
Role
{
// role for the bootstrap signer to be able to inspect kube-system secrets
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
saRolePrefix
+
"bootstrap-signer"
},
Rules
:
[]
rbac
.
PolicyRule
{
rbac
.
NewRule
(
"get"
,
"list"
,
"watch"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"secrets"
)
.
RuleOrDie
(),
},
})
addNamespaceRole
(
metav1
.
NamespaceSystem
,
rbac
.
Role
{
// role for the token-cleaner to be able to remove secrets, but only in kube-system
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
saRolePrefix
+
"token-cleaner"
},
Rules
:
[]
rbac
.
PolicyRule
{
rbac
.
NewRule
(
"get"
,
"list"
,
"watch"
,
"delete"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"secrets"
)
.
RuleOrDie
(),
eventsRule
(),
},
})
addNamespaceRoleBinding
(
metav1
.
NamespaceSystem
,
rbac
.
NewRoleBinding
(
saRolePrefix
+
"bootstrap-signer"
,
metav1
.
NamespaceSystem
)
.
SAs
(
metav1
.
NamespaceSystem
,
"bootstrap-signer"
)
.
BindingOrDie
())
addNamespaceRoleBinding
(
metav1
.
NamespaceSystem
,
rbac
.
NewRoleBinding
(
saRolePrefix
+
"token-cleaner"
,
metav1
.
NamespaceSystem
)
.
SAs
(
metav1
.
NamespaceSystem
,
"token-cleaner"
)
.
BindingOrDie
())
addNamespaceRole
(
metav1
.
NamespacePublic
,
rbac
.
Role
{
// role for the bootstrap signer to be able to write its configmap
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
saRolePrefix
+
"bootstrap-signer"
},
Rules
:
[]
rbac
.
PolicyRule
{
rbac
.
NewRule
(
"get"
,
"list"
,
"watch"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"configmaps"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"update"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"configmaps"
)
.
Names
(
"cluster-info"
)
.
RuleOrDie
(),
eventsRule
(),
},
})
addNamespaceRoleBinding
(
metav1
.
NamespacePublic
,
rbac
.
NewRoleBinding
(
saRolePrefix
+
"bootstrap-signer"
,
metav1
.
NamespacePublic
)
.
SAs
(
metav1
.
NamespaceSystem
,
"bootstrap-signer"
)
.
BindingOrDie
())
}
}
// NamespaceRoles returns a map of namespace to slice of roles to create
// NamespaceRoles returns a map of namespace to slice of roles to create
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/namespace-role-bindings.yaml
View file @
1cb582a0
apiVersion
:
v1
apiVersion
:
v1
items
:
null
items
:
-
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
RoleBinding
metadata
:
annotations
:
rbac.authorization.kubernetes.io/autoupdate
:
"
true"
creationTimestamp
:
null
labels
:
kubernetes.io/bootstrapping
:
rbac-defaults
name
:
system:controller:bootstrap-signer
namespace
:
kube-public
roleRef
:
apiGroup
:
rbac.authorization.k8s.io
kind
:
Role
name
:
system:controller:bootstrap-signer
subjects
:
-
kind
:
ServiceAccount
name
:
bootstrap-signer
namespace
:
kube-system
-
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
RoleBinding
metadata
:
annotations
:
rbac.authorization.kubernetes.io/autoupdate
:
"
true"
creationTimestamp
:
null
labels
:
kubernetes.io/bootstrapping
:
rbac-defaults
name
:
system:controller:bootstrap-signer
namespace
:
kube-system
roleRef
:
apiGroup
:
rbac.authorization.k8s.io
kind
:
Role
name
:
system:controller:bootstrap-signer
subjects
:
-
kind
:
ServiceAccount
name
:
bootstrap-signer
namespace
:
kube-system
-
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
RoleBinding
metadata
:
annotations
:
rbac.authorization.kubernetes.io/autoupdate
:
"
true"
creationTimestamp
:
null
labels
:
kubernetes.io/bootstrapping
:
rbac-defaults
name
:
system:controller:token-cleaner
namespace
:
kube-system
roleRef
:
apiGroup
:
rbac.authorization.k8s.io
kind
:
Role
name
:
system:controller:token-cleaner
subjects
:
-
kind
:
ServiceAccount
name
:
token-cleaner
namespace
:
kube-system
kind
:
List
kind
:
List
metadata
:
{}
metadata
:
{}
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/namespace-roles.yaml
View file @
1cb582a0
...
@@ -8,6 +8,41 @@ items:
...
@@ -8,6 +8,41 @@ items:
creationTimestamp
:
null
creationTimestamp
:
null
labels
:
labels
:
kubernetes.io/bootstrapping
:
rbac-defaults
kubernetes.io/bootstrapping
:
rbac-defaults
name
:
system:controller:bootstrap-signer
namespace
:
kube-public
rules
:
-
apiGroups
:
-
"
"
resources
:
-
configmaps
verbs
:
-
get
-
list
-
watch
-
apiGroups
:
-
"
"
resourceNames
:
-
cluster-info
resources
:
-
configmaps
verbs
:
-
update
-
apiGroups
:
-
"
"
resources
:
-
events
verbs
:
-
create
-
patch
-
update
-
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
Role
metadata
:
annotations
:
rbac.authorization.kubernetes.io/autoupdate
:
"
true"
creationTimestamp
:
null
labels
:
kubernetes.io/bootstrapping
:
rbac-defaults
name
:
extension-apiserver-authentication-reader
name
:
extension-apiserver-authentication-reader
namespace
:
kube-system
namespace
:
kube-system
rules
:
rules
:
...
@@ -19,5 +54,52 @@ items:
...
@@ -19,5 +54,52 @@ items:
-
configmaps
-
configmaps
verbs
:
verbs
:
-
get
-
get
-
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
Role
metadata
:
annotations
:
rbac.authorization.kubernetes.io/autoupdate
:
"
true"
creationTimestamp
:
null
labels
:
kubernetes.io/bootstrapping
:
rbac-defaults
name
:
system:controller:bootstrap-signer
namespace
:
kube-system
rules
:
-
apiGroups
:
-
"
"
resources
:
-
secrets
verbs
:
-
get
-
list
-
watch
-
apiVersion
:
rbac.authorization.k8s.io/v1beta1
kind
:
Role
metadata
:
annotations
:
rbac.authorization.kubernetes.io/autoupdate
:
"
true"
creationTimestamp
:
null
labels
:
kubernetes.io/bootstrapping
:
rbac-defaults
name
:
system:controller:token-cleaner
namespace
:
kube-system
rules
:
-
apiGroups
:
-
"
"
resources
:
-
secrets
verbs
:
-
delete
-
get
-
list
-
watch
-
apiGroups
:
-
"
"
resources
:
-
events
verbs
:
-
create
-
patch
-
update
kind
:
List
kind
:
List
metadata
:
{}
metadata
:
{}
staging/src/k8s.io/client-go/pkg/apis/rbac/helpers.go
View file @
1cb582a0
...
@@ -279,6 +279,22 @@ func NewRoleBinding(roleName, namespace string) *RoleBindingBuilder {
...
@@ -279,6 +279,22 @@ func NewRoleBinding(roleName, namespace string) *RoleBindingBuilder {
}
}
}
}
func
NewRoleBindingForClusterRole
(
roleName
,
namespace
string
)
*
RoleBindingBuilder
{
return
&
RoleBindingBuilder
{
RoleBinding
:
RoleBinding
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
roleName
,
Namespace
:
namespace
,
},
RoleRef
:
RoleRef
{
APIGroup
:
GroupName
,
Kind
:
"ClusterRole"
,
Name
:
roleName
,
},
},
}
}
// Groups adds the specified groups as the subjects of the RoleBinding.
// Groups adds the specified groups as the subjects of the RoleBinding.
func
(
r
*
RoleBindingBuilder
)
Groups
(
groups
...
string
)
*
RoleBindingBuilder
{
func
(
r
*
RoleBindingBuilder
)
Groups
(
groups
...
string
)
*
RoleBindingBuilder
{
for
_
,
group
:=
range
groups
{
for
_
,
group
:=
range
groups
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment