mirror of
https://github.com/games-on-whales/wolf.git
synced 2026-10-15 13:02:03 +00:00
[GH-ISSUE #82] Native Kubernetes Integration #59
Labels
No labels
🧠 1 - 🤖 999
AMD
bug
bug
cannot reproduce
documentation
duplicate
easy
enhancement
enhancement
enhancement
fixed?
fixed?
good first issue
hard
help wanted
Intel
invalid
LXC
medium
moonlight-protocol
Multi GPU
nixos
not a bug
nvidia
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/wolf#59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jacaudi on GitHub (Jun 29, 2024).
Original GitHub issue: https://github.com/games-on-whales/wolf/issues/82
Please consider integrating with the Kubernetes API to deploy Steam, Firefox, etc in additional pods.
@ABeltramo commented on GitHub (Jun 29, 2024):
This is probably out of scope for Wolf, it feels to me that this should be another software that leverage Wolf inside.
Wolf currently allows multiple users to share a single host, it automatically provisions virtual desktops, devices and routes the events from one client to the right Docker container, to simplify:
With k8s you could scale that further so that multiple clients can be mapped to multiple machines:
I hope this makes sense, I don't exclude we could work on this in future once Wolf is probably more mature and stable. Controlling multiple machines is definitely outside the scope of Wolf and will be better positioned in a separate program, but, there's quite a lot of logic and stuff that could be re-used IMHO.
@bo0tzz commented on GitHub (Jun 29, 2024):
I think the main thing about a kubernetes integration would be having Wolf talk to the kubernetes API to create pods, rather than having it use a passed-through docker socket. Would that be feasible at all, in terms of functionality & code structure?
Edit: Looking at docker.hpp, that seems to me like it's not all too far off fitting the Kubernetes API as well. I have no insight into whether all the other parts of wolf could work with Kubernetes though, in terms of passing through devices and communicating between containers and such.
@ABeltramo commented on GitHub (Jun 29, 2024):
Yep that could easily be a different Runner the problem is more about the locality of things
That's exactly my point and why I've included
uinputandGPUin the simple charts above (sorry, I should have been more specific). I'm not an expert on k8s, but, I know that we can't have Wolf running in one pod and an app (Steam, Firefox, ...) on another one because we can't share the local virtual input devices (uinput) and Wayland socket (GPU) between different machines.That's why I think the proper solution would be to decouple the Moonlight protocol from the rest, this way you'll have
Wolf can "only" do the last step, but you need something else that coordinates the multiple Wolf instances.
I hope this clears things up; I'm very open to ideas and feedback
@bo0tzz commented on GitHub (Jun 29, 2024):
Is it 'just' unix sockets that need to be shared, or is there more to it? I think it would be possible to have separate kubernetes Pods for the different bits with a socket shared between them, with the caveat that it's a bit unusual and would only work as long as the Pods are still on the same Node (but that's honestly fine).
Wolf takes a docker socket and spins stuff up on the fly - is that required, or is it possible to have all the containers started ahead of time instead? If so, having one Pod with all of the Wolf bits inside of it would also be a reasonable solution that should work on Kubernetes without (many) changes today.
Something relevant here that isn't yet entirely clear to me - in the existing Docker setup, does a single Wolf instance support multiple clients running different things at the same time, or is it moonlight sending clients to separate Wolf instances? That would influence what the "best practice" way to fit this into Kubernetes is.
@ABeltramo commented on GitHub (Jun 29, 2024):
It's not just sockets, we are talking to and sharing virtual devices under
/dev/input/plus the Wayland socket that can't be shared over the network. Wolf has been developed under the assumption that you are on a single machine, lifting that assumption to manage multiple machines is out of scope for Wolf.It is required because you don't know ahead of time what is going to be the client settings (resolution, FPS, how many and which devices to provision, think of joypads for example) and most importantly how many and which apps do you want to start.
Wolf automatically spins up and down containers on demand, that's the main point. You want to start Steam on your phone and another one in the household starts Retroarch on another device? Wolf will do that, automagically and transparently for the end user.
There's a single Wolf instance that will manage and control multiple containers. You can read more about how it works from a high level POW in the docs here
@bo0tzz commented on GitHub (Jun 29, 2024):
This is absolutely fair. I want to clarify that running in Kubernetes doesn't mean you have to split across multiple machines. You can pin things to one node, and you still get the other benefits of Kubernetes when doing that.
My suggestion for a first pass at this request would be adding a Kubernetes backend that spins up a Pod for each container that's needed, and uses pod affinity to ensure they all land on the same node, then just mounts host paths in the same way that the current Docker setup does. I expect that should Just Work without needing changes in other parts of Wolf (fingers crossed).
@ABeltramo commented on GitHub (Jun 29, 2024):
That doesn't sound too bad, and it'll probably fit well as a different Runner implementation. Sounds like this would give me a nice excuse to finally tip my toes into k8s.. 😅
@bo0tzz commented on GitHub (Jun 29, 2024):
I didn't expect you'd be interested in implementing it yourself, but that would be pretty awesome :D Unfortunately I can't really write the code myself (or I'd already be doing so, lol) but if you need any help around Kube at all don't hesitate to ask!
Thank you for the great discussion btw :)
@ABeltramo commented on GitHub (Jun 29, 2024):
Thank you for sticking around and bring up some good points! There are a few issues that I would like to tackle first, I'm not sure when I'll have time to look into this; I'll keep this open if anyone else wants to give it a shot.
@ABeltramo commented on GitHub (Jul 9, 2024):
So does Kasm and others, how's this relevant to the discussion?
@Relicjamin-jv commented on GitHub (Sep 27, 2024):
I wouldn't mind taking a whack at this, although I'm not too experienced at C++. I'm happy to see official development documentation, I'll go ahead and fork this project and see what I can start cooking. I agree with keeping this objectively to one node, and implementing a new runner.
@Relicjamin-jv commented on GitHub (Sep 27, 2024):
Looking into this a little bit further, there are no really good C++ libraries, however there is a C library that I can wrap. Having this information, would the project maintainers be against introducing another language (Rust?) to implement this feature?
https://slint.dev/blog/rust-and-cpp
@Relicjamin-jv commented on GitHub (Sep 27, 2024):
Never mind, I'll go ahead and write a C++ HTTP client library for CRUD on pods. It will be a fun chance to learn C++.
@ABeltramo commented on GitHub (Sep 27, 2024):
Nothing against Rust, in fact we use it quite extensively for our custom Wayland compositor
gst-wayland-display.My only advice would be that wrapping a C library can be done safely in C++ using smart pointers instead of pulling Rust just for implementing a wrapper. I'd be more than happy to provide more guidance, at least on set things up; feel free to give me a shout on Discord!
Also, if you want to dive into the code I really recommend using devcontainers; all dependencies will be already setup and you should have a working environment automagically in a few minutes (and I should add that to the docs..).
@Relicjamin-jv commented on GitHub (Sep 27, 2024):
I'll take that approach, thanks for being available, I look forward to talking with you! I will definitely use those dev containers.
@judahrand commented on GitHub (Nov 16, 2024):
Does this issues still fall under the
wontfixlabel? I've been playing with deploying GoW on Kubernetes with Sunshine but a lot of the containers are quite out of date and the experience isn't great.wolfbehaving like kind of like a Kubernetes Operator sounds way better.@ABeltramo commented on GitHub (Nov 16, 2024):
I don't use k8s in my homelab, so personally, I don't have much reason to work on this.
As I said before, I'd be more than happy to help anyone from the community that is willing to work on this on any language of choice!
I'll change the label accordingly 😉
@DrummyFloyd commented on GitHub (Jan 7, 2025):
you're right wolf act an operator, seems to be a good direction for me, to look after maybe an k8s-operator sdk
do we have some good dev here ? (i'm not very good , but i can do many stuff )
is there ppl interested to make a K8S stuff with GOLANG based on the wold backend ?
@yitzhakbg commented on GitHub (Jan 8, 2025):
is there ppl interested to make a K8S stuff with GOLANG based on the wold backend ?
Looks promising. I'd be interested (preferably a Rust backend) but I'm not proficient.
My vision is to mass stream of Anki through Wolf in educational settings. What would be the way to go?
P.S. What is wold backend?
@bo0tzz commented on GitHub (Jan 8, 2025):
I think a whole operator probably isn't necessary, though I guess it would work. I think the most straightforward way, like also discussed above, would be essentially to create a Kubernetes version of https://github.com/games-on-whales/wolf/blob/stable/src/moonlight-server/runners/docker.cpp (if I'm understanding the Wolf codebase correctly).
@DrummyFloyd commented on GitHub (Jan 8, 2025):
will try to have a look, even if i a huge 💩 with C++
@yitzhakbg commented on GitHub (Jan 8, 2025):
"will try to have a look, even if i a huge 💩 with C++"
AI coding to our assistance. What does Abeltramo think?
On Wed, Jan 8, 2025 at 2:47 PM DrummyFloyd @.***> wrote:
@anultravioletaurora commented on GitHub (Jan 8, 2025):
I've got a K8s cluster with GPUs that I can do testing on if y'all need guinea pigs!
@ABeltramo commented on GitHub (Jan 8, 2025):
I think it's fairly simple to implement what @bo0tzz suggested above:
This can potentially be done in any language, compiled down to a binary and then being called by Wolf as a
processrunner (ex: [Test ball] ).The main caveat to that is that Wolf wouldn't support multiple nodes as explained in detail in the previous comments.
I'd be happy to help anyone that wants to implement the little runner or a more general purpose, multi-node k8s application that coordinates multiple Wolf instances (and/or single parts of it) on each node. We have some fairly powerful APIs nowadays 😉
@bo0tzz commented on GitHub (Jan 8, 2025):
I hadn't considered that option yet, but I think with that the way to go for a first pass is pretty clearly to just call out to
kubectl. That means no custom binary, not needing to code any direct HTTP interaction with the Kubernetes API, when running inside a Pod it should automatically pick up any mounted credentials, and it'll make development easier as it can just be run from a workstation rather than getting the code being worked on into Kubernetes somehow.That should make for a good first pass that'll get things running, which means people can start using Wolf in Kube and trying stuff out, and then there's plenty of room from that point on to improve things with fancier & more elaborate setups.
As another way to simplify the first pass a bit, rather than the multiple Pods with node affinity that I suggested above, it'll probably be easier to start with just a single Pod with multiple containers for the different pieces, and the sockets mounted via
emptyDirvolumes. That might also play nicer if there are multiple instances running on one node.If it'd be helpful for whoever develops this, I could potentially put together a (dummy) Pod YAML to illustrate the sort of layout I'm thinking of.
@RyuunosukeDS3 commented on GitHub (Feb 28, 2025):
I was able to make wolf run under Kubernetes today, but only wolf. The other containers still seem to be in regular docker. For my specific use case, this will suffice. For now, I made a VERY rudimentary implementation. But I could share if there is anyone interested
@raiomarco commented on GitHub (Feb 28, 2025):
I'm actually really interested
@RyuunosukeDS3 commented on GitHub (Feb 28, 2025):
I will try to share as soon as I can (It COULD take some days tho, sry)
@raiomarco commented on GitHub (Feb 28, 2025):
no problem :)
@RyuunosukeDS3 commented on GitHub (Mar 1, 2025):
OK, I got lucky and got some free time now.
First of all, I ran this command in order to copy my nvidia volume to somewhere easier to mount:
docker run --rm -v nvidia-driver-vol:/volume -it -v $HOME/ubuntu-nvidia-driver:/mnt busybox shcp -R /volume/* /mntSo here the manifests.
deployment.yaml
Here's a sample PV for the nvidia stuff:
Here's the PVC
And finally the service:
In order to make this work, I had to change the default NodePorts. There's probably a more graceful way of doing it. I tried using the loadbalancer, but it didn't work. I didn't spend too much time trying to make it work tho, maybe it's something simple I haven't seen yet, maybe it is something complex. But what I did to change the default ports of my NodePort was adding this flag to the k3s systemctl:
--kube-apiserver-arg=service-node-port-range=47000-49828Like I said it is VERY rudimentary, hacky and testy, but it is something, right? As I try new stuff and evolve it, I might post an update. For now this is the best I could do.
@ABeltramo commented on GitHub (Mar 1, 2025):
Thanks @RyuunosukeDS3 for sharing your setup.
If anyone wants to contribute it would be nice to add this in a separate page in the documentation portal. This doesn't "fix" the original issue (auto-scale on-demand to multiple nodes) but at least it would allow Wolf to run on K8S I guess.
@RyuunosukeDS3 commented on GitHub (Mar 1, 2025):
No prob. For me, specifically, this is nice cause i can have the configs in a gitops manner. And I also use argocd to deploy my apps.
@RyuunosukeDS3 commented on GitHub (Mar 19, 2025):
Jumping in to say that, for my sloppy ahh solution, if you update your nvidia drivers, you need to delete the kubernetes you need take down the manifests and uo then again. Not sure why, didn't really dig further into that but if anyone stumble upon this config and has this problem.
@jtcressy commented on GitHub (Apr 20, 2025):
I wonder if something like kubedock could be used to shim docker.cpp without writing a whole alternative runner backend. would probably be very hacky anyway
@bo0tzz commented on GitHub (Apr 20, 2025):
Some work has been done now on kicking this off. The progress is in https://github.com/games-on-whales/fenrir (very much not ready for use), with discussion happening in Discord at https://discord.com/channels/856434175455133727/1343295057628762252.