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
a37d8ec1
Unverified
Commit
a37d8ec1
authored
Dec 13, 2017
by
Mikkel Oscar Lyderik Larsen
Committed by
Mikkel Oscar Lyderik Larsen
Dec 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't create PSP binding when RBAC is not enabled
parent
38368572
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
25 deletions
+29
-25
psp_util.go
test/e2e/framework/psp_util.go
+29
-25
No files found.
test/e2e/framework/psp_util.go
View file @
a37d8ec1
...
...
@@ -97,7 +97,7 @@ var (
)
func
CreatePrivilegedPSPBinding
(
f
*
Framework
,
namespace
string
)
{
if
!
IsPodSecurityPolicyEnabled
(
f
)
||
!
IsRBACEnabled
(
f
)
{
if
!
IsPodSecurityPolicyEnabled
(
f
)
{
return
}
// Create the privileged PSP & role
...
...
@@ -114,30 +114,34 @@ func CreatePrivilegedPSPBinding(f *Framework, namespace string) {
psp
,
err
=
f
.
ClientSet
.
ExtensionsV1beta1
()
.
PodSecurityPolicies
()
.
Create
(
psp
)
ExpectNoError
(
err
,
"Failed to create PSP %s"
,
podSecurityPolicyPrivileged
)
// Create the Role to bind it to the namespace.
_
,
err
=
f
.
ClientSet
.
RbacV1beta1
()
.
ClusterRoles
()
.
Create
(
&
rbacv1beta1
.
ClusterRole
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
podSecurityPolicyPrivileged
},
Rules
:
[]
rbacv1beta1
.
PolicyRule
{{
APIGroups
:
[]
string
{
"extensions"
},
Resources
:
[]
string
{
"podsecuritypolicies"
},
ResourceNames
:
[]
string
{
podSecurityPolicyPrivileged
},
Verbs
:
[]
string
{
"use"
},
}},
})
ExpectNoError
(
err
,
"Failed to create PSP role"
)
if
IsRBACEnabled
(
f
)
{
// Create the Role to bind it to the namespace.
_
,
err
=
f
.
ClientSet
.
RbacV1beta1
()
.
ClusterRoles
()
.
Create
(
&
rbacv1beta1
.
ClusterRole
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
podSecurityPolicyPrivileged
},
Rules
:
[]
rbacv1beta1
.
PolicyRule
{{
APIGroups
:
[]
string
{
"extensions"
},
Resources
:
[]
string
{
"podsecuritypolicies"
},
ResourceNames
:
[]
string
{
podSecurityPolicyPrivileged
},
Verbs
:
[]
string
{
"use"
},
}},
})
ExpectNoError
(
err
,
"Failed to create PSP role"
)
}
})
By
(
fmt
.
Sprintf
(
"Binding the %s PodSecurityPolicy to the default service account in %s"
,
podSecurityPolicyPrivileged
,
namespace
))
BindClusterRoleInNamespace
(
f
.
ClientSet
.
RbacV1beta1
(),
podSecurityPolicyPrivileged
,
namespace
,
rbacv1beta1
.
Subject
{
Kind
:
rbacv1beta1
.
ServiceAccountKind
,
Namespace
:
namespace
,
Name
:
"default"
,
})
ExpectNoError
(
WaitForNamedAuthorizationUpdate
(
f
.
ClientSet
.
AuthorizationV1beta1
(),
serviceaccount
.
MakeUsername
(
namespace
,
"default"
),
namespace
,
"use"
,
podSecurityPolicyPrivileged
,
schema
.
GroupResource
{
Group
:
"extensions"
,
Resource
:
"podsecuritypolicies"
},
true
))
if
IsRBACEnabled
(
f
)
{
By
(
fmt
.
Sprintf
(
"Binding the %s PodSecurityPolicy to the default service account in %s"
,
podSecurityPolicyPrivileged
,
namespace
))
BindClusterRoleInNamespace
(
f
.
ClientSet
.
RbacV1beta1
(),
podSecurityPolicyPrivileged
,
namespace
,
rbacv1beta1
.
Subject
{
Kind
:
rbacv1beta1
.
ServiceAccountKind
,
Namespace
:
namespace
,
Name
:
"default"
,
})
ExpectNoError
(
WaitForNamedAuthorizationUpdate
(
f
.
ClientSet
.
AuthorizationV1beta1
(),
serviceaccount
.
MakeUsername
(
namespace
,
"default"
),
namespace
,
"use"
,
podSecurityPolicyPrivileged
,
schema
.
GroupResource
{
Group
:
"extensions"
,
Resource
:
"podsecuritypolicies"
},
true
))
}
}
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