Address PR feedback

This commit is contained in:
Tim Allclair
2021-06-24 09:51:32 -07:00
parent 4600715899
commit ae1ae50454
4 changed files with 24 additions and 22 deletions
@@ -115,7 +115,7 @@ subjects:
- kind: Group - kind: Group
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
name: system:serviceaccounts:<authorized namespace> name: system:serviceaccounts:<authorized namespace>
# Authorize specific service accounts: # Authorize specific service accounts (not recommended):
- kind: ServiceAccount - kind: ServiceAccount
name: <authorized service account name> name: <authorized service account name>
namespace: <authorized pod namespace> namespace: <authorized pod namespace>
@@ -144,20 +144,21 @@ Examples](/docs/reference/access-authn-authz/rbac#role-binding-examples).
For a complete example of authorizing a PodSecurityPolicy, see For a complete example of authorizing a PodSecurityPolicy, see
[below](#example). [below](#example).
### Best Practices ### Recommended Practice
PodSecurityPolicy is being replaced by a new, simplified PodSecurity admission controller. The PodSecurityPolicy is being replaced by a new, simplified `PodSecurity` {{< glossary_tooltip
following recommended best-practices will make the migration to the new PodSecurity admission text="admission controller" term_id="admission-controller" >}}. For more details on this change, see
controller much simpler. For more details on this change, see [PodSecurityPolicy Deprecation: Past, Present, and
[PodSecurityPolicy Deprecation: Past, Present, and Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/). Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/). Follow these
guidelines to simplify migration from PodSecurityPolicy to the new admission controller:
1. Limit your PodSecurityPolicies to the policies defined by the [Pod Security Standards](/docs/concepts/security/pod-security-standards): 1. Limit your PodSecurityPolicies to the policies defined by the [Pod Security Standards](/docs/concepts/security/pod-security-standards):
- [Privileged](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/privileged-psp.yaml) - {{< example file="policy/privileged-psp.yaml" >}}Privileged{{< /example >}}
- [Baseline](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/baseline-psp.yaml) - {{< example file="policy/baseline-psp.yaml" >}}Baseline{{< /example >}}
- [Restricted](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/restricted-psp.yaml) - {{< example file="policy/restricted-psp.yaml" >}}Restricted{{< /example >}}
2. Only bind PSPs to namespaces, by using the `system:serviceaccounts:<namespace>` group (where 2. Only bind PSPs to entire namespaces, by using the `system:serviceaccounts:<namespace>` group
`<namespace>` is the target namespace). For example: (where `<namespace>` is the target namespace). For example:
```yaml ```yaml
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
@@ -699,6 +700,10 @@ Refer to the [Sysctl documentation](
## {{% heading "whatsnext" %}} ## {{% heading "whatsnext" %}}
- See [PodSecurityPolicy Deprecation: Past, Present, and
Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/) to learn about
the future of pod security policy.
- See [Pod Security Standards](/docs/concepts/security/pod-security-standards/) for policy recommendations. - See [Pod Security Standards](/docs/concepts/security/pod-security-standards/) for policy recommendations.
- Refer to [Pod Security Policy Reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podsecuritypolicy-v1beta1-policy) for the api details. - Refer to [Pod Security Policy Reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podsecuritypolicy-v1beta1-policy) for the api details.
@@ -86,7 +86,7 @@ enforced/disallowed:
<tr> <tr>
<td>Capabilities</td> <td>Capabilities</td>
<td> <td>
Adding additional capabilities beyond the <a href="https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities">default set (excluding NET_RAW)</a> must be disallowed.<br> Adding <tt>NET_RAW</tt> or capabilities beyond the <a href="https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities">default set</a> must be disallowed.<br>
<br><b>Restricted Fields:</b><br> <br><b>Restricted Fields:</b><br>
spec.containers[*].securityContext.capabilities.add<br> spec.containers[*].securityContext.capabilities.add<br>
spec.initContainers[*].securityContext.capabilities.add<br> spec.initContainers[*].securityContext.capabilities.add<br>
+4 -5
View File
@@ -6,9 +6,7 @@ metadata:
# Optional: Allow the default AppArmor profile, requires setting the default. # Optional: Allow the default AppArmor profile, requires setting the default.
apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default' apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default'
apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default' apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default'
# Optional: Allow the default seccomp profile, requires setting the default. seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*'
seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'docker/default,runtime/default,unconfined'
seccomp.security.alpha.kubernetes.io/defaultProfileName: 'unconfined'
spec: spec:
privileged: false privileged: false
# The moby default capability set, minus NET_RAW # The moby default capability set, minus NET_RAW
@@ -34,15 +32,16 @@ spec:
- 'projected' - 'projected'
- 'secret' - 'secret'
- 'downwardAPI' - 'downwardAPI'
# Assume that persistentVolumes set up by the cluster admin are safe to use. # Assume that ephemeral CSI drivers & persistentVolumes set up by the cluster admin are safe to use.
- 'csi'
- 'persistentVolumeClaim' - 'persistentVolumeClaim'
- 'ephemeral'
# Allow all other non-hostpath volume types. # Allow all other non-hostpath volume types.
- 'awsElasticBlockStore' - 'awsElasticBlockStore'
- 'azureDisk' - 'azureDisk'
- 'azureFile' - 'azureFile'
- 'cephFS' - 'cephFS'
- 'cinder' - 'cinder'
- 'csi'
- 'fc' - 'fc'
- 'flexVolume' - 'flexVolume'
- 'flocker' - 'flocker'
@@ -5,14 +5,11 @@ metadata:
annotations: annotations:
seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'docker/default,runtime/default' seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'docker/default,runtime/default'
apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default' apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default'
seccomp.security.alpha.kubernetes.io/defaultProfileName: 'runtime/default'
apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default' apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default'
spec: spec:
privileged: false privileged: false
# Required to prevent escalations to root. # Required to prevent escalations to root.
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
# This is redundant with non-root + disallow privilege escalation,
# but we can provide it for defense in depth.
requiredDropCapabilities: requiredDropCapabilities:
- ALL - ALL
# Allow core volume types. # Allow core volume types.
@@ -22,9 +19,10 @@ spec:
- 'projected' - 'projected'
- 'secret' - 'secret'
- 'downwardAPI' - 'downwardAPI'
# Assume that CSI drivers & persistentVolumes set up by the cluster admin are safe to use. # Assume that ephemeral CSI drivers & persistentVolumes set up by the cluster admin are safe to use.
- 'persistentVolumeClaim'
- 'csi' - 'csi'
- 'persistentVolumeClaim'
- 'ephemeral'
hostNetwork: false hostNetwork: false
hostIPC: false hostIPC: false
hostPID: false hostPID: false