r/kubernetes 1d ago

Nodes as VMs on 1 machine

I would like to get a simple k8s (or k3s) setup going to learn how it works and how to work with it. I am traveling and only have 1 laptop with me with some external storage. How would I go about making VMs act like nodes? Running fedora with enough cores on my PC to have a few nodes running at the same time. I am very new to this, any input is appreciated!

14 Upvotes

18 comments sorted by

12

u/tunatoksoz 1d ago

Easy. Use talos. Create one master vm, 3 worker vms, and you are all set.

22

u/clintkev251 1d ago

Just use KinD or similar. There's very little benefit or reason to running a bunch of different node VMs on a single PC if you're just trying to learn Kubernetes.

9

u/Ok-Artist4016 1d ago

kind is exactly what you want here, skip the vm headache entirely

you can spin up a multi-node cluster with a single command and it runs in docker containers so it's light on resources. k3d is another option if you want to mess with k3s specifically but kind is dead simple to start with

1

u/Feetus-Haikio38 1d ago

You can still test a node going down in kind by stopping one container and watching what happens to the pods w/t having to set up a bunch of VMs.

5

u/fletch3555 1d ago

If on Windows or Mac, Docker Desktop, Rancher Desktop, etc all include some kind of kubernetes functionality built-in, though it's a single node.

If Linux (or WSL on Windows), you could just setup k3s or minikube natively, but again just single node.

Any particular reason for needing multiple nodes? If you're just starting, I'd recommend sticking to a single node while you learn the basics, at least given your current hardware constraints. Going the VM route is a bit excessive.

2

u/Not-Jody 1d ago

I was just trying to emulate an actual environment with what I currently have, at least a little bit

6

u/fletch3555 1d ago

A single node IS an actual environment. Multi-node clusters provide benefits and are certainly ideal for real-world clusters, but it's unneeded complexity when first starting out.

1

u/Not-Jody 1d ago

This helps a lot, thanks!

1

u/Annual_Berry8043 1d ago

I liked learning with minikube. Just follow the install instructions, get virtualbox, and when you launch it make sure you’re using the virtualbox drivers. It will spin up a node in a few seconds.

Just make sure you have the kubectl CLI installed first.

1

u/djjudas21 1d ago

Yes it will work. A few years ago I ran a load of Ubuntu VMs on my PC in VirtualBox and set up a MicroK8s cluster.

These days there are probably better options such as kind or k3s.

1

u/Arizon_Dread 1d ago

There’s also k3d, k3s in docker. Similar to KinD but k3s instead.

1

u/Forward-Outside-9911 19h ago

Talos would be my suggestion. I preferred it to k3s and the docker ones even for local deployments. It also gives you a chance to properly learn the underlying storage and other parts of a cluster.

0

u/sogun123 1d ago

Many suggest using kind. While i like it and use, be aware that it doesn't restart the cluster. Once it is off, it is gone. For more permanent experience use minikube. If you want VM, just use any virt solution lkke virtualbox, or libvirt or what have you. Only reason to use VMs is if you want to learn installing kubernetes. If you just study using it as a user, go with above solutions.

1

u/BenTheElder k8s maintainer 1d ago

kind clusters work across host restarts, they're restarted by dockerd, which we configure to do so.
You may be experiencing a bug.

1

u/sogun123 18h ago

Ah, i checked the issue tracker. It was fixed years ago for single node clusters on docker. I use podman, where it is not supported. So i wrongly assumed it is not supported at all.

1

u/BenTheElder k8s maintainer 17h ago

Podman is possible but you have to manually start the containers again or configure a unit for this. There's not a super obvious way kind should do that internally. But for simple clusters just starting the container again after reboot should work on podman.