In the dev
configuration in devspace.yaml
, we add a labelSelector
dev:
the-dev-container:
labelSelector:
<the-label-key>: <the-label-value>
This is helpful if we have to deploy multiple dev container Pods in a single namespace. We could for example add a user identifier (such as the email from the Git config) as a label selector to be able to distinguish between Pods for multiple users that are deployed to the same namespace.
dev:
the-dev-container:
labelSelector:
devspace.sh/user: "${USER}"
vars:
USER: $(git config user.email | tr '@' '_')
Note that unlike stated in the DevSpace documentation, .dev.imageSelector
and .dev.labelSelector
may not be used together (at least in version 6.3.12). DevSpace CLI returns the following error if both selectors are specified simultaneously:
fatal dev.the-dev-container: image selector and label selector cannot be used together
We have to replace @
with a legal symbol for label values. I’m replacing it with _
. Hence the ... | tr '@' '_'
part of the USER
variable assignment.