Simulation
Create a PSP that will only allow the persistentvolumeclaim as the volume type in the namespace restricted.
Create a new PodSecurityPolicy named prevent-volume-policy which prevents the pods which is having different volumes mount apart from persistentvolumeclaim.
Create a new ServiceAccount named psp-sa in the namespace restricted.
Create a new ClusterRole named psp-role, which uses the newly created Pod Security Policy prevent-volume-policy
Create a new ClusterRoleBinding named psp-role-binding, which binds the created ClusterRole psp-role to the created SA psp-sa.
Hint:
Also, Check the Configuration is working or not by trying to Mount a Secret in the pod maifest, it should get failed.
POD Manifest:
1. apiVersion: v1
2. kind: Pod
3. metadata:
4. name:
5. spec:
6. containers:
7. - name:
8. image:
9. volumeMounts:
10.- name:
11. mountPath:
12. volumes:
13.- name:
14. secret:
15. secretName:
Not auto-scored - compare your configuration against the model answer.