This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #620 from phoenixking25/block_host_path
#404 added test for block use of bind mounts
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
benchmarks/e2e/tests/block_bind_mounts/block_bind_mounts.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package block_bind_mounts | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/onsi/ginkgo" | ||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/kubernetes/test/e2e/framework" | ||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod" | ||
configutil "sigs.k8s.io/multi-tenancy/benchmarks/e2e/config" | ||
) | ||
|
||
const ( | ||
expectedVal = "Host path volumes are not allowed" | ||
) | ||
|
||
var _ = framework.KubeDescribe("[PL1] [PL2] [PL3] Tenants should not be able to mount host volumes and folders", func() { | ||
var config *configutil.BenchmarkConfig | ||
var tenantA configutil.TenantSpec | ||
var user string | ||
var err error | ||
var InlineVolumeSources = []*v1.VolumeSource{ | ||
{ | ||
HostPath: &v1.HostPathVolumeSource{ | ||
Path: "/tmp/busybox", | ||
}, | ||
}, | ||
} | ||
|
||
ginkgo.BeforeEach(func() { | ||
config, err = configutil.ReadConfig(configutil.ConfigPath) | ||
framework.ExpectNoError(err) | ||
|
||
tenantA, err = config.GetValidTenant() | ||
framework.ExpectNoError(err) | ||
|
||
user = configutil.GetContextFromKubeconfig(tenantA.Kubeconfig) | ||
}) | ||
|
||
ginkgo.It("Tenants should not be able to mount host volumes and folders", func() { | ||
ginkgo.By(fmt.Sprintf("Tenant %s should not be able to mount host volumes and folders", user)) | ||
|
||
pod := e2epod.MakeSecPod(tenantA.Namespace, nil, InlineVolumeSources, false, "", false, false, nil, nil) | ||
|
||
kclient := configutil.NewKubeClientWithKubeconfig(tenantA.Kubeconfig) | ||
_, err = kclient.CoreV1().Pods(tenantA.Namespace).Create(pod) | ||
|
||
if !strings.Contains(err.Error(), expectedVal) { | ||
framework.Failf("%s must be unable to create pod with host-path volume", user) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters