Skip to content

Commit dbb243f

Browse files
authored
Merge pull request #6542 from s-urbaniak/pod-security-admission
e2e-tests: describe pod security admission
2 parents 6dcbc54 + 43a08f9 commit dbb243f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

contributors/devel/sig-testing/e2e-tests.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,32 @@ Note that advanced testing parameters, and hierarchichally defined parameters, a
604604
605605
In time, it is our intent to add or autogenerate a sample viper configuration that includes all e2e parameters, to ship with Kubernetes.
606606
607+
### Pod Security Admission
608+
609+
With introducing Pod Security admission in Kubernetes by default, it is desired to execute e2e tests within bounded pod security policy levels. The default pod security policy in e2e tests is [restricted](https://kubernetes.io/docs/concepts/security/pod-security-admission/#pod-security-levels). This is set in https://github.com/kubernetes/kubernetes/blob/master/test/e2e/framework/framework.go. This ensures that e2e tests follow best practices for hardening pods by default.
610+
611+
Two helper functions are available for returning a minimal [restricted pod security context](https://github.com/kubernetes/kubernetes/blob/d7e6eab87d0fd005b238e3ec9b088e37d41a15d3/test/e2e/framework/pod/utils.go#L119) and a [restricted container security context](https://github.com/kubernetes/kubernetes/blob/d7e6eab87d0fd005b238e3ec9b088e37d41a15d3/test/e2e/framework/pod/utils.go#L127). These can be used to initialize pod or container specs to ensure adherence for the most restricted pod security policy.
612+
613+
If pods need to elevate privileges to either `baseline` or `privileged` a new field - `NamespacePodSecurityEnforceLevel` - was introduced to the e2e framework to specify the necessary namespace enforcement level. Note that namespaces get created in the `BeforeEach()` phase of ginkgo tests.
614+
615+
```
616+
import (
617+
...
618+
admissionapi "k8s.io/pod-security-admission/api"
619+
...
620+
)
621+
622+
623+
var _ = SIGDescribe("Test", func() {
624+
...
625+
f := framework.NewDefaultFramework("test")
626+
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
627+
...
628+
}
629+
```
630+
631+
This ensures that the namespace returned by `f.Namespace.Name` includes the configured pod security policy level. Note that creating custom namespace names is not encouraged and will not include the configured settings.
632+
607633
### Conformance tests
608634
609635
For more information on Conformance tests please see the [Conformance Testing](../sig-architecture/conformance-tests.md)

0 commit comments

Comments
 (0)