<p>I want to know how label can be set while namespace is getting created in e2e.
This line of code simply creates a namespace <a href="https://github.com/kubernetes/kubernetes/blob/v1.25.0/test/e2e/framework/framework.go#L239" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/blob/v1.25.0/test/e2e/framework/framework.go#L239</a> and it picks default <code>pod-security.kubernetes.io/</code> set which is <code>restricted</code>. I want test framework to create namespace with <code>pod-security.kubernetes.io</code> to be <code>Privileged</code>.</p>

<p>This label is set by an admission controller. Setting it manually will cause the controller to reject your pod.</p>
<p>To get the correct Pod Security Policy (PSP) assigned you need RBAC rules that allows <code>use</code> on that PSP: <a href="https://v1-24.docs.kubernetes.io/docs/concepts/security/pod-security-policy/#via-rbac" rel="nofollow noreferrer">https://v1-24.docs.kubernetes.io/docs/concepts/security/pod-security-policy/#via-rbac</a></p>
<p>Also, if when several PSPs can be used with a particular Pod they are applied in lexicographical order: <a href="https://v1-24.docs.kubernetes.io/docs/concepts/security/pod-security-policy/#policy-order" rel="nofollow noreferrer">https://v1-24.docs.kubernetes.io/docs/concepts/security/pod-security-policy/#policy-order</a></p>
