5
5
6
6
Current kubernetes version: 1.32.0
7
7
8
- ## Requirements
8
+ ## TL;DR Quick Start
9
+
10
+ ``` bash
11
+ curl -O https://raw.githubusercontent.com/bashtools/mok/refs/heads/master/package/mok
12
+ chmod +x mok
13
+ sudo mv mok /usr/local/bin/
14
+ mok build image --get-prebuilt-image
15
+ mok create cluster myk8s --masters 1 --publish
16
+ export KUBECONFIG=/var/tmp/admin-myk8s.conf
17
+ kubectl get nodes
18
+ kubectl get pods --all-namespaces
19
+ kubectl run --privileged --rm -ti alpine --image alpine /bin/sh
20
+ mok delete cluster myk8s
21
+ ```
9
22
10
- ** Fedora 41 Desktop/Server on x86_64 or AMD64**
11
- * Podman
12
- * 5 GB of free disk space
23
+ To ensure no resources are used on Mac OS afterwards, run ` mok machine destroy ` .
13
24
14
- ** MacOS 14.7 (Sonoma) on Apple Silicon**
15
- * Podman
16
- * 5 GB of free disk space
25
+ ## Requirements
17
26
18
- Mok may work on other versions of Linux or MacOS but I have only tested it on the above.
27
+ ** MacOS on Apple Silicon (M1, M2, ...)**
28
+ * Mok will will install any required packages using Homebrew, and will prompt you before doing so.
29
+ * To see exactly how and what will be installed, see ` src/macos.sh ` .
30
+
31
+ ** Fedora Desktop or Server**
32
+ * Install Podman.
19
33
20
34
## Install
21
35
22
- Use ` curl ` and download ` mok ` to ` /usr/local/bin ` :
36
+ ### Installation for Linux and Mac
37
+
38
+ Use ` curl ` to download ` mok ` and move it to ` /usr/local/bin ` :
23
39
24
40
``` bash
25
41
curl -O https://raw.githubusercontent.com/bashtools/mok/refs/heads/master/package/mok
26
42
chmod +x mok
27
43
sudo mv mok /usr/local/bin/
28
44
```
29
45
30
- or use ` git ` and ` make ` and install to ` /usr/local/bin ` :
46
+ ## Using Mok
47
+
48
+ ### Add an alias (Linux only)
49
+
50
+ On Linux only, use ` sudo mok ... ` or create an alias so that only ` mok ` is needed:
31
51
32
52
``` bash
33
- git clone https://github.com/bashtools/mok.git
34
- cd mok
35
- sudo make install
53
+ alias mok=" sudo /usr/local/bin/mok"
36
54
```
37
55
38
- ### First use
39
-
40
- For linux users: ` alias mok="sudo /usr/local/bin/mok" `
56
+ Note: Add the alias to your shell startup file (` .bash_profile ` or ` .zshrc ` ) to make it persistent
41
57
42
- Build the latest image:
58
+ ### Build a container image
43
59
44
60
``` bash
45
- mok build image
61
+ mok build image --get-prebuilt-image
46
62
```
47
63
48
- ### Create a multi node kuberenetes cluster
64
+ ### Create a single node kuberenetes cluster
49
65
50
66
``` bash
51
- mok create cluster myk8s --masters 1 --workers 1
67
+ mok create cluster myk8s --masters 1 --publish
52
68
```
53
69
70
+ For Mac users ` --publish ` must be used - but it's optional for Linux users:
71
+
54
72
### Run some kubectl commands
55
73
74
+ Naturally, the [ kubectl command] ( https://kubernetes.io/docs/tasks/tools/ ) is needed for this.
75
+
56
76
``` bash
57
77
export KUBECONFIG=/var/tmp/admin-myk8s.conf
58
78
kubectl get nodes
59
79
kubectl get pods --all-namespaces
60
80
```
61
81
62
82
``` bash
63
- # --privileged is required if you want to `ping`
83
+ # --privileged is required if you want to `ping` a host
64
84
kubectl run --privileged --rm -ti alpine --image alpine /bin/sh
65
85
```
66
86
@@ -69,6 +89,9 @@ kubectl run --privileged --rm -ti alpine --image alpine /bin/sh
69
89
``` bash
70
90
mok -h
71
91
mok create -h
92
+ mok build -h
93
+ mok machine -h
94
+ # ... etc ...
72
95
```
73
96
74
97
### Delete the cluster
@@ -77,61 +100,68 @@ mok create -h
77
100
mok delete cluster myk8s
78
101
```
79
102
80
- ### Uninstall mok completely
103
+ ## To Uninstall mok completely
104
+
105
+ ### Mac
106
+
107
+ ``` bash
108
+ mok machine destroy
109
+ ```
110
+
111
+ If ` mok ` installed Homebrew, then remove homebrew and all its installed packages with:
112
+
113
+ ```
114
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
115
+ ```
116
+
117
+ Then to completely remove any left over directories run:
118
+
119
+ ```
120
+ sudo rm -rf /opt/homebrew
121
+ ```
122
+
123
+ Finally, delete ` mok ` , with:
81
124
82
125
``` bash
83
126
sudo rm /usr/local/bin/mok
127
+ ```
128
+
129
+ ### Linux
84
130
85
- # If you used git and make delete the git repo
131
+ ``` bash
132
+ sudo rm /usr/local/bin/mok
133
+
134
+ # If you used git and make, then delete the git repo
86
135
rm -rf mok/
87
136
```
88
137
89
138
Then delete the podman images that were built by ` mok build ` .
90
139
91
140
## Known Issues
92
141
93
- ** Fedora and MacOS:**
94
142
* With multiple master nodes only the first master is set up
95
143
* Currently only single node clusters can be stopped and restarted
96
-
97
- ** MacOS only:**
98
- * A recent version of Bash is required.
99
- * Use homebrew to install ` bash ` and ` gawk `
100
- * add ` eval "$(/opt/homebrew/bin/brew shellenv) ` to the end of your ` .zprofile ` or ` .bash_profile ` so that
101
- brew installed files are found first.
102
- * To be able to use ` kubectl ` from the host machine and to be able to modify ` nf_conntrack_max ` the machine needs to be created with:
103
- ``` bash
104
- podman machine init --rootful --user-mode-networing
105
- ```
106
- * This allows a kubernetes cluster to be created with the ` --publish ` option, for example:
107
- ``` bash
108
- mok create cluster myk8s 1 0 --publish
109
- ```
110
- Then the commands in the ' Run some kubectl commands' section above will work without any modification.
111
- * ` kube-proxy` requires a correctly set ` nf_conntrack_max` . If it' s incorrect then mok will supply the command to correct it and will also suggest the following commands be run:
112
- ```
113
- # WARNING - This will delete all your existing pods/containers and anything else in the podman machine:
114
- podman machine stop
115
- podman machine rm
116
- podman machine init --now --rootful --user-mode-networing
117
- podman machine ssh modprobe nf_conntrack
118
- podman machine ssh sysctl -w net.netfilter.nf_conntrack_max=163840
119
- ```
144
+ * For Mac, if you installed Homebrew with ` mok ` then you should run
145
+ ` /opt/homebrew/bin/brew doctor ` and follow the instructions shown there if
146
+ you want to use Homebrew outside of Mok, or if you want to run the utilities
147
+ that mok installed (podman for example).
120
148
121
149
## Some Features
122
150
151
+ * Podman Desktop is not required
152
+ * On Mac OS all the required packages are installed for you
153
+ * On Mac OS it uses a non-default podman machine, so won't mess up your existing podman installation
123
154
* Builds kubernetes master and worker nodes in containers
124
155
* Very simple to use without need for YAML files
125
156
* After creating the image a single node cluster builds in under 60 seconds
126
157
* For multi-node clusters the 'create cluster' command returns only when kubernetes is completely ready, with all nodes and pods up and ready.
127
158
* Can skip setting up kubernetes on the master and/or worker node (good for learning!)
128
159
* In this case the set-up scripts are placed in ` /root ` in the containers and can be run by hand
129
160
* Can do kubernetes the hard way (see [ kthwic] ( https://github.com/my-own-kind/kubernetes-the-hard-way-in-containers ) )
130
- * `mok build` and `mok create` can show extensive logs with `--tailf`
161
+ * ` mok build ` and ` mok create ` can show extensive kubernetes logs with ` --tailf `
131
162
132
163
* [ Full Documentation] ( https://github.com/bashtools/mokctl-docs/tree/master/docs )
133
164
134
- ## Support
165
+ ## Support Mok
135
166
136
- Follow:
137
- [Mok on BlueSky](https://bsky.app/profile/github-mok.bsky.social)
167
+ Follow [ Mok on BlueSky] ( https://bsky.app/profile/github-mok.bsky.social ) or give Mok a star.
0 commit comments