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
0698354f
Commit
0698354f
authored
Sep 18, 2018
by
David Zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add privileged test pod security policy to local volume provisioner test service account
parent
e7eb2691
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
0 deletions
+60
-0
persistent_volumes-local.go
test/e2e/storage/persistent_volumes-local.go
+2
-0
BUILD
test/e2e/storage/utils/BUILD
+3
-0
utils.go
test/e2e/storage/utils/utils.go
+55
-0
No files found.
test/e2e/storage/persistent_volumes-local.go
View file @
0698354f
...
@@ -1464,6 +1464,7 @@ func setupLocalVolumeProvisioner(config *localTestConfig) {
...
@@ -1464,6 +1464,7 @@ func setupLocalVolumeProvisioner(config *localTestConfig) {
By
(
"Bootstrapping local volume provisioner"
)
By
(
"Bootstrapping local volume provisioner"
)
createServiceAccount
(
config
)
createServiceAccount
(
config
)
createProvisionerClusterRoleBinding
(
config
)
createProvisionerClusterRoleBinding
(
config
)
utils
.
PrivilegedTestPSPClusterRoleBinding
(
config
.
client
,
config
.
ns
,
false
/* teardown */
,
[]
string
{
testServiceAccount
})
createVolumeConfigMap
(
config
)
createVolumeConfigMap
(
config
)
for
_
,
node
:=
range
config
.
nodes
{
for
_
,
node
:=
range
config
.
nodes
{
...
@@ -1477,6 +1478,7 @@ func setupLocalVolumeProvisioner(config *localTestConfig) {
...
@@ -1477,6 +1478,7 @@ func setupLocalVolumeProvisioner(config *localTestConfig) {
func
cleanupLocalVolumeProvisioner
(
config
*
localTestConfig
)
{
func
cleanupLocalVolumeProvisioner
(
config
*
localTestConfig
)
{
By
(
"Cleaning up cluster role binding"
)
By
(
"Cleaning up cluster role binding"
)
deleteClusterRoleBinding
(
config
)
deleteClusterRoleBinding
(
config
)
utils
.
PrivilegedTestPSPClusterRoleBinding
(
config
.
client
,
config
.
ns
,
true
/* teardown */
,
[]
string
{
testServiceAccount
})
for
_
,
node
:=
range
config
.
nodes
{
for
_
,
node
:=
range
config
.
nodes
{
By
(
fmt
.
Sprintf
(
"Removing the test discovery directory on node %v"
,
node
.
Name
))
By
(
fmt
.
Sprintf
(
"Removing the test discovery directory on node %v"
,
node
.
Name
))
...
...
test/e2e/storage/utils/BUILD
View file @
0698354f
...
@@ -14,7 +14,10 @@ go_library(
...
@@ -14,7 +14,10 @@ go_library(
importpath = "k8s.io/kubernetes/test/e2e/storage/utils",
importpath = "k8s.io/kubernetes/test/e2e/storage/utils",
deps = [
deps = [
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/rbac/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//test/e2e/framework:go_default_library",
"//test/e2e/framework:go_default_library",
"//test/utils/image:go_default_library",
"//test/utils/image:go_default_library",
...
...
test/e2e/storage/utils/utils.go
View file @
0698354f
...
@@ -24,7 +24,10 @@ import (
...
@@ -24,7 +24,10 @@ import (
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
rbacv1
"k8s.io/api/rbac/v1"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
clientset
"k8s.io/client-go/kubernetes"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
imageutils
"k8s.io/kubernetes/test/utils/image"
imageutils
"k8s.io/kubernetes/test/utils/image"
...
@@ -40,6 +43,11 @@ const (
...
@@ -40,6 +43,11 @@ const (
KRestart
KubeletOpt
=
"restart"
KRestart
KubeletOpt
=
"restart"
)
)
const
(
// ClusterRole name for e2e test Priveledged Pod Security Policy User
podSecurityPolicyPrivilegedClusterRoleName
=
"e2e-test-privileged-psp"
)
// PodExec wraps RunKubectl to execute a bash cmd in target pod
// PodExec wraps RunKubectl to execute a bash cmd in target pod
func
PodExec
(
pod
*
v1
.
Pod
,
bashExec
string
)
(
string
,
error
)
{
func
PodExec
(
pod
*
v1
.
Pod
,
bashExec
string
)
(
string
,
error
)
{
return
framework
.
RunKubectl
(
"exec"
,
fmt
.
Sprintf
(
"--namespace=%s"
,
pod
.
Namespace
),
pod
.
Name
,
"--"
,
"/bin/sh"
,
"-c"
,
bashExec
)
return
framework
.
RunKubectl
(
"exec"
,
fmt
.
Sprintf
(
"--namespace=%s"
,
pod
.
Namespace
),
pod
.
Name
,
"--"
,
"/bin/sh"
,
"-c"
,
bashExec
)
...
@@ -386,3 +394,50 @@ func StartExternalProvisioner(c clientset.Interface, ns string, externalPluginNa
...
@@ -386,3 +394,50 @@ func StartExternalProvisioner(c clientset.Interface, ns string, externalPluginNa
return
pod
return
pod
}
}
func
PrivilegedTestPSPClusterRoleBinding
(
client
clientset
.
Interface
,
namespace
string
,
teardown
bool
,
saNames
[]
string
)
{
bindingString
:=
"Binding"
if
teardown
{
bindingString
=
"Unbinding"
}
roleBindingClient
:=
client
.
RbacV1
()
.
RoleBindings
(
namespace
)
for
_
,
saName
:=
range
saNames
{
By
(
fmt
.
Sprintf
(
"%v priviledged Pod Security Policy to the service account %s"
,
bindingString
,
saName
))
binding
:=
&
rbacv1
.
RoleBinding
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"psp-"
+
saName
,
Namespace
:
namespace
,
},
Subjects
:
[]
rbacv1
.
Subject
{
{
Kind
:
rbacv1
.
ServiceAccountKind
,
Name
:
saName
,
Namespace
:
namespace
,
},
},
RoleRef
:
rbacv1
.
RoleRef
{
Kind
:
"ClusterRole"
,
Name
:
podSecurityPolicyPrivilegedClusterRoleName
,
APIGroup
:
"rbac.authorization.k8s.io"
,
},
}
roleBindingClient
.
Delete
(
binding
.
GetName
(),
&
metav1
.
DeleteOptions
{})
err
:=
wait
.
Poll
(
2
*
time
.
Second
,
2
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
_
,
err
:=
roleBindingClient
.
Get
(
binding
.
GetName
(),
metav1
.
GetOptions
{})
return
apierrs
.
IsNotFound
(
err
),
nil
})
framework
.
ExpectNoError
(
err
,
"Timed out waiting for deletion: %v"
,
err
)
if
teardown
{
continue
}
_
,
err
=
roleBindingClient
.
Create
(
binding
)
framework
.
ExpectNoError
(
err
,
"Failed to create %s role binding: %v"
,
binding
.
GetName
(),
err
)
}
}
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