diff --git a/content/en/docs/concepts/policy/pod-security-policy.md b/content/en/docs/concepts/policy/pod-security-policy.md index 487413f6fc..520fe50820 100644 --- a/content/en/docs/concepts/policy/pod-security-policy.md +++ b/content/en/docs/concepts/policy/pod-security-policy.md @@ -31,7 +31,7 @@ administrator to control the following: | Control Aspect | Field Names | | ----------------------------------------------------| ------------------------------------------- | | Running of privileged containers | [`privileged`](#privileged) | -| Usage of the root namespaces | [`hostPID`, `hostIPC`](#host-namespaces) | +| Usage of host namespaces | [`hostPID`, `hostIPC`](#host-namespaces) | | Usage of host networking and ports | [`hostNetwork`, `hostPorts`](#host-namespaces) | | Usage of volume types | [`volumes`](#volumes-and-file-systems) | | Usage of the host filesystem | [`allowedHostPaths`](#volumes-and-file-systems) | @@ -176,17 +176,17 @@ Set up a namespace and a service account to act as for this example. We'll use this service account to mock a non-admin user. ```shell -$ kubectl create namespace psp-example -$ kubectl create serviceaccount -n psp-example fake-user -$ kubectl create rolebinding -n psp-example fake-editor --clusterrole=edit --serviceaccount=psp-example:fake-user +kubectl create namespace psp-example +kubectl create serviceaccount -n psp-example fake-user +kubectl create rolebinding -n psp-example fake-editor --clusterrole=edit --serviceaccount=psp-example:fake-user ``` To make it clear which user we're acting as and save some typing, create 2 aliases: ```shell -$ alias kubectl-admin='kubectl -n psp-example' -$ alias kubectl-user='kubectl --as=system:serviceaccount:psp-example:fake-user -n psp-example' +alias kubectl-admin='kubectl -n psp-example' +alias kubectl-user='kubectl --as=system:serviceaccount:psp-example:fake-user -n psp-example' ``` ### Create a policy and a pod @@ -199,13 +199,13 @@ simply prevents the creation of privileged pods. And create it with kubectl: ```shell -$ kubectl-admin create -f example-psp.yaml +kubectl-admin create -f example-psp.yaml ``` Now, as the unprivileged user, try to create a simple pod: ```shell -$ kubectl-user create -f- <}} +**Note:** _This is not the recommended way! See the [next section](#run-another-pod) for the preferred approach._ +{{< /note >}} ```shell -$ kubectl-admin create role psp:unprivileged \ +kubectl-admin create role psp:unprivileged \ --verb=use \ --resource=podsecuritypolicy \ --resource-name=example role "psp:unprivileged" created -$ kubectl-admin create rolebinding fake-user:psp:unprivileged \ + +kubectl-admin create rolebinding fake-user:psp:unprivileged \ --role=psp:unprivileged \ --serviceaccount=psp-example:fake-user rolebinding "fake-user:psp:unprivileged" created -$ kubectl-user auth can-i use podsecuritypolicy/example + +kubectl-user auth can-i use podsecuritypolicy/example yes ``` Now retry creating the pod: ```shell -$ kubectl-user create -f- <