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
kubectltool
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.
|
-
The
kubectlbinary from the Kubernetes website. -
Verify the installation of
kubectlusing thekubectl versioncommand:$ 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.
-
Use the
execcommand to open a remote shell. -
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.
-
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 -
When you have the namespace, pod name, and the name of the container, use the
kubectlcommand 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 $ -
From the container, execute the
buildandruncommands (as if from the Che workspace terminal):user@workspace7b2wemdf3hx7s3ln $ mvn clean install [INFO] Scanning for projects... (...)
-
For more about
kubectl, see the Kubernetes documentation.
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.
-
A running instance of Eclipse Che. To install an instance of Eclipse Che, see Che 'quick-starts'.
-
Remote access to the Che workspace you intend to modify. For instructions see Remotely accessing workspaces using the Kubernetes command-line tool.
-
The
kubectlbinary from the Kubernetes website. -
Verify the installation of
kubectlusing thekubectl versioncommand:
-
To download a local file named
downloadme.txtfrom 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.txtto a workspace container in the/projectsdirectory:
$ 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.