This document outlines the permissions that are provisioned for the DevWorkspace service account by default. The role attached to the workspace ServiceAccount is defined in rbac.go. As a regular Kubernetes role definition, this is
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: workspace
rules:
- apiGroups:
- ""
resources:
- pods/exec
verbs:
- create
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- watch
- apiGroups:
- apps
- extensions
resources:
- deployments
- replicasets
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- create
- patch
- update
- delete
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- create
- patch
- update
- delete
- apiGroups:
- workspace.devfile.io
resources:
- devworkspaces
verbs:
- get
- watch
- list
- patch
- update
- apiGroups:
- controller.devfile.io
resources:
- devworkspaceroutings
verbs:
- get
- list
- watch
- apiGroups:
- workspace.devfile.io
resources:
- devworkspacetemplates
verbs:
- get
- create
- patch
- update
- delete
- list
- watchAdditional permissions can be bound to the DevWorkspace ServiceAccount as follows:
- Find the DevWorkspace ID for the DevWorkspace in question. This is available on the
.status.devworkspaceIdfield in the object, which can be obtained usingjq:The service account created for the DevWorkspace will be namedDEVWORKSPACE_ID=$(kubectl get devworkspaces <workspace-name> -o json | jq -r '.status.devworkspaceId')${DEVWORKSPACE_ID}-sa - Create a rolebinding to attach a custom role to the workspace service account:
where
NAMESPACE=<workspace namespace> cat << EOF | kubectl apply -f - apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: workspace-${DEVWORKSPACE_ID}-custom-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: <custom role name> subjects: - kind: ServiceAccount name: ${DEVWORKSPACE_ID}-sa namespace: $NAMESPACE EOF
<current namespace>is the namespace of the workspace, and<custom role name>is the name of role to be bound to the DevWorkspace.
In order to grant permissions to all workspaces in a given namespace, the RoleBinding can instead bind to all ServiceAccounts in the namespace:
NAMESPACE=<workspace namespace>
cat << EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: devworkspace-custom-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: <custom role name>
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: system:serviceaccounts:$NAMESPACE
EOFNote however that this will bind the role to all service accounts in that namespace, including the default serviceaccount used for pods.
For more information on creating rolebindings, see rolebinding and clusterrolebinding in the Kubernetes documentation.