Skip to content

Commit f1c1a43

Browse files
committed
Use PSP from policy API group.
1 parent 857fee8 commit f1c1a43

File tree

7 files changed

+26
-14
lines changed

7 files changed

+26
-14
lines changed

docs/admin/authorization/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ DELETE | delete (for individual resources), deletecollection (for collections
6767

6868
Kubernetes sometimes checks authorization for additional permissions using specialized verbs. For example:
6969

70-
* [PodSecurityPolicy](/docs/concepts/policy/pod-security-policy/) checks for authorization of the `use` verb on `podsecuritypolicies` resources in the `extensions` API group.
70+
* [PodSecurityPolicy](/docs/concepts/policy/pod-security-policy/) checks for authorization of the `use` verb on `podsecuritypolicies` resources in the `policy` API group.
7171
* [RBAC](/docs/admin/authorization/rbac/#privilege-escalation-prevention-and-bootstrapping) checks for authorization
7272
of the `bind` verb on `roles` and `clusterroles` resources in the `rbac.authorization.k8s.io` API group.
7373
* [Authentication](/docs/admin/authentication/) layer checks for authorization of the `impersonate` verb on `users`, `groups`, and `serviceaccounts` in the core API group, and the `userextras` in the `authentication.k8s.io` API group.

docs/concepts/policy/example-psp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: policy/v1beta1
22
kind: PodSecurityPolicy
33
metadata:
44
name: example

docs/concepts/policy/pod-security-policy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ controller](/docs/admin/admission-controllers/#how-do-i-turn-on-an-admission-con
4949
but doing so without authorizing any policies **will prevent any pods from being
5050
created** in the cluster.
5151

52-
Since the pod security policy API (`extensions/v1beta1/podsecuritypolicy`) is
52+
Since the pod security policy API (`policy/v1beta1/podsecuritypolicy`) is
5353
enabled independently of the admission controller, for existing clusters it is
5454
recommended that policies are added and authorized before enabling the admission
5555
controller.
@@ -84,7 +84,7 @@ apiVersion: rbac.authorization.k8s.io/v1
8484
metadata:
8585
name: <role name>
8686
rules:
87-
- apiGroups: ['extensions']
87+
- apiGroups: ['policy']
8888
resources: ['podsecuritypolicies']
8989
verbs: ['use']
9090
resourceNames:

docs/concepts/policy/privileged-psp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: policy/v1beta1
22
kind: PodSecurityPolicy
33
metadata:
44
name: privileged

docs/concepts/policy/restricted-psp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: policy/v1beta1
22
kind: PodSecurityPolicy
33
metadata:
44
name: restricted

docs/tutorials/clusters/apparmor.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,13 @@ node with the required profile.
317317
### Restricting profiles with the PodSecurityPolicy
318318

319319
If the PodSecurityPolicy extension is enabled, cluster-wide AppArmor restrictions can be applied. To
320-
enable the PodSecurityPolicy, two flags must be set on the `apiserver`:
320+
enable the PodSecurityPolicy, the following flag must be set on the `apiserver`:
321321

322322
```
323323
--admission-control=PodSecurityPolicy[,others...]
324-
--runtime-config=extensions/v1beta1/podsecuritypolicy[,others...]
325324
```
326325

327-
With the extension enabled, the AppArmor options can be specified as annotations on the PodSecurityPolicy:
326+
The AppArmor options can be specified as annotations on the PodSecurityPolicy:
328327

329328
```yaml
330329
apparmor.security.beta.kubernetes.io/defaultProfileName: <profile_ref>

test/examples_test.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"strings"
2929
"testing"
3030

31+
policyv1beta1 "k8s.io/api/policy/v1beta1"
3132
"k8s.io/apimachinery/pkg/runtime"
3233
"k8s.io/apimachinery/pkg/types"
3334
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -47,6 +48,7 @@ import (
4748
"k8s.io/kubernetes/pkg/apis/extensions"
4849
ext_validation "k8s.io/kubernetes/pkg/apis/extensions/validation"
4950
"k8s.io/kubernetes/pkg/apis/policy"
51+
policyconversion "k8s.io/kubernetes/pkg/apis/policy/v1beta1"
5052
policy_validation "k8s.io/kubernetes/pkg/apis/policy/validation"
5153
"k8s.io/kubernetes/pkg/apis/rbac"
5254
rbac_validation "k8s.io/kubernetes/pkg/apis/rbac/validation"
@@ -173,8 +175,8 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
173175
t.Namespace = api.NamespaceDefault
174176
}
175177
errors = ext_validation.ValidateIngress(t)
176-
case *extensions.PodSecurityPolicy:
177-
errors = ext_validation.ValidatePodSecurityPolicy(t)
178+
case *policyv1beta1.PodSecurityPolicy:
179+
errors = validatePodSecurityPolicy(t)
178180
case *extensions.ReplicaSet:
179181
if t.Namespace == "" {
180182
t.Namespace = api.NamespaceDefault
@@ -312,9 +314,9 @@ func TestExampleObjectSchemas(t *testing.T) {
312314
"nginx-deployment": {&extensions.Deployment{}},
313315
},
314316
"../docs/concepts/policy": {
315-
"privileged-psp": {&extensions.PodSecurityPolicy{}},
316-
"restricted-psp": {&extensions.PodSecurityPolicy{}},
317-
"example-psp": {&extensions.PodSecurityPolicy{}},
317+
"privileged-psp": {&policyv1beta1.PodSecurityPolicy{}},
318+
"restricted-psp": {&policyv1beta1.PodSecurityPolicy{}},
319+
"example-psp": {&policyv1beta1.PodSecurityPolicy{}},
318320
},
319321
"../docs/concepts/services-networking": {
320322
"curlpod": {&extensions.Deployment{}},
@@ -754,3 +756,14 @@ func TestReadme(t *testing.T) {
754756
}
755757
}
756758
}
759+
760+
// TODO: remove type conversion when PSP validation will accept PSP from policy group
761+
func validatePodSecurityPolicy(newPsp *policyv1beta1.PodSecurityPolicy) field.ErrorList {
762+
oldPsp := &extensions.PodSecurityPolicy{}
763+
if err := policyconversion.Convert_v1beta1_PodSecurityPolicy_To_extensions_PodSecurityPolicy(newPsp, oldPsp, nil); err != nil {
764+
errs := field.ErrorList{}
765+
errs = append(errs, field.InternalError(field.NewPath(""), fmt.Errorf("cannot convert PSP from policy to extensions group: %v", err)))
766+
return errs
767+
}
768+
return ext_validation.ValidatePodSecurityPolicy(oldPsp)
769+
}

0 commit comments

Comments
 (0)