Chapter 11. Integrate with OpenShift


Manage OpenShift Dev Spaces workspaces by using OpenShift APIs, automatic token injection, and the OpenShift web console.

OpenShift Dev Spaces workspaces run as OpenShift resources. You can create, list, stop, and remove workspaces by using standard OpenShift tools such as oc or the web console. You can also navigate between OpenShift Dev Spaces and the OpenShift Developer perspective.

11.1. OpenShift integration overview

OpenShift Dev Spaces integrates with OpenShift to provide automatic API token injection, direct console access, and seamless navigation between workspaces and cluster resources.

Key integration features include:

  • Managing workspaces using Kubernetes APIs
  • Automatic token injection for cluster access
  • Navigating to OpenShift Dev Spaces from the OpenShift Developer Perspective
  • Navigating to the OpenShift Web Console from OpenShift Dev Spaces

On your organization’s OpenShift cluster, each OpenShift Dev Spaces workspace is represented as a DevWorkspace custom resource of the same name. For example, a workspace named my-workspace in the OpenShift Dev Spaces dashboard has a corresponding DevWorkspace custom resource in the user’s project. You can manage OpenShift Dev Spaces workspaces by using OpenShift APIs with clients such as the command-line oc.

Each DevWorkspace custom resource contains details derived from the devfile of the Git repository cloned for the workspace, such as devfile commands and workspace container configurations.

11.2. List all workspaces

List your workspaces from the command line to check their status, identify stopped or failed workspaces, and monitor resource usage across your OpenShift Dev Spaces environment.

Prerequisites

  • You have an active oc session with permissions to get the DevWorkspace resources in your project on the cluster. See Getting started with the CLI.
  • You know the relevant OpenShift Dev Spaces user namespace on the cluster. Visit https://<openshift_dev_spaces_fqdn>/api/kubernetes/namespace to get your OpenShift Dev Spaces user namespace as name.
  • You are in the OpenShift Dev Spaces user namespace on the cluster. On OpenShift, use oc to display your current namespace or switch to a namespace.

Procedure

  1. List your workspaces:

    $ oc get devworkspaces

    Example output:

    NAMESPACE   NAME                 DEVWORKSPACE ID             PHASE     INFO
    user1-dev   spring-petclinic     workspace6d99e9ffb9784491   Running   https://url-to-workspace.com
    user1-dev   golang-example       workspacedf64e4a492cd4701   Stopped   Stopped
    user1-dev   python-hello-world   workspace69c26884bbc141f2   Failed    Container tooling has state CrashLoopBackOff
  2. Optional: Add the --watch flag to show PHASE changes live:

    $ oc get devworkspaces --watch
  3. Optional: Add the --all-namespaces flag to list workspaces from all OpenShift Dev Spaces users. This requires administrative permissions on the cluster.

    $ oc get devworkspaces --all-namespaces

11.3. Create workspaces

If your use case does not permit use of the OpenShift Dev Spaces dashboard, create workspaces with OpenShift APIs by applying custom resources to the cluster.

Creating workspaces through the OpenShift Dev Spaces dashboard provides better user experience and configuration benefits compared to using the command line:

  • As a user, you are automatically logged in to the cluster.
  • OpenShift clients work automatically.
  • OpenShift Dev Spaces and its components automatically convert the target Git repository’s devfile into the DevWorkspace and DevWorkspaceTemplate custom resources on the cluster.
  • Access to the workspace is secured by default with the routingClass: che in the DevWorkspace of the workspace.
  • Recognition of the DevWorkspaceOperatorConfig configuration is managed by OpenShift Dev Spaces.
  • Recognition of configurations in spec.devEnvironments specified in the CheCluster custom resource including:

    • Persistent storage strategy is specified with devEnvironments.storage.
    • Default IDE is specified with devEnvironments.defaultEditor.
    • Default plugins are specified with devEnvironments.defaultPlugins.
    • Container build configuration is specified with devEnvironments.containerBuildConfiguration.

Prerequisites

  • You have an active oc session with permissions to create DevWorkspace resources in your project on the cluster. See Getting started with the CLI.
  • You know your OpenShift Dev Spaces user namespace on the cluster. To retrieve it, visit https://<openshift_dev_spaces_fqdn>/api/kubernetes/namespace and find the name value.
  • You are in your OpenShift Dev Spaces user namespace on the cluster. On OpenShift, use oc to display your current namespace or switch to a namespace.

    To create workspaces for other users, create the DevWorkspace custom resource in the target user namespace. This namespace must be provisioned by OpenShift Dev Spaces or by the administrator. See Configuring a user namespace.

Procedure

  1. Copy the contents of the target Git repository’s devfile to prepare the DevWorkspace custom resource.

    For example:

    components:
      - name: tooling-container
        container:
          image: quay.io/devfile/universal-developer-image:ubi9-latest

    For more details, see the devfile v2 documentation.

  2. Create a DevWorkspace custom resource, pasting the devfile contents from the previous step under the spec.template field.

    For example:

    kind: DevWorkspace
    apiVersion: workspace.devfile.io/v1alpha2
    metadata:
      name: my-devworkspace
      namespace: user1-dev
    spec:
      routingClass: che
      started: true
      contributions:
        - name: ide
          uri: http://devspaces-dashboard.openshift-devspaces.svc.cluster.local:8080/dashboard/api/editors/devfile?che-editor=che-incubator/che-code/latest
      template:
        projects:
          - name: my-project-name
            git:
              remotes:
                origin: https://github.com/eclipse-che/che-docs
        components:
          - name: tooling-container
            container:
              image: quay.io/devfile/universal-developer-image:ubi9-latest
              env:
                - name: CHE_DASHBOARD_URL
                  value: https://<openshift_dev_spaces_fqdn>/dashboard/

    where:

    name
    Name of the DevWorkspace custom resource. This is the name of the new workspace.
    namespace
    User namespace, which is the target project for the new workspace.
    started
    Determines whether the workspace must be started when the DevWorkspace custom resource is created.
    contributions
    URL reference to the Microsoft Visual Studio Code - Open Source IDE devfile.
    projects
    Details about the Git repository to clone into the workspace when it starts.
    components
    List of components such as workspace containers and volume components.
    CHE_DASHBOARD_URL
    URL to OpenShift Dev Spaces dashboard.
  3. Apply the DevWorkspace custom resource to the cluster.

    $ oc apply -f <devworkspace>.yaml

Verification

  1. Verify that the workspace is starting by checking the PHASE status of the DevWorkspace.

    $ oc get devworkspaces -n <user_project> --watch

    Example output:

    NAMESPACE        NAME                  DEVWORKSPACE ID             PHASE      INFO
    user1-dev        my-devworkspace       workspacedf64e4a492cd4701   Starting   Waiting for workspace deployment
  2. When the workspace has successfully started, its PHASE status changes to Running in the output of the oc get devworkspaces command.

    Example output:

    NAMESPACE            NAME                  DEVWORKSPACE ID             PHASE      INFO
    user1-dev            my-devworkspace       workspacedf64e4a492cd4701   Running    https://url-to-workspace.com

    You can then open the workspace by using one of these options:

    • Visit the URL provided in the INFO section of the output of the oc get devworkspaces command.
    • Open the workspace from the OpenShift Dev Spaces dashboard.

11.4. Stop workspaces

Stop a workspace by setting the spec.started field in the DevWorkspace custom resource to false.

Prerequisites

  • You have an active oc session on the cluster. See Getting started with the CLI.
  • You have the workspace name. Run oc get devworkspaces to list workspace names.
  • You have the relevant OpenShift Dev Spaces user namespace on the cluster. Visit https://<openshift_dev_spaces_fqdn>/api/kubernetes/namespace to get your OpenShift Dev Spaces user namespace as name.
  • You are in the OpenShift Dev Spaces user namespace on the cluster. On OpenShift, use oc to display your current namespace or switch to a namespace.

Procedure

  1. Run the following command to stop a workspace:

    $ oc patch devworkspace <workspace_name> \
    -p '{"spec":{"started":false}}' \
    --type=merge -n <user_namespace> && \
    oc wait --for=jsonpath='{.status.phase}'=Stopped \
    dw/<workspace_name> -n <user_namespace>

11.5. Start stopped workspaces

Start a stopped workspace by setting the spec.started field in the DevWorkspace custom resource to true.

Prerequisites

  • You have an active oc session on the cluster. See Getting started with the CLI.
  • You have the workspace name. Run oc get devworkspaces to list workspace names.
  • You have the relevant OpenShift Dev Spaces user namespace on the cluster. Visit https://<openshift_dev_spaces_fqdn>/api/kubernetes/namespace to get your OpenShift Dev Spaces user namespace as name.
  • You are in the OpenShift Dev Spaces user namespace on the cluster. On OpenShift, use oc to display your current namespace or switch to a namespace.

Procedure

  1. Run the following command to start a stopped workspace:

    $ oc patch devworkspace <workspace_name> \
    -p '{"spec":{"started":true}}' \
    --type=merge -n <user_namespace> && \
    oc wait --for=jsonpath='{.status.phase}'=Running \
    dw/<workspace_name> -n <user_namespace>

11.6. Remove workspaces

Remove a workspace from the command line by deleting its DevWorkspace custom resource. The OpenShift Dev Spaces dashboard is the recommended method for routine operations.

Warning

Deleting the DevWorkspace custom resource also deletes other workspace resources if they were created by OpenShift Dev Spaces: for example, the referenced DevWorkspaceTemplate and per-workspace PersistentVolumeClaims.

Prerequisites

  • You have an active oc session on the cluster. See Getting started with the CLI.
  • You know the workspace name. Run oc get devworkspaces to list workspace names.
  • You know the relevant OpenShift Dev Spaces user namespace on the cluster. Visit https://<openshift_dev_spaces_fqdn>/api/kubernetes/namespace to get your OpenShift Dev Spaces user namespace as name. On OpenShift, use oc to display your current namespace or switch to a namespace.
  • You are in the OpenShift Dev Spaces user namespace on the cluster.

Procedure

  • Run the following command to remove a workspace:

    $ oc delete devworkspace <workspace_name> -n <user_namespace>

11.7. Use automatic OpenShift token injection

Use the OpenShift user token that is automatically injected into workspace containers to run oc and kubectl commands against the OpenShift cluster without explicit login.

Warning

Automatic token injection works only on the OpenShift infrastructure.

Prerequisites

  • You have a running instance of Red Hat OpenShift Dev Spaces.

Procedure

  1. Open the OpenShift Dev Spaces dashboard and start a workspace.
  2. After the workspace starts, open a terminal in the workspace container.
  3. Run oc or kubectl commands to deploy applications, inspect and manage cluster resources, or view logs. The injected OpenShift user token authenticates these commands automatically.

    $ oc get pods
    Token Injection in IDE

Access OpenShift Dev Spaces workspaces directly from the OpenShift Developer Perspective to open, edit, and manage workspace code alongside other cluster resources.

When the OpenShift Dev Spaces Operator is deployed into OpenShift Container Platform 4.2 and later, it creates a ConsoleLink Custom Resource (CR). This adds an interactive link to the Red Hat Applications menu for accessing the OpenShift Dev Spaces installation. To access the menu, click the three-by-three matrix icon on the main screen of the OpenShift web console. The OpenShift Dev Spaces Console Link creates a new workspace or redirects you to an existing one.

The console link requires HTTPS. When installing OpenShift Dev Spaces with the From Git option, the console link is only created if OpenShift Dev Spaces is deployed with HTTPS.

Starting with OpenShift Container Platform 4.19, the web console perspectives have unified. There is no longer a separate Developer perspective in the default view. All OpenShift Container Platform web console features remain discoverable to all users, but you might need to request permission for certain features from the cluster owner. The Getting Started pane includes a quick start for enabling the Developer perspective if you prefer the previous layout.

Edit the source code of applications running on OpenShift directly from the Developer Perspective to fix and iterate on deployed components without switching tools.

Prerequisites

  • You have OpenShift Dev Spaces deployed on the same OpenShift 4 cluster.

Procedure

  1. Open the Topology view to list all projects.
  2. In the Select an Application search field, type workspace to list all workspaces.
  3. Click the workspace to edit.

    The deployments are displayed as graphical circles surrounded by circular buttons. One of these buttons is Edit Source Code.

    Edit Source Code button in the OpenShift Developer Perspective
  4. Click the Edit Source Code button. This redirects to a workspace with the cloned source code of the application component.

Open OpenShift Dev Spaces directly from the Red Hat Applications menu on OpenShift Container Platform to reach the Dashboard without navigating away from your current OpenShift context.

Prerequisites

  • You have the OpenShift Dev Spaces Operator available in OpenShift 4.

Procedure

  1. Open the Red Hat Applications menu by using the three-by-three matrix icon in the upper right corner of the main screen.

    The drop-down menu displays the available applications.

    Applications in the drop-down menu
  2. Click the OpenShift Dev Spaces link to open the Red Hat OpenShift Dev Spaces Dashboard.

Navigate to the OpenShift web console from the OpenShift Dev Spaces dashboard to manage cluster resources, inspect pods, and troubleshoot workspace issues without leaving your workflow.

Prerequisites

  • You have the OpenShift Dev Spaces Operator available in OpenShift Container Platform 4.

Procedure

  1. Open the OpenShift Dev Spaces dashboard and click the three-by-three matrix icon in the upper right corner of the main screen.

    The drop-down menu displays the available applications.

    OpenShift web console in the drop-down menu
  2. Click the OpenShift console link to open the OpenShift web console.
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top