How to write a new custom Node Driver

  1. Can someone point me to the documentation for writing rancher custom node driver? We need this to support the provisioning of VMs in our private cloud. Sifting through the official docs of rancher 2.x landed me with this page. This pretty much delegates it to docker-machine. Going through the documentation of docker-machine, I got hold of the Drivers section in the Contributing Guide (not putting link since new users are only allowed 2 links) which generically explains guidelines on how to get a docker-machine driver accepted by the maintainers of the project. Other than that I couldn’t find any specifics of creating a docker-machine driver.
  2. I came across this PR on github docker/machine#1902 (quite old - 17 Oct 2015. not putting as a link since new users are only allowed 2 links) which seems to give some technical details like which interface to implement and an example driver on github docker/docker-machine-example(not putting as a link since new users are only allowed 2 links) that could be used as a starter code(repo is missing and couldn’t find the code in the main repo as well). Can this be considered the official documentation?
  3. I also came across this issue docker/machine#4537 in the docker-machine GitHub repo which says that the project is in maintenance mode(14th July 2018). Will docker-machine continue to be the standard node driver integration in rancher. Just asking to assess if it would be worth the effort in creating a docker-machine driver that is specific for a private cloud.

We are still maintaining a forked version of it; you can look at any 3rd-party machine driver as an example but you basically just implement the golang interface for the lifecycle of a node. Create the VM, get its IP, configure the SSH key, etc.

Custom UI for Rancher after you have the actual driver working is a separate optimal step (without it you’ll get a generic laid out form of the options).

1 Like

Is this documented somewhere, at least in the forked version of docker-machine?

Adding this info here to avoid additional google searches for users who come across this post:

  1. Driver seems to be the golang interface for the lifecycle of a node that needs to be implemented
  2. ui-driver-skel is the starter repo for implementing a custom UI for your custom node driver. The Usage section of README also includes steps on adding the custom driver binary and UI to rancher.

The documentation for implementing a docker-machine driver seems to available on github, but not on the official documentation website. That is the reason it was difficult to discover.

@livinston I know this is an old post but I’m testing out a custom node driver as well and am running into an issue where I don’t know how to pass an SSH key to my driver. The custom node driver accepts either a path to a SSH key or the fingerprint of a SSH key that is loaded in the SSH agent. I’m able to set either of these parameters in my node template but I don’t know how to get my node driver access to this SSH key. I’m running rancher in a docker container on an Ubuntu VM. I tried placing my SSH key inside the rancher docker container but that didn’t work since rancher creates a jail when running the node driver. I also tried adding the SSH key to the SSH agent in the Ubuntu VM and recreated the rancher docker container with the following arguments: -v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK which allows me to see the SSH key when I run ssh-add -l from inside the rancher docker container but $SSH_AUTH_SOCK is still not accessible to my node driver since it’s in a jail. Any suggestions?

Here’s where I see it creating a jail in the rancher docker container log:

2022/03/19 01:27:45 [INFO] Creating jail for c-9dfx6
2022/03/19 01:27:45 [INFO] Provisioning node k8s-worker-1

Seems Cluster API with machine controller would be a good fit these days?