This section describes how to remotely access Che workspaces outside of the browser.

Che workspaces exist as containers and are, by default, modified from a browser window. In addition to this, there are the following methods of interacting with a Che workspace:

  • Opening a command line in the workspace container using the Kubernetes command-line tool, kubectl

  • Uploading and downloading files using the kubectl tool

Remotely accessing workspaces using the Kubernetes command-line tool

To access Che workspaces remotely using Kubernetes command-line tool (kubectl), follow the instructions in this section.

The kubectl tool is used in this section to open a shell and manage files in a Che workspace. Alternatively, it is possible to use the oc OpenShift command-line tool.
Prerequisites
  • The kubectl binary from the Kubernetes website.

  • Verify the installation of kubectl using the kubectl version command:

    $ kubectl version
    Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:40:16Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"darwin/amd64"}
    Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:32:14Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

    For versions 1.5.0 or higher, proceed with the steps in this section.

Procedure
  1. Use the exec command to open a remote shell.

  2. To find the name of the Kubernetes namespace and pod that runs the Che workspace:

    $ kubectl get pod -l che.workspace_id --all-namespaces
    NAMESPACE   NAME                                               READY   STATUS    RESTARTS   AGE
    che         workspace7b2wemdf3hx7s3ln.maven-74885cf4d5-kf2q4   4/4     Running   0          6m4s

In the example above, the pod name is workspace7b2wemdf3hx7s3ln.maven-74885cf4d5-kf2q4, and the namespace is che.

  1. To find the name of the container:

    $ NAMESPACE=che
    $ POD=workspace7b2wemdf3hx7s3ln.maven-74885cf4d5-kf2q4
    $ kubectl get pod ${POD} -o custom-columns=CONTAINERS:.spec.containers[*].name
    CONTAINERS
    maven,che-machine-execpau,theia-ide6dj,vscode-javaw92
  2. When you have the namespace, pod name, and the name of the container, use the kubectl command to open a remote shell:

    $ NAMESPACE=che
    $ POD=workspace7b2wemdf3hx7s3ln.maven-74885cf4d5-kf2q4
    $ CONTAINER=maven
    $ kubectl exec -ti -n ${NAMESPACE} ${POD} -c ${CONTAINER} bash
    user@workspace7b2wemdf3hx7s3ln $
  3. From the container, execute the build and run commands (as if from the Che workspace terminal):

    user@workspace7b2wemdf3hx7s3ln $ mvn clean install
    [INFO] Scanning for projects...
    (...)
Additional resources

Downloading and uploading a file to a workspace using the command-line interface

This procedure describes how to use the kubectl tool to download or upload files remotely from or to an Eclipse Che workspace.

Prerequisites
Procedure
  • To download a local file named downloadme.txt from a workspace container to the current home directory of the user, use the following in the Che remote shell.

    $ REMOTE_FILE_PATH=/projects/downloadme.txt
    $ NAMESPACE=che
    $ POD=workspace7b2wemdf3hx7s3ln.maven-74885cf4d5-kf2q4
    $ CONTAINER=maven
    $ kubectl cp ${NAMESPACE}/${POD}:${REMOTE_FILE_PATH} ~/downloadme.txt -c ${CONTAINER}
  • To upload a local file named uploadme.txt to a workspace container in the /projects directory:

$ LOCAL_FILE_PATH=./uploadme.txt
$ NAMESPACE=che
$ POD=workspace7b2wemdf3hx7s3ln.maven-74885cf4d5-kf2q4
$ CONTAINER=maven
$ kubectl cp ${LOCAL_FILE_PATH} ${NAMESPACE}/${POD}:/projects -c ${CONTAINER}

Using the preceding steps, the user can also download and upload directories.

Tags: