redhat-developer / vscode-openshift-tools

OpenShift extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=redhat.vscode-openshift-connector
MIT License
94 stars 60 forks source link

Investigate what actions should be taken in order to run dev component without "odo dev" #4541

Open lgrossma opened 3 weeks ago

lgrossma commented 2 weeks ago

The odo dev command basically automates this process:

  1. Create an empty deployment with base image based on the tools needed (nodejs component needs node and npm for example) and leave it running indefinitely.
  2. Create volumes and mount these volumes into the container (optional)
  3. Expose ports where the application should be accessible after starting it and sets up port forwarding so the app can be accessed via localhost
  4. Syncs source code of the application to the created volumes (or directly to the container, if step 2 was omitted)
  5. Execute commands that should result in starting the application (npm install and npm start for example)
  6. Watch for changes in code and repeat steps 4-6

No info from devfile is required

adietish commented 1 week ago

@lgrossma Excellent, detailed explanation. Thanks!

In step 4, where local code is synced to the container (not volumes), it is not evident to me how this is done. Afaik containers are read-only. Without any "special means" one would run a new container with the updated code. If no new container is spun up one would need some special means to copy the updated local classes to the containers. Rsync?

@vrubezhny, @datho7561: do you know more about it?

datho7561 commented 1 week ago

Afaik containers are read-only

It seems you can use kubectl cp to write files to the container.

adietish commented 1 week ago

Afaik containers are read-only

It seems you can use kubectl cp to write files to the container.

@datho7561: oh, indeed. nice pointer, thx!

https://kubernetes.io/docs/reference/kubectl/generated/kubectl_cp/

kubectl cp requires tar to be available in the destination pod. It looks as if kubectl cp is using tar + ssh (?) to copy to the filesystem of the pod: https://github.com/kubernetes/kubectl/blob/a49902335815c339759acdb16444c4115232c518/pkg/cmd/cp/cp.go#L300-L350