squat / generic-device-plugin

A Kubernetes device plugin to schedule generic Linux devices
Apache License 2.0
210 stars 23 forks source link

Any way to do rolling restarts? #34

Closed GeoffWilliams closed 1 year ago

GeoffWilliams commented 1 year ago

Plugin is working great with USB Zigbee stick on /dev/ttyUSB0 and Home Assistant as a Deployment, thanks! Is there any way I can roll the Deployment without deleting and re-applying? Eg, can I make this work:

kubectl rollout restart -n home-assistant deployment home-assistant

At the moment kubectl describe pod gives:

Warning  FailedScheduling  6m21s (x13 over 66m)  default-scheduler  0/1 nodes are available: 1 Insufficient squat.ai/serial. preemption: 0/1 nodes are available: 1 No preemption victims found for incoming pod..

I'm limiting the Deployment like this:

        resources:
          limits:
            squat.ai/serial: 1

Not fully sure what the number means, I just copy pasted the examples but it works.

squat commented 1 year ago

@GeoffWilliams that depends entirely your application and device!

Is your application and/or device able to tolerate multiple processes potentially accessing/reading/writing to the same device simultaneously? A rolling restart would mean that multiple containers would have the device allocated to it at the same time. This might cause problems with the device or drivers. However, if this is acceptable, then you could change the "count" of the serial device (see fuse device example [0]). This would enable two pods targeting the same device to be running simultaneously.

If simultaneous access of the device is not acceptable, then rolling updates are not acceptable either. This means you'll need to either:

  1. Use the "Recreate" strategy instead; or
  2. Use a statefulset instead of a deployment.

[0] https://github.com/squat/generic-device-plugin/blob/main/manifests/generic-device-plugin.yaml#L52

squat commented 1 year ago

closing for now. please re-open if you think there is a problem with the plugin or if you need more support!