Minimal RBAC Configuration for Development Clusters
The following describes the minimal RBAC roles and permissions required for day-to-day use by developers for Garden when using the kubernetes plugin. These should be created along with the kubeconfig/kubecontext for the user in their namespace, replacing the <username>, <service-accounts-namespace> and <project-namespace> values as appropriate.
---# The user service accountapiVersion:v1kind:ServiceAccountmetadata:name:user-<username>namespace:<service-accounts-namespace>---# Project namespacesapiVersion:v1kind:Namespacemetadata:name:<project-namespace># Some required annotationsannotations:garden.io/version:"0.11.3"---# Allow reading namespaces and persistent volumes, which are cluster-scopedapiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:user-<username>rules:- apiGroups: [""]resources: ["namespaces","persistentvolumes"]verbs: ["get","list"]---apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRoleBindingmetadata:name:user-<username>namespace:<service-accounts-namespace>roleRef:apiGroup:rbac.authorization.k8s.iokind:ClusterRolename:user-<username>subjects:- namespace:<service-accounts-namespace>kind:ServiceAccountname:user-<username>---# Full permissions within the <project-namespace>apiVersion:rbac.authorization.k8s.io/v1kind:Rolemetadata:name:<project-namespace>namespace:<project-namespace>rules:- apiGroups: ["*"]resources: ["*"]verbs: ["*"]---apiVersion:rbac.authorization.k8s.io/v1kind:RoleBindingmetadata:name:<project-namespace>namespace:<project-namespace>roleRef:apiGroup:rbac.authorization.k8s.iokind:Rolename:<project-namespace>subjects:- namespace:<service-accounts-namespace>kind:ServiceAccountname:user-<username>---# Required access for the garden-system namespacekind:RoleapiVersion:rbac.authorization.k8s.io/v1metadata:namespace:garden-systemname:user-<username>-commonrules:# Allow storing and reading test results- apiGroups: [""]resources: ["configmaps"]verbs: ["get","list","create"]# Allow getting status of shared services- apiGroups: [""]resources: - "configmaps" - "services" - "serviceaccounts" - "persistentvolumeclaims" - "pods/log"verbs: ["get","list"]- apiGroups: [""]resources: ["configmaps","services","serviceaccounts"]verbs: ["get","list"]- apiGroups: ["rbac.authorization.k8s.io"]resources: ["roles","rolebindings"]verbs: ["get","list"]# Note: We do not store anything sensitive in secrets, aside from registry auth,# which users anyway need to be able to read and push built images.- apiGroups: [""]resources: ["secrets"]verbs: ["get","list"]---apiVersion:rbac.authorization.k8s.io/v1kind:RoleBindingmetadata:name:user-<username>-commonnamespace:garden-systemroleRef:kind:Rolename:user-<username>-commonapiGroup:""subjects:- namespace:<service-accounts-namespace>kind:ServiceAccountname:user-<username>