Set the workspace namespace naming convention
Set the project name template that OpenShift Dev Spaces uses when creating workspace projects to enforce naming conventions and organizational compliance.
Before you begin
- You have an active
ocsession with administrative permissions to the OpenShift cluster. See This page is not included, but the link has been rewritten to point to the nearest parent document.Getting started with the CLI.
About this task
A valid project name template follows these conventions:
- The
<username>or<userid>placeholder is mandatory. - Usernames and IDs cannot contain invalid characters. If a username or ID is incompatible with OpenShift naming conventions, OpenShift Dev Spaces replaces incompatible characters with the
-symbol. - OpenShift Dev Spaces evaluates the
<userid>placeholder into a 14 character long string, and adds a random six character long suffix to prevent IDs from colliding. The result is stored in the user preferences for reuse. - Kubernetes limits the length of a project name to 63 characters.
- OpenShift limits the length further to 49 characters.
Procedure
Edit the
CheCluster Custom Resource on the cluster:
$ oc edit checluster/devspaces -n openshift-devspacesspec:
components:
devEnvironments:
defaultNamespace:
template: <workspace_namespace_template>where:
-
<workspace_namespace_template> -
The project name template. Must include the
<username>or<userid>placeholder.Table 1. User workspaces project name template examples User workspaces project name template Resulting project example <username>-devspaces(default)user1-devspaces
<userid>-namespacecge1egvsb2nhba-namespace-ul1411<userid>-aka-<username>-namespacecgezegvsb2nhba-aka-user1-namespace-6m2w2b
Results
- Start a workspace and verify that the workspace project name matches the configured template:
oc get devworkspaces -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"\n"}{end}'