@@ -14,7 +14,7 @@ weight: 20
14
14
Pod Security Policies enable fine-grained authorization of pod creation and
15
15
updates.
16
16
-->
17
- PodSecurityPolicy支持针对 pod 创建和更新进行精细的权限控制。
17
+ Pod 安全策略支持针对 pod 创建和更新进行精细的权限控制。
18
18
19
19
{{% /capture %}}
20
20
@@ -24,7 +24,7 @@ PodSecurityPolicy支持针对 pod 创建和更新进行精细的权限控制。
24
24
<!--
25
25
## What is a Pod Security Policy?
26
26
-->
27
- ## 什么是 PodSecurityPolicy ?
27
+ ## 什么是 Pod 安全策略 ?
28
28
29
29
<!--
30
30
A _Pod Security Policy_ is a cluster-level resource that controls security
@@ -33,55 +33,55 @@ define a set of conditions that a pod must run with in order to be accepted into
33
33
the system, as well as defaults for the related fields. They allow an
34
34
administrator to control the following:
35
35
-->
36
- _ PodSecurityPolicy _ 是集群级别的资源,它能够控制 Pod 规范中对安全敏感的方面。
36
+ _ Pod 安全策略 _ 是集群级别的资源,它能够控制 Pod 规范中对安全敏感的方面。
37
37
[ PodSecurityPolicy] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podsecuritypolicy-v1beta1-policy)
38
- 对象定义了一组条件,指示 Pod 必须按系统所能接受的顺序运行,以及相关字段的默认值 。
38
+ 对象定义了一组 pod 必须在其上运行才能被系统接受的条件,以及相关字段的默认设置 。
39
39
它们允许管理员控制如下方面:
40
40
41
41
<!--
42
- | Control Aspect | Field Names |
43
- | ----------------------------------------------------| ------------------------------------------- |
44
- | Running of privileged containers | [`privileged`](#privileged) |
45
- | Usage of host namespaces | [`hostPID`, `hostIPC`](#host-namespaces) |
46
- | Usage of host networking and ports | [`hostNetwork`, `hostPorts`](#host-namespaces) |
47
- | Usage of volume types | [`volumes`](#volumes-and-file-systems) |
48
- | Usage of the host filesystem | [`allowedHostPaths`](#volumes-and-file-systems) |
49
- | White list of FlexVolume drivers | [`allowedFlexVolumes`](#flexvolume-drivers) |
50
- | Allocating an FSGroup that owns the pod's volumes | [`fsGroup`](#volumes-and-file-systems) |
51
- | Requiring the use of a read only root file system | [`readOnlyRootFilesystem`](#volumes-and-file-systems) |
52
- | The user and group IDs of the container | [`runAsUser`, `runAsGroup`, `supplementalGroups`](#users-and-groups) |
53
- | Restricting escalation to root privileges | [`allowPrivilegeEscalation`, `defaultAllowPrivilegeEscalation`](#privilege-escalation) |
54
- | Linux capabilities | [`defaultAddCapabilities`, `requiredDropCapabilities`, `allowedCapabilities`](#capabilities) |
55
- | The SELinux context of the container | [`seLinux`](#selinux) |
56
- | The Allowed Proc Mount types for the container | [`allowedProcMountTypes`](#allowedprocmounttypes) |
57
- | The AppArmor profile used by containers | [annotations](#apparmor) |
58
- | The seccomp profile used by containers | [annotations](#seccomp) |
59
- | The sysctl profile used by containers | [`forbiddenSysctls`,`allowedUnsafeSysctls`](#sysctl) |
42
+ | Control Aspect | Field Names |
43
+ |---------------------------------------------------| ---------------------------------------------------------------------------------------------- |
44
+ | Running of privileged containers | [`privileged`](#privileged) |
45
+ | Usage of host namespaces | [`hostPID`, `hostIPC`](#host-namespaces) |
46
+ | Usage of host networking and ports | [`hostNetwork`, `hostPorts`](#host-namespaces) |
47
+ | Usage of volume types | [`volumes`](#volumes-and-file-systems) |
48
+ | Usage of the host filesystem | [`allowedHostPaths`](#volumes-and-file-systems) |
49
+ | White list of FlexVolume drivers | [`allowedFlexVolumes`](#flexvolume-drivers) |
50
+ | Allocating an FSGroup that owns the pod's volumes | [`fsGroup`](#volumes-and-file-systems) |
51
+ | Requiring the use of a read only root file system | [`readOnlyRootFilesystem`](#volumes-and-file-systems) |
52
+ | The user and group IDs of the container | [`runAsUser`, `runAsGroup`, `supplementalGroups`](#users-and-groups) |
53
+ | Restricting escalation to root privileges | [`allowPrivilegeEscalation`, `defaultAllowPrivilegeEscalation`](#privilege-escalation) |
54
+ | Linux capabilities | [`defaultAddCapabilities`, `requiredDropCapabilities`, `allowedCapabilities`](#capabilities) |
55
+ | The SELinux context of the container | [`seLinux`](#selinux) |
56
+ | The Allowed Proc Mount types for the container | [`allowedProcMountTypes`](#allowedprocmounttypes) |
57
+ | The AppArmor profile used by containers | [annotations](#apparmor) |
58
+ | The seccomp profile used by containers | [annotations](#seccomp) |
59
+ | The sysctl profile used by containers | [`forbiddenSysctls`,`allowedUnsafeSysctls`](#sysctl) |
60
60
61
61
-->
62
- | 控制面 | 字段名称 |
63
- | --------------------------------| ----------------------------------------------------------------------------------------------|
64
- | 已授权容器的运行 | [ ` privileged ` ] ( #privileged ) |
65
- | 主机 PID namespace 的使用 | [ ` hostPID ` , ` hostIPC ` ] ( #host-namespaces ) |
62
+ | 所控制的方面 | 字段名称 |
63
+ | ---------------------------------- | ----------------------------------------------------------------------------------------------|
64
+ | 运行特权容器 | [ ` privileged ` ] ( #privileged ) |
65
+ | 使用主机 PID 的命名空间 | [ ` hostPID ` , ` hostIPC ` ] ( #host-namespaces ) |
66
66
| 主机网络的使用 | [ ` hostNetwork ` ,` hostPorts ` ] ( #host-namespaces ) |
67
67
| 控制卷类型的使用 | [ ` volumes ` ] ( #volumes-and-file-systems ) |
68
68
| 主机路径的使用 | [ ` allowedHostPaths ` ] ( #volumes-and-file-systems ) |
69
69
| FlexVolume 卷驱动的白名单 | [ ` allowedFlexVolumes ` ] ( #flexvolume-drivers ) |
70
70
| 分配拥有 Pod 数据卷的 FSGroup | [ ` fsGroup ` ] ( #volumes-and-file-systems ) |
71
- | 必须使用一个只读的 root 文件系统 | [ ` readOnlyRootFilesystem ` (#volumes-and-file-systems) |
71
+ | 必须使用一个只读的 root 文件系统 | [ ` readOnlyRootFilesystem ` (#volumes-and-file-systems) |
72
72
| 容器的用户和组的 ID | [ ` runAsUser ` , ` runAsGroup ` , ` supplementalGroups ` ] ( #users-and-groups ) |
73
- | 提升为 root 权限的限制 | [ ` allowPrivilegeEscalation ` , ` defaultAllowPrivilegeEscalation ` ] ( #privilege-escalation ) |
74
- | 为容器添加默认的一组能力 | [ ` defaultAddCapabilities ` , ` requiredDropCapabilities ` , ` allowedCapabilities ` ] ( #capabilities ) |
73
+ | 限制提升为 root 特权 | [ ` allowPrivilegeEscalation ` , ` defaultAllowPrivilegeEscalation ` ] ( #privilege-escalation ) |
74
+ | 为容器添加默认的一组能力 | [ ` defaultAddCapabilities ` , ` requiredDropCapabilities ` , ` allowedCapabilities ` ] ( #capabilities ) |
75
75
| 容器的 SELinux 上下文 | [ ` seLinux ` ] ( #selinux ) |
76
- | 容器允许的 Proc 挂载类型 | [ ` allowedProcMountTypes ` ] ( #allowedprocmounttypes ) |
77
- | 容器使用的 AppArmor 配置文件 | [ annotations] ( #apparmor ) |
78
- | 容器使用的 seccomp 配置文件 | [ annotations] ( #seccomp ) |
79
- | 容器使用的 sysctl 配置文件 | [ ` forbiddenSysctls ` ,` allowedUnsafeSysctls ` ] ( #sysctl ) |
76
+ | 容器允许的 Proc 挂载类型 | [ ` allowedProcMountTypes ` ] ( #allowedprocmounttypes ) |
77
+ | 容器使用的 AppArmor 配置 | [ annotations] ( #apparmor ) |
78
+ | 容器使用的 seccomp 配置 | [ annotations] ( #seccomp ) |
79
+ | 容器使用的 sysctl 配置 | [ ` forbiddenSysctls ` ,` allowedUnsafeSysctls ` ] ( #sysctl ) |
80
80
81
81
<!--
82
82
## Enabling Pod Security Policies
83
83
-->
84
- ## 启用 PodSecurityPolicy
84
+ ## 启用 Pod 安全策略
85
85
86
86
<!--
87
87
Pod security policy control is implemented as an optional (but recommended)
@@ -93,7 +93,7 @@ but doing so without authorizing any policies **will prevent any pods from being
93
93
created** in the cluster.
94
94
-->
95
95
96
- PodSecurityPolicy 控制是 [ admission 控制器] ( /docs/reference/access-authn-authz/admission-controllers/#podsecuritypolicy )
96
+ Pod 安全策略控制是 [ admission 控制器] ( /docs/reference/access-authn-authz/admission-controllers/#podsecuritypolicy )
97
97
的一个可选实现。PodSecurityPolicy通过 [ 启用 admission 控制器] ( /docs/reference/access-authn-authz/admission-controllers/#how-do-i-turn-on-an-admission-control-plug-in ) 被强制启用,
98
98
但是如果集群内没有授权任何策略时这样做 ** 将导致任何 pod 都无法被创建** 。
99
99
@@ -103,7 +103,7 @@ enabled independently of the admission controller, for existing clusters it is
103
103
recommended that policies are added and authorized before enabling the admission
104
104
controller.
105
105
-->
106
- 由于 PodSecurityPolicy API (` policy/v1beta1/podsecuritypolicy ` ) 时独立于 admission 控制器启用的,
106
+ 由于 Pod 安全策略 API (` policy/v1beta1/podsecuritypolicy ` ) 时独立于 admission 控制器启用的,
107
107
所以对于现有集群推荐在启用 admission 控制器之前就添加并授权安全策略。
108
108
109
109
<!--
@@ -132,7 +132,7 @@ pod's service account (see [example](#run-another-pod)).
132
132
-->
133
133
多数 Kubernetes pod 并非由用户直接创建。相反,通常他们作为 [ Deployment] ( /docs/concepts/workloads/controllers/deployment/ ) 、
134
134
[ ReplicaSet] ( /docs/concepts/workloads/controllers/replicaset/ ) 或者其他的模板控制器的组成部分由控制器管理器被间接地创建。
135
- 授权策略给控制器即授权给 ** 所有** 由该控制器创建的 pod,因此授权策略的授权方式应该时授权给 pod 的服务账户 (参见 [ 示例] ( #run-another-pod ) )。
135
+ 授权策略给控制器即授权给 ** 所有** 由该控制器创建的 pod,因此授权策略的授权方式应该时授权给 pod 的 service account (参见 [ 示例] ( #run-another-pod ) )。
136
136
137
137
<!--
138
138
### Via RBAC
@@ -246,7 +246,7 @@ paired with system groups to grant access to all pods run in the namespace:
246
246
` ` `
247
247
-->
248
248
` ` ` yaml
249
- # 授权命名空间下的所有服务账户 :
249
+ # 授权命名空间下的所有 service accounts :
250
250
- kind: Group
251
251
apiGroup: rbac.authorization.k8s.io
252
252
name: system:serviceaccounts
@@ -294,7 +294,7 @@ also be used to provide default values for many of the fields that it
294
294
controls. When multiple policies are available, the pod security policy
295
295
controller selects policies according to the following criteria :
296
296
-->
297
- 除了限制 pod 的创建和更新之外,PodSecurityPolicy 也可以用于为由其控制的许多字段提供默认值 。当同时多个策略可用时,PodSecurityPolicy 控制器依据以下标准选择策略 :
297
+ 除了限制 pod 的创建和更新之外,pod 安全策略也可以用于为由其控制的许多字段提供默认值 。当同时多个策略可用时,pod 安全策略控制器依据以下标准选择策略 :
298
298
299
299
<!--
300
300
1. PodSecurityPolicies which allow the pod as-is, without changing defaults or
@@ -334,7 +334,7 @@ _这个示例假定你有一个运行中且已启用 PodSecurityPolicy admission
334
334
Set up a namespace and a service account to act as for this example. We'll use
335
335
this service account to mock a non-admin user.
336
336
-->
337
- 以此为例设置一个命名空间和服务账户. 我们将使用这个服务账户来模拟一个非管理员用户 .
337
+ 以此为例设置一个命名空间和 service account. 我们将使用这个 service account 来模拟一个非管理员用户 .
338
338
339
339
` ` ` shell
340
340
kubectl create namespace psp-example
@@ -401,7 +401,7 @@ Error from server (Forbidden): error when creating "STDIN": pods "pause" is forb
401
401
**What happened?** Although the PodSecurityPolicy was created, neither the
402
402
pod's service account nor `fake-user` have permission to use the new policy :
403
403
-->
404
- *** 发生了什么?* 尽管 PodSecurityPolicy 已经创建, pod 的 service account 和 `fake-user` 都没有权限使用这个策略:
404
+ **发生了什么?* * 尽管 PodSecurityPolicy 已经创建, pod 的 service account 和 `fake-user` 都没有权限使用这个策略:
405
405
406
406
` ` ` shell
407
407
kubectl-user auth can-i use podsecuritypolicy/example
441
441
<!--
442
442
Now retry creating the pod :
443
443
-->
444
- 接下来尝试创建这个 pod :
444
+ 现在重新创建这个 pod :
445
445
446
446
` ` ` shell
447
447
kubectl-user create -f- <<EOF
@@ -461,7 +461,7 @@ pod "pause" created
461
461
It works as expected! But any attempts to create a privileged pod should still
462
462
be denied :
463
463
-->
464
- 它按预期运行 ,但是任何创建特权 pod 的尝试应当都被拒绝 :
464
+ 它如期运行 ,但是任何创建特权 pod 的尝试都应当被拒绝 :
465
465
466
466
` ` ` shell
467
467
kubectl-user create -f- <<EOF
@@ -519,7 +519,7 @@ deployment (which successfully created a replicaset), but when the replicaset
519
519
went to create the pod it was not authorized to use the example
520
520
podsecuritypolicy.
521
521
-->
522
- **发生了什么?**我们已经将 `psp:unprivileged` 角色绑定给了 `fake-user`, 为何仍然报错
522
+ **发生了什么?** 我们已经将 `psp:unprivileged` 角色绑定给了 `fake-user`, 为何仍然报错
523
523
`Error creating : pods "pause-7774d79b5-" is forbidden: no providers available to validate pod request`?
524
524
答案在 `replicaset-controller` 源码中. Fake-user 成功创建了 deployment (并且该 deployment 成功创建了一个 replicaset),
525
525
然而当该 replicaset 想要创建 pod 时却没有权限使用我们的示例 pod 安全策略.
@@ -529,7 +529,7 @@ In order to fix this, bind the `psp:unprivileged` role to the pod's service
529
529
account instead. In this case (since we didn't specify it) the service account
530
530
is `default` :
531
531
-->
532
- 为了修复这个问题, 将 `psp:unprivileged` 角色绑定给 pod 的 service account. 在这种情况下(由于我们没有显式指定) 该 service account 为 `default` :
532
+ 为了修复这个问题, 将 `psp:unprivileged` 角色绑定给 pod 的 service account. 在这种情况下(由于我们没有显式指定) 该 service account 为 `default` :
533
533
534
534
` ` ` shell
535
535
kubectl-admin create rolebinding default:psp:unprivileged \
@@ -780,7 +780,7 @@ kind: PodSecurityPolicy
780
780
metadata:
781
781
name: allow-flex-volumes
782
782
spec:
783
- # ... other spec fields
783
+ # ... 其他特性字段
784
784
volumes:
785
785
- flexVolume
786
786
allowedFlexVolumes:
0 commit comments