workspaces-issues icon indicating copy to clipboard operation
workspaces-issues copied to clipboard

Add workspace image through bash

Open OscarCy opened this issue 2 years ago • 2 comments

I have a script that generates a custom image. Is there any way to add that custom image to Kasm workspaces through bash instead of going manually to add it? Maybe API or whatsoever?

OscarCy avatar Nov 08 '23 08:11 OscarCy

There is a developer API: https://kasmweb.com/docs/latest/developers/developer_api.html

Creating an Image/Workspace record is not a documented endpoint, but the API keys can be used to auth against most every endpoint the UI uses. So you could inspect the calls to create an image from the UI and script it out.

An alternative you may consider is creating your own Workspace Registry to house the definition of your images. More info here:

  • https://kasmweb.com/docs/latest/guide/workspace_registry.html

j-travis avatar Nov 08 '23 14:11 j-travis

You can create an image via vi api create_image. A curl example :

curl --insecure -H "Content-Type: application/json" -X POST https://jfc.local:10443/api/public/create_image -d '{"api_key" : "gJ7USTHOozuq", "api_key_secret" : "hrMoKW4oVNLlvtB0LlAUVyJPASk mBwmw", "target_image" : {"cores": 4.0, "description": "VPC2", "docker_registry": null, "docker_token": null, "docker_user": n ull, "enabled": true, "friendly_name": "VPC2", "memory": 300000 0000, "name": "vpcmgdix:latest", "persistent_profile_path": "/m nt/kasm-profiles/{username}", "volume_mappings": "{"/home/jfc ": {"bind": "/mnt/kasm-profiles/jfc", "mode": "rw",
"uid": 1000, "gid": 1000, "required": true, "skip_check" : true}, "/var/run/docker.sock": {"bind": "/run/docker.soc k", "mode": "rw", "uid": 0, "gid": 0, "required": tr ue, "skip_check": true}}", "run_config": "{"environment": { "KASM_USER": "kasmmgd-jfc", "OUSR": "jfc", "OIDU": "1000", "OIDG": "1000", "LD_LIB RARY_PATH": "/usr/lib/libreoffice/program:/usr/lib/x86_64-lin ux-gnu:/usr/lib/i386-linux-gnu:/usr/local/nvidia/lib:/usr/local /nvidia/lib64"}, "privileged": true, "hostname": "JFC-dockermgd0"}"}}'

Hope it helps

octave21 avatar Nov 04 '24 17:11 octave21