blob: 3897dbe3b5a743a1046f1bc9ac8e11812e6f987d [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Managing workspaces with Kubernetes APIs :: Eclipse Che Documentation</title>
<link rel="canonical" href="https://www.eclipse.org/che/docs/stable/end-user-guide/managing-workspaces-with-apis/">
<meta name="description" content="Managing workspaces with Kubernetes APIs">
<meta name="keywords" content="api, list workspaces, create workspace, restart workspace, stop workspace, start workspace, remove workspace">
<meta name="generator" content="Antora 3.1.7">
<link rel="stylesheet" href="../../../../docs/_/css/site.css">
<link rel="stylesheet" href="../../../../docs/_/css/extra.css">
<link rel="stylesheet" href="../../../../docs/_/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="icon" href="../../../../docs/_/img/favicon.ico" type="image/x-icon">
<script>var uiRootPath = '../../../../docs/_'</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-37306001-2"></script>
<script>function gtag(){dataLayer.push(arguments)};window.dataLayer=window.dataLayer||[];gtag('js',new Date());gtag('config','UA-37306001-2')</script>
</head>
<body class="article">
<header class="header">
<nav class="navbar">
<div class="navbar-brand">
<div class="navbar-item">
<button class="navbar-burger" data-target="topbar-nav">
<span></span>
<span></span>
<span></span>
</button>
<img src="../../../../docs/_/img/icon-eclipse-che.svg" class="navbar-logo" alt="Eclipse Che logo">
<a href="https://www.eclipse.org/che/docs/index.html">Eclipse Che Documentation</a>
</div>
</div>
<div id="topbar-nav" class="navbar-menu">
<div class="navbar-end">
<div class="navbar-item search hide-for-print">
<div id="search-field" class="field">
<input id="search-input" type="text" placeholder="Search the docs">
</div>
</div>
<a class="navbar-item" href="https://www.eclipse.org/che/">Home</a>
<a class="navbar-item" href="https://che.eclipseprojects.io/">Blog</a>
<a class="navbar-item" href="https://github.com/eclipse/che">Source Code</a>
</div>
</div>
</nav>
</header>
<div class="body">
<div class="nav-container" data-component="docs" data-version="7.82.x">
<aside class="nav">
<div class="panels">
<div class="nav-panel-menu is-active" data-panel="menu">
<nav class="nav-menu">
<button class="nav-menu-toggle" aria-label="Toggle expand/collapse all" style="display: none"></button>
<h3 class="title"><a href="../../overview/introduction-to-eclipse-che/">Documentation</a></h3>
<ul class="nav-list">
<li class="nav-item" data-depth="0">
<ul class="nav-list">
<li class="nav-item" data-depth="1">
<a class="nav-link" href="../../overview/introduction-to-eclipse-che/">Introduction to Che</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="0">
<ul class="nav-list">
<li class="nav-item" data-depth="1">
<a class="nav-link" href="../../hosted-che/hosted-che/">Eclipse Che hosted by Red Hat</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="0">
<button class="nav-item-toggle"></button>
<span class="nav-text">User Guide</span>
<ul class="nav-list">
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../getting-started-with-che/">Getting started with Che</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../starting-a-workspace-from-a-git-repository-url/">Starting a workspace from a Git repository URL</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../optional-parameters-for-the-urls-for-starting-a-new-workspace/">Optional parameters for the URLs for starting a new workspace</a>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-concatenation/">URL parameter concatenation</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-for-the-ide/">URL parameter for the IDE</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-for-the-ide-image/">URL parameter for the IDE image</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-for-starting-duplicate-workspaces/">URL parameter for starting duplicate workspaces</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-for-the-devfile-file-name/">URL parameter for the devfile file name</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-for-the-devfile-file-path/">URL parameter for the devfile file path</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-for-the-workspace-storage/">URL parameter for the workspace storage</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-for-additional-remotes/">URL parameter for additional remotes</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../url-parameter-for-container-image/">URL parameter for a container image</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../starting-a-workspace-from-a-raw-devfile-url/">Starting a workspace from a raw devfile URL</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../basic-actions-you-can-perform-on-a-workspace/">Basic actions you can perform on a workspace</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../authenticating-to-a-git-server-from-a-workspace/">Authenticating to a Git server from a workspace</a>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../using-the-fuse-overlay-storage-driver/">Using the fuse-overlayfs storage driver for Podman and Buildah</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../accessing-fuse/">Accessing /dev/fuse</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../enabling-overlay-with-a-configmap/">Enabling fuse-overlayfs with a ConfigMap</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../using-che-in-team-workflow/">Using Che in team workflow</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../first-time-contributors/">Badge for first-time contributors</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../benefits-of-pull-requests-review-in-che/">Reviewing pull and merge requests</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../try-in-web-ide-github-action/">Try in Web IDE GitHub action</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="../customizing-workspace-components/">Customizing workspace components</a>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="../devfile-introduction/">Introduction to devfile in Che</a>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../ides-in-workspaces/">IDEs in workspaces</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../microsoft-visual-studio-code-open-source-ide/">Microsoft Visual Studio Code - Open Source</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../defining-a-common-ide/">Defining a common IDE</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../using-credentials-and-configurations-in-workspaces/">Using credentials and configurations in workspaces</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../mounting-secrets/">Mounting Secrets</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../creating-image-pull-secrets/">Creating image pull Secrets</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../using-a-git-provider-access-token/">Using a Git-provider access token</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../mounting-configmaps/">Mounting ConfigMaps</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../mounting-git-configuration/">Mounting Git configuration</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../enabling-artifact-repositories-in-a-restricted-environment/">Enabling artifact repositories in a restricted environment</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../enabling-maven-artifact-repositories/">Maven</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../enabling-gradle-artifact-repositories/">Gradle</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../enabling-npm-artifact-repositories/">npm</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../enabling-python-artifact-repositories/">Python</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../enabling-go-artifact-repositories/">Go</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../enabling-nuget-artifact-repositories/">NuGet</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="../requesting-persistent-storage-for-workspaces/">Requesting persistent storage for workspaces</a>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../integrating-with-kubernetes/">Integrating with Kubernetes</a>
<ul class="nav-list">
<li class="nav-item is-current-page" data-depth="2">
<a class="nav-link" href="./">Managing workspaces with Kubernetes APIs</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../automatic-token-injection/">Automatic Kubernetes token injection</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../navigating-che-from-openshift-developer-perspective/">Navigating Che from OpenShift Developer Perspective</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../navigating-openshift-web-console-from-che/">Navigating OpenShift web console from Che</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../troubleshooting-che/">Troubleshooting Che</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../viewing-che-workspaces-logs/">Viewing Che workspaces logs</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../viewing-workspace-logs-in-cli/">Workspace logs in CLI</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../viewing-workspace-logs-in-the-openshift-console/">Workspace logs in OpenShift console</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../viewing-language-servers-and-debug-adapters-logs-in-visual-studio-code/">Language servers and debug adapters logs in the editor</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../troubleshooting-slow-workspaces/">Troubleshooting slow workspaces</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../troubleshooting-network-problems/">Troubleshooting network problems</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../troubleshooting-webview-loading-error/">Troubleshooting webview loading error</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item" data-depth="0">
<button class="nav-item-toggle"></button>
<span class="nav-text">Administration Guide</span>
<ul class="nav-list">
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/preparing-the-installation/">Preparing the installation</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/supported-platforms/">Supported platforms</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/installing-the-chectl-management-tool/">Installing the chectl management tool</a>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/architecture-overview/">Architecture</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/server-components/">Server components</a>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/che-operator/">Che operator</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/devworkspace-operator/">DevWorkspace operator</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/gateway/">Gateway</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/dashboard/">User dashboard</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/devfile-registries/">Devfile registries</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/che-server/">Che server</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/plugin-registry/">Plug-in registry</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/user-workspaces/">User workspaces</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/calculating-che-resource-requirements/">Calculating Che resource requirements</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/installing-che/">Installing Che</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/installing-che-in-the-cloud/">Installing Che in the cloud</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-che-on-openshift-using-cli/">Installing Che on OpenShift using CLI</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-che-on-openshift-using-the-web-console/">Installing Che on OpenShift using the web console</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-che-in-a-restricted-environment/">Installing Che in a restricted environment</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-che-on-microsoft-azure/">Installing Che on Microsoft Azure</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/installing-che-locally/">Installing Che locally</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-che-on-red-hat-openshift-local/">Installing Che on Red Hat OpenShift Local</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-che-on-minikube/">Installing Che on Minikube</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-che-on-minikube-keycloak-oidc/">Installing Che on Minikube with Keycloak as the OIDC provider</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/finding-the-fully-qualified-domain-name-fqdn/">Finding the fully qualified domain name (FQDN)</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-che/">Configuring Che</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/understanding-the-checluster-custom-resource/">Understanding the <code>CheCluster</code> Custom Resource</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/using-chectl-to-configure-the-checluster-custom-resource-during-installation/">Using chectl to configure the <code>CheCluster</code> Custom Resource during installation</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/using-the-cli-to-configure-the-checluster-custom-resource/">Using the CLI to configure the CheCluster Custom Resource</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/checluster-custom-resource-fields-reference/"><code>CheCluster</code> Custom Resource fields reference</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-namespace-provisioning/">Configuring namespaces</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-workspace-target-namespace/">Configuring namespace name</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/provisioning-namespaces-in-advance/">Provisioning namespaces in advance</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-server-components/">Configuring server components</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/mounting-a-secret-as-a-file-or-an-environment-variable-into-a-container/">Mounting a Secret or a ConfigMap as a file or an environment variable into a Eclipse&#160;Che container</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/advanced-configuration-options-for-the-che-server-component/">Advanced configuration options for Che server</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-number-of-replicas/">configuring-number-of-replicas.adoc</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-workspaces-globally/">Configuring workspaces globally</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/limiting-the-number-of-workspaces-that-a-user-can-keep/">Limiting the number of workspaces that a user can keep</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/enabling-users-to-run-multiple-workspaces-simultaneously/">Enabling users to run multiple workspaces simultaneously</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/deploying-che-with-support-for-git-repositories-with-self-signed-certificates/">Git with self-signed certificates</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-workspaces-nodeselector/">Configuring workspaces nodeSelector</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-the-open-vsx-registry-url/">Open VSX registry URL</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-a-user-namespace/">Configuring a user namespace</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/caching-images-for-faster-workspace-start/">Caching images for faster workspace start</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/defining-the-list-of-images-to-pull/">Defining the list of images</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/defining-the-memory-parameters-for-the-image-puller/">Defining the memory settings</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-image-puller-on-openshift-using-the-web-console/">Installing Image Puller on OpenShift using the web console</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/installing-image-puller-on-openshift-using-cli/">Installing Image Puller on OpenShift using CLI</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-observability/">Configuring observability</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/the-woopra-telemetry-plugin/">The Woopra telemetry plugin</a>
</li>
<li class="nav-item" data-depth="3">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/creating-a-telemetry-plugin/">Creating a telemetry plugin</a>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/configuring-server-logging/">Configuring server logging</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/collecting-logs-using-chectl/">Collecting logs using chectl</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/monitoring-the-dev-workspace-operator/">Monitoring the DevWorkspace Operator</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/monitoring-che/">Monitoring Che Server</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-networking/">Configuring networking</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-network-policies/">Configuring network policies</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-che-hostname/">Configuring Che hostname</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-che-with-self-signed-certificate/">Configuring Che with self-signed certificates</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/importing-untrusted-tls-certificates/">Importing untrusted TLS certificates to Che</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/adding-labels-and-annotations/">Adding labels and annotations</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-storage/">Configuring storage</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-storage-classes/">Configuring storage classes</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-the-storage-strategy/">Configuring the storage strategy</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-storage-sizes/">Configuring storage sizes</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-dashboard/">Configuring dashboard</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-getting-started-samples/">Configuring getting started samples</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/customizing-openshift-che-consolelink-icon/">Customizing OpenShift Eclipse Che ConsoleLink icon</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/managing-identities-and-authorizations/">Managing identities and authorizations</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/configuring-oauth-for-git-providers/">Configuring OAuth for Git providers</a>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/configuring-oauth-2-for-github/">Configuring OAuth 2.0 for GitHub</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/configuring-oauth-2-for-gitlab/">Configuring OAuth 2.0 for GitLab</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/configuring-oauth-2-for-a-bitbucket-server/">Configuring OAuth 2.0 for a Bitbucket Server</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/configuring-oauth-2-for-the-bitbucket-cloud/">Configuring OAuth 2.0 for the Bitbucket Cloud</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/configuring-oauth-1-for-a-bitbucket-server/">Configuring OAuth 1.0 for a Bitbucket Server</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../../administration-guide/configuring-oauth-2-for-microsoft-azure-devops-services/">Configuring OAuth 2.0 for Microsoft Azure DevOps Services</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-cluster-roles-for-users/">Configuring cluster roles for Che users</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/configuring-advanced-authorization/">Configuring advanced authorization</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../administration-guide/removing-user-data-in-compliance-with-the-gdpr/">Removing user data in compliance with the GDPR</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/configuring-fuse/">Configuring fuse-overlayfs</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/managing-ide-extensions/">Managing IDE extensions</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/extensions-for-microsoft-visual-studio-code-open-source/">Extensions for Microsoft Visual Studio Code - Open Source</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="../../administration-guide/managing-workloads-using-the-che-server-api/">Using the Che server API</a>
</li>
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../administration-guide/upgrading-che/">Upgrading Che</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/upgrading-the-chectl-management-tool/">Upgrading the chectl management tool</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/specifying-the-update-approval-strategy/">Specifying the update approval strategy</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/upgrading-che-using-the-web-console/">Upgrading Che using the OpenShift web console</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/upgrading-che-using-the-cli-management-tool/">Upgrading Che using the CLI management tool</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/upgrading-che-using-the-cli-management-tool-in-restricted-environment/">Upgrading Che in a restricted environment</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../../administration-guide/repairing-the-devworkspace-operator-on-openshift/">Repairing the DevWorkspace Operator on OpenShift</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="1">
<a class="nav-link" href="../../administration-guide/uninstalling-che/">Uninstalling Che</a>
</li>
</ul>
</li>
<li class="nav-item" data-depth="0">
<ul class="nav-list">
<li class="nav-item" data-depth="1">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../extensions/extensions/">Extensions</a>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<a class="nav-link" href="../../extensions/openshift-connector-overview/">OpenShift Connector</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../extensions/features-of-openshift-connector/">Features of OpenShift Connector</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../extensions/installing-openshift-connector-in-che/">Installing OpenShift Connector in Eclipse Che</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../extensions/authenticating-with-openshift-connector-from-che/">Authenticating with OpenShift Connector from Eclipse Che</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../extensions/creating-components-with-openshift-connector-in-che/">Creating Components with OpenShift Connector in Eclipse Che</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../../extensions/connecting-source-code-from-github-to-a-openshift-component-using-openshift-connector/">Connecting source code from GitHub to a OpenShift Component</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item" data-depth="0">
<ul class="nav-list">
<li class="nav-item" data-depth="1">
<a class="nav-link" href="../../glossary/che-glossary/">Che glossary</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<div class="nav-panel-explore" data-panel="explore">
<div class="context">
<span class="title">Documentation</span>
<span class="version">7.82.x</span>
</div>
<ul class="components">
<li class="component is-current">
<div class="title"><a href="../../overview/introduction-to-eclipse-che/">Documentation</a></div>
<ul class="versions">
<li class="version">
<a href="../../../next/overview/introduction-to-eclipse-che/">next</a>
</li>
<li class="version">
<a href="../../../che-7/">old (7.41)</a>
</li>
<li class="version is-current is-latest">
<a href="../../overview/introduction-to-eclipse-che/">7.82.x</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</aside>
</div>
<main class="article">
<div class="toolbar" role="navigation">
<button class="nav-toggle"></button>
<a href="../../overview/introduction-to-eclipse-che/" class="home-link"></a>
<nav class="breadcrumbs" aria-label="breadcrumbs">
<ul>
<li><a href="../../overview/introduction-to-eclipse-che/">Documentation</a></li>
<li>User Guide</li>
<li><a href="../integrating-with-kubernetes/">Integrating with Kubernetes</a></li>
<li><a href="./">Managing workspaces with Kubernetes APIs</a></li>
</ul>
</nav>
<div class="page-versions">
<button class="version-menu-toggle" title="Show other versions of page">7.82.x</button>
<div class="version-menu">
<a class="version" href="../../../next/end-user-guide/managing-workspaces-with-apis/">next</a>
<a class="version is-missing" href="../../../che-7/">old (7.41)</a>
<a class="version is-current" href="./">7.82.x</a>
</div>
</div>
<div class="edit-this-page"><a href="https://github.com/eclipse-che/che-docs/edit/7.82.x/modules/end-user-guide/pages/managing-workspaces-with-apis.adoc">Edit this Page</a></div>
</div>
<div class="content">
<aside class="toc sidebar" data-title="Contents" data-levels="2">
<div class="toc-menu"></div>
</aside>
<article class="doc">
<h1 class="page">Managing workspaces with Kubernetes APIs</h1>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>On your organization&#8217;s Kubernetes cluster, Che workspaces are represented as <code>DevWorkspace</code> custom resources of the same name.
As a result, if there is a workspace named <code>my-workspace</code> in the Che dashboard, there is a corresponding <code>DevWorkspace</code> custom resource named <code>my-workspace</code> in the user&#8217;s namespace on the cluster.</p>
</div>
<div class="paragraph">
<p>Because each <code>DevWorkspace</code> custom resource on the cluster represents a Che workspace, you can manage Che workspaces by using Kubernetes APIs with clients such as the command-line <code>kubectl</code>.</p>
</div>
<div class="paragraph">
<p>Each <code>DevWorkspace</code> custom resource contains details derived from the devfile of the Git repository cloned for the workspace. For example, a devfile might provide devfile commands and workspace container configurations.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="listing-workspaces"><a class="anchor" href="#listing-workspaces"></a>Listing all workspaces</h2>
<div class="sectionbody">
<div class="paragraph">
<p>As a user, you can list your workspaces by using the command line.</p>
</div>
<div class="ulist">
<div class="title">Prerequisites</div>
<ul>
<li>
<p>An active <code>kubectl</code> session with permissions to <code>get</code> the <code>DevWorkspace</code> resources in your namespace on the cluster. See <a href="https://kubernetes.io/docs/reference/kubectl/overview/">Overview of kubectl</a>.</p>
</li>
<li>
<p>You know the relevant Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
You can visit <code>https://<em>&lt;che_fqdn&gt;</em>/api/kubernetes/namespace</code> to get your Che user namespace as <code>name</code>.
</td>
</tr>
</table>
</div>
</li>
<li>
<p>You are in the Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>On OpenShift, you can use the command-line <code>oc</code> tool to <a href="https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/developer-cli-commands.html#oc-project">display your current namespace or switch to a namespace</a>.</p>
</div>
</td>
</tr>
</table>
</div>
</li>
</ul>
</div>
<div class="ulist">
<div class="title">Procedure</div>
<ul>
<li>
<p>To list your workspaces, enter the following on a command line:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">$ kubectl get devworkspaces</code></pre>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 1. Output</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre>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</pre>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>You can view <strong>PHASE</strong> changes live by adding the <code>--watch</code> flag to this command.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Users with administrative permissions on the cluster can list all workspaces from all Che users by including the <code>--all-namespaces</code> flag.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="creating-workspaces"><a class="anchor" href="#creating-workspaces"></a>Creating workspaces</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If your use case does not permit use of the Che dashboard, you can create workspaces with Kubernetes APIs by applying custom resources to the cluster.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Creating workspaces through the Che dashboard provides better user experience and configuration benefits compared to using the command line:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>As a user, you are automatically logged in to the cluster.</p>
</li>
<li>
<p>Kubernetes or OpenShift clients work automatically.</p>
</li>
<li>
<p>Che and its components automatically convert the target Git repository&#8217;s devfile into the <code>DevWorkspace</code> and <code>DevWorkspaceTemplate</code> custom resources on the cluster.</p>
</li>
<li>
<p>Access to the workspace is secured by default with the <code>routingClass: che</code> in the <code>DevWorkspace</code> of the workspace.</p>
</li>
<li>
<p>Recognition of the <code>DevWorkspaceOperatorConfig</code> configuration is managed by Che.</p>
</li>
<li>
<p>Recognition of configurations in <code>spec.devEnvironments</code> specified in the <code>CheCluster</code> custom resource including:</p>
<div class="ulist">
<ul>
<li>
<p>Persistent storage strategy is specified with <code>devEnvironments.storage</code>.</p>
</li>
<li>
<p>Default IDE is specified with <code>devEnvironments.defaultEditor</code>.</p>
</li>
<li>
<p>Default plugins are specified with <code>devEnvironments.defaultPlugins</code>.</p>
</li>
<li>
<p>Container build configuration is specified with <code>devEnvironments.containerBuildConfiguration</code>.</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</td>
</tr>
</table>
</div>
<div class="ulist">
<div class="title">Prerequisites</div>
<ul>
<li>
<p>An active <code>kubectl</code> session with permissions to create <code>DevWorkspace</code> resources in your namespace on the cluster. See <a href="https://kubernetes.io/docs/reference/kubectl/overview/">Overview of kubectl</a>.</p>
</li>
<li>
<p>You know the relevant Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
You can visit <code>https://<em>&lt;che_fqdn&gt;</em>/api/kubernetes/namespace</code> to get your Che user namespace as <code>name</code>.
</td>
</tr>
</table>
</div>
</li>
<li>
<p>You are in the Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>On OpenShift, you can use the command-line <code>oc</code> tool to <a href="https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/developer-cli-commands.html#oc-project">display your current namespace or switch to a namespace</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Che administrators who intend to create workspaces for other users must create the <code>DevWorkspace</code> custom resource in a user namespace that is provisioned by Che or by the administrator. See <a href="../../administration-guide/configuring-namespace-provisioning/" class="xref page">Configuring user namespace provisioning</a>.
</td>
</tr>
</table>
</div>
</li>
</ul>
</div>
<div class="olist arabic">
<div class="title">Procedure</div>
<ol class="arabic">
<li>
<p>To prepare the <code>DevWorkspace</code> custom resource, copy the contents of the target Git repository&#8217;s devfile.</p>
<div class="exampleblock">
<div class="title">Example 2. Copied devfile contents with <code>schemaVersion: 2.2.0</code></div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">components:
- name: tooling-container
container:
image: quay.io/devfile/universal-developer-image:ubi8-latest</code></pre>
</div>
</div>
</div>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
For more details, see the <a href="https://devfile.io/docs/2.2.0/what-is-a-devfile">devfile v2 documentation</a>.
</td>
</tr>
</table>
</div>
</li>
<li>
<p>Create a <code>DevWorkspace</code> custom resource, pasting the devfile contents from the previous step under the <code>spec.template</code> field.</p>
<div class="exampleblock">
<div class="title">Example 3. A <code>DevWorkspace</code> custom resource</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
name: my-devworkspace<i class="conum" data-value="1"></i><b>(1)</b>
namespace: user1-dev<i class="conum" data-value="2"></i><b>(2)</b>
spec:
routingClass: che
started: true<i class="conum" data-value="3"></i><b>(3)</b>
contributions:<i class="conum" data-value="4"></i><b>(4)</b>
- name: ide
uri: https://<em>&lt;che_fqdn&gt;</em>/plugin-registry/v3/plugins/che-incubator/che-code/latest/devfile.yaml
template:
projects:<i class="conum" data-value="5"></i><b>(5)</b>
- name: my-project-name
git:
remotes:
origin: <a href="https://github.com/eclipse-che/che-docs" class="bare">https://github.com/eclipse-che/che-docs</a>
components:<i class="conum" data-value="6"></i><b>(6)</b>
- name: tooling-container
container:
image: quay.io/devfile/universal-developer-image:ubi8-latest</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Name of the <code>DevWorkspace</code> custom resource. This will be the name of the new workspace.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>User namespace, which is the target namespace for the new workspace.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Determines whether the workspace must be started when the <code>DevWorkspace</code> custom resource is created.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>URL reference to the <a href="https://github.com/microsoft/vscode">Microsoft Visual Studio Code - Open Source</a> IDE devfile from the plugin registry.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Details about the Git repository to clone into the workspace when it starts.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>List of components such as workspace containers and volume components.</td>
</tr>
</table>
</div>
</div>
</div>
</li>
<li>
<p>Apply the <code>DevWorkspace</code> custom resource to the cluster.</p>
</li>
</ol>
</div>
<div class="olist arabic">
<div class="title">Verification</div>
<ol class="arabic">
<li>
<p>Verify that the workspace is starting by checking the <strong>PHASE</strong> status of the <code>DevWorkspace</code>.</p>
<div class="listingblock">
<div class="content">
<pre>$ kubectl get devworkspaces -n <em>&lt;user_namespace&gt;</em> --watch</pre>
</div>
</div>
<div class="exampleblock">
<div class="title">Example 4. Output</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre>NAMESPACE NAME DEVWORKSPACE ID PHASE INFO
user1-dev my-devworkspace workspacedf64e4a492cd4701 Starting Waiting for workspace deployment</pre>
</div>
</div>
</div>
</div>
</li>
<li>
<p>When the workspace has successfully started, its <strong>PHASE</strong> status changes to <strong>Running</strong> in the output of the <code>kubectl get devworkspaces</code> command.</p>
<div class="exampleblock">
<div class="title">Example 5. Output</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre>NAMESPACE NAME DEVWORKSPACE ID PHASE INFO
user1-dev my-devworkspace workspacedf64e4a492cd4701 Running https://url-to-workspace.com</pre>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p>You can then open the workspace by using one of these options:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Visit the URL provided in the <strong>INFO</strong> section of the output of the <code>kubectl get devworkspaces</code> command.</p>
</li>
<li>
<p>Open the workspace from the Che dashboard.</p>
</li>
</ul>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="stopping-workspaces"><a class="anchor" href="#stopping-workspaces"></a>Stopping workspaces</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can stop a workspace by setting the <code>spec.started</code> field in the <code>Devworkspace</code> custom resource to <code>false</code>.</p>
</div>
<div class="ulist">
<div class="title">Prerequisites</div>
<ul>
<li>
<p>An active <code>kubectl</code> session on the cluster. See <a href="https://kubernetes.io/docs/reference/kubectl/overview/">Overview of kubectl</a>.</p>
</li>
<li>
<p>You know the workspace name.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>You can find the relevant workspace name in the output of <code>$ kubectl get devworkspaces</code>.</p>
</div>
</td>
</tr>
</table>
</div>
</li>
<li>
<p>You know the relevant Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
You can visit <code>https://<em>&lt;che_fqdn&gt;</em>/api/kubernetes/namespace</code> to get your Che user namespace as <code>name</code>.
</td>
</tr>
</table>
</div>
</li>
<li>
<p>You are in the Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>On OpenShift, you can use the command-line <code>oc</code> tool to <a href="https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/developer-cli-commands.html#oc-project">display your current namespace or switch to a namespace</a>.</p>
</div>
</td>
</tr>
</table>
</div>
</li>
</ul>
</div>
<div class="ulist">
<div class="title">Procedure</div>
<ul>
<li>
<p>Run the following command to stop a workspace:</p>
<div class="listingblock">
<div class="content">
<pre>$ kubectl patch devworkspace <em>&lt;workspace_name&gt;</em> \
-p '{"spec":{"started":false}}' \
--type=merge -n <em>&lt;user_namespace&gt;</em> &amp;&amp; \
kubectl wait --for=jsonpath='{.status.phase}'=Stopped \
dw/<em>&lt;workspace_name&gt;</em> -n <em>&lt;user_namespace&gt;</em></pre>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="starting-stopped-workspaces"><a class="anchor" href="#starting-stopped-workspaces"></a>Starting stopped workspaces</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can start a stopped workspace by setting the <code>spec.started</code> field in the <code>Devworkspace</code> custom resource to <code>true</code>.</p>
</div>
<div class="ulist">
<div class="title">Prerequisites</div>
<ul>
<li>
<p>An active <code>kubectl</code> session on the cluster. See <a href="https://kubernetes.io/docs/reference/kubectl/overview/">Overview of kubectl</a>.</p>
</li>
<li>
<p>You know the workspace name.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>You can find the relevant workspace name in the output of <code>$ kubectl get devworkspaces</code>.</p>
</div>
</td>
</tr>
</table>
</div>
</li>
<li>
<p>You know the relevant Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
You can visit <code>https://<em>&lt;che_fqdn&gt;</em>/api/kubernetes/namespace</code> to get your Che user namespace as <code>name</code>.
</td>
</tr>
</table>
</div>
</li>
<li>
<p>You are in the Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>On OpenShift, you can use the command-line <code>oc</code> tool to <a href="https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/developer-cli-commands.html#oc-project">display your current namespace or switch to a namespace</a>.</p>
</div>
</td>
</tr>
</table>
</div>
</li>
</ul>
</div>
<div class="ulist">
<div class="title">Procedure</div>
<ul>
<li>
<p>Run the following command to start a stopped workspace:</p>
<div class="listingblock">
<div class="content">
<pre>$ kubectl patch devworkspace <em>&lt;workspace_name&gt;</em> \
-p '{"spec":{"started":true}}' \
--type=merge -n <em>&lt;user_namespace&gt;</em> &amp;&amp; \
kubectl wait --for=jsonpath='{.status.phase}'=Running \
dw/<em>&lt;workspace_name&gt;</em> -n <em>&lt;user_namespace&gt;</em></pre>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="removing-workspaces"><a class="anchor" href="#removing-workspaces"></a>Removing workspaces</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can remove a workspace by simply deleting the <code>DevWorkspace</code> custom resource.</p>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Deleting the <code>DevWorkspace</code> custom resource will also delete other workspace resources if they were created by Che: for example, the referenced <code>DevWorkspaceTemplate</code> and per-workspace <code>PersistentVolumeClaims</code>.
</td>
</tr>
</table>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
Remove workspaces by using the Che dashboard whenever possible.
</td>
</tr>
</table>
</div>
<div class="ulist">
<div class="title">Prerequisites</div>
<ul>
<li>
<p>An active <code>kubectl</code> session on the cluster. See <a href="https://kubernetes.io/docs/reference/kubectl/overview/">Overview of kubectl</a>.</p>
</li>
<li>
<p>You know the workspace name.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>You can find the relevant workspace name in the output of <code>$ kubectl get devworkspaces</code>.</p>
</div>
</td>
</tr>
</table>
</div>
</li>
<li>
<p>You know the relevant Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
You can visit <code>https://<em>&lt;che_fqdn&gt;</em>/api/kubernetes/namespace</code> to get your Che user namespace as <code>name</code>.
</td>
</tr>
</table>
</div>
</li>
<li>
<p>You are in the Che user namespace on the cluster.</p>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>On OpenShift, you can use the command-line <code>oc</code> tool to <a href="https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/developer-cli-commands.html#oc-project">display your current namespace or switch to a namespace</a>.</p>
</div>
</td>
</tr>
</table>
</div>
</li>
</ul>
</div>
<div class="ulist">
<div class="title">Procedure</div>
<ul>
<li>
<p>Run the following command to remove a workspace:</p>
<div class="listingblock">
<div class="content">
<pre>$ kubectl delete devworkspace <em>&lt;workspace_name&gt;</em> -n <em>&lt;user_namespace&gt;</em></pre>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</article>
</div>
</main>
</div>
<footer class="footer">
<div>
<a href="https://www.eclipse.org/che/sitemap.xml" target="_blank">Site Map</a> |
<a href="https://www.eclipse.org" target="_blank">Eclipse Foundation</a> |
<a href="https://www.eclipse.org/legal/privacy.php" target="_blank">Privacy Policy</a> |
<a href="https://www.eclipse.org/legal/termsofuse.php" target="_blank">Terms of Use</a> |
<a href="https://www.eclipse.org/legal/epl-2.0/" target="_blank">Eclipse Public License</a> |
<a href="https://www.eclipse.org/legal" target="_blank">Legal Resources</a></div>
</footer>
<script id="site-script" src="../../../../docs/_/js/site.js" data-ui-root-path="../../../../docs/_"></script>
<script async src="../../../../docs/_/js/vendor/highlight.js"></script>
<script src="../../../../docs/_/js/vendor/lunr.js"></script>
<script src="../../../../docs/_/js/search-ui.js" id="search-ui-script" data-site-root-path="../../../.." data-snippet-length="142" data-stylesheet="../../../../docs/_/css/search.css"></script>
<script async src="../../../../search-index.js"></script>
</body>
</html>