How can I control access to storageclasses in Kubernetes?

7/18/2018

Is it possible to restrict the ability of particular users to dynamically provision disks from storageclasses? Or, for example, only allowing particular namespaces to be able to use a storageclass?

-- dippynark
kubernetes

2 Answers

7/19/2018

Storage resource quota can be used to restrict usage of storage classes

-- dippynark
Source: StackOverflow

7/18/2018

Fair warning: I haven't tested this!

StorageClass is just an API endpoint, and RBAC works by restricting access to those endpoints, so in theory this should work just fine:

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: sc_access
rules:
- apiGroups: ["storage.k8s.io", "core" ]
  resources: [ "storageclass" ]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]

If that doesn't work, you might be able to restrict access directly via the NonResourceUrls option:

rules:
- nonResourceURLs: ["/storage.k8s.io/v1/storageclasses"]
  verbs: ["get", "post"]
-- jaxxstorm
Source: StackOverflow