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.