k8spspvolumetypes
Basic Information
Function
This policy restricts the type of the volumes field in PodSecurityPolicy.
Policy Example
The following policy instance shows the resource types for which the policy definition takes effect. The volumes field of parameters defines the allowed types.
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: K8sPSPVolumeTypes metadata: name: psp-volume-types spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] parameters: volumes: # - "*" # * may be used to allow all volume types - configMap - emptyDir - projected - secret - downwardAPI - persistentVolumeClaim #- hostPath #required for allowedHostPaths - flexVolume #required for allowedFlexVolumes
Resource Definition That Complies with the Policy
In the example, the types in volumes are within the preceding range and comply with the policy.
apiVersion: v1 kind: Pod metadata: name: nginx-volume-types-allowed labels: app: nginx-volume-types spec: containers: - name: nginx image: nginx volumeMounts: - mountPath: /cache name: cache-volume - name: nginx2 image: nginx volumeMounts: - mountPath: /cache2 name: demo-vol volumes: - name: cache-volume emptyDir: {} - name: demo-vol emptyDir: {}
Resource Definition That Does Not Comply with the Policy
In the example, the type (hostPath) in volumes is not within the preceding range and does not comply with the policy instance.
apiVersion: v1 kind: Pod metadata: name: nginx-volume-types-disallowed labels: app: nginx-volume-types spec: containers: - name: nginx image: nginx volumeMounts: - mountPath: /cache name: cache-volume - name: nginx2 image: nginx volumeMounts: - mountPath: /cache2 name: demo-vol volumes: - name: cache-volume hostPath: path: /tmp # directory location on host - name: demo-vol emptyDir: {}
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot