Current kubernetes version: 1.31
Fedora 41 Desktop/Server on x86_64 or AMD64
- Podman
- 5 GB of free disk space
MacOS 14.7 (Sonoma) on Apple Silicon
- Podman
- 5 GB of free disk space
Mok may work on other versions of Linux or MacOS but I have only tested it on the above.
Use curl
and download mok
to /usr/local/bin
:
curl -O https://raw.githubusercontent.com/bashtools/mok/refs/heads/master/package/mok
chmod +x mok
sudo mv mok /usr/local/bin/
or use git
and make
and install to /usr/local/bin
:
git clone https://github.com/bashtools/mok.git
cd mok
sudo make install
For linux users: alias mok="sudo /usr/local/bin/mok"
# Takes around 10 minutes
mok build image
mok create cluster myk8s --masters 1 --workers 1
export KUBECONFIG=/var/tmp/admin-myk8s.conf
kubectl get nodes
kubectl get pods --all-namespaces
# --privileged is required if you want to `ping`
kubectl run --privileged --rm -ti alpine --image alpine /bin/sh
mok -h
mok create -h
mok delete cluster myk8s
sudo rm /usr/local/bin/mok
# If you used git and make delete the git repo
rm -rf mok/
Then delete the podman images that were built by mok build
.
Fedora and MacOS:
- With multiple master nodes only the first master is set up
- Currently only single node clusters can be stopped and restarted
MacOS only:
- A recent version of Bash is required.
- Use homebrew to install
bash
andgawk
- add
eval "$(/opt/homebrew/bin/brew shellenv)
to the end of your.zprofile
or.bash_profile
so that brew installed files are found first.
- Use homebrew to install
- To be able to use
kubectl
from the host machine and to be able to modifynf_conntrack_max
the machine needs to be created with:podman machine init --rootful --user-mode-networing
- This allows a kubernetes cluster to be created with the
--publish
option, for example:Then the commands in the 'Run some kubectl commands' section above will work without any modification.mok create cluster myk8s 1 0 --publish
- This allows a kubernetes cluster to be created with the
kube-proxy
requires a correctly setnf_conntrack_max
. If it's incorrect then mok will supply the command to correct it and will also suggest the following commands be run:# WARNING - This will delete all your existing pods/containers and anything else in the podman machine: podman machine stop podman machine rm podman machine init --now --rootful --user-mode-networing podman machine ssh modprobe nf_conntrack podman machine ssh sysctl -w net.netfilter.nf_conntrack_max=163840
-
Builds kubernetes master and worker nodes in containers
-
Very simple to use without need for YAML files
-
After creating the image a single node cluster builds in under 60 seconds
-
For multi-node clusters the 'create cluster' command returns only when kubernetes is completely ready, with all nodes and pods up and ready.
-
Can skip setting up kubernetes on the master and/or worker node (good for learning!)
- In this case the set-up scripts are placed in
/root
in the containers and can be run by hand - Can do kubernetes the hard way (see kthwic)
- In this case the set-up scripts are placed in
-
mok build
andmok create
can show extensive logs with--tailf