Jupyterhub rest api kubespawner_override options

Hello,
Currently, I am starting the server using rest api. I am not finding option to override the kubespawner.
My Post http://localhost:8081/hub/api/users/xyz/servers/ws2
{
“profile”: “react-environment”,

“kubespawner_override”: {
“image”: “jupyterhub/k8s-singleuser-sample:0.8.4”
}

}

Image is not override . Could you please me ?

kubespawner_override is not exposed in the REST API. That would grant users extremely privileged access (full access to create arbitrary kubernetes resources, in many cases).

If you want to expose full kubespawner_overrides to users (make sure you trust users a lot!), you’ll need to subclass KubeSpawner and override load_user_options.

from kubespawner import KubeSpawner
class MyKubeSpawner(KubeSpawner):
    async def load_user_options(self):
        if "kubespawner_override" in self.user_options:
            self._apply_overrides(self.user_options["kubespawner_override"])


c.JupyterHub.spawner_class = MyKubeSpawner

Or, more likely, expose the few options you actually do want to expose, and handle those individually, with validation, bounds, limits, etc. load_user_options is still the method to implement.

1 Like

Thanks a lot. It helped.