Skip to content

Commit 6a148fc

Browse files
committed
ipv6 kind on macos
1 parent 4b3e0d8 commit 6a148fc

File tree

1 file changed

+118
-11
lines changed

1 file changed

+118
-11
lines changed

content/posts/kind-macos.md

+118-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
1-
# Running Kubernetes in Docker (kind) on Macos
1+
---
2+
title: Running IPv6 enabled Kubernetes on a MacOS
3+
date: 2025-03-15
4+
tags: ["Kubernetes", "IPv6", "Cilium"]
5+
author: "Kapil Agrawal"
6+
comments: false
7+
---
8+
If you use MacOS as your daily driver and need a functional IPv6 enabled Kubernetes cluster for local development/testing this article is meant for you! I have been using [orbstack](https://orbstack.dev) for a few years now as a drop in replacement for Docker desktop and I have to say it's beyond impressive in terms of performance and features. My main motivation to move away from Docker desktop was the lack of support IPv6 on a MacOS and the horrendous performance. The next thing I tried was Colima which is quite flexible but still [lacks IPv6 support on MacOS](https://news.ycombinator.com/item?id=41422931).
9+
10+
While there are multiple kubernetes distributions such as [minikube](https://github.com/kubernetes/minikube/issues/8535), [k3d](https://github.com/k3d-io/k3d/issues/833) which work quite well on a MacOS, neither of those support IPv6 😭 Eventually I ended up trying [KIND](https://kind.sigs.k8s.io) and turns out, it works perfectly fine with IPv6 and is fully customizable 🎉
11+
12+
If you look under the hood, Kubernetes is an API server which relies on composable set of components to build a distributed system. Kubernetes by itself does not handle networking just as it does not handle managing container lifecycle, it relies on a container runtime such as containerd. Similarly, k8s relies on a container network interface [CNI] (https://cni.dev) which is the component that manages cluster networking and routing network traffic in and out of the cluster. I will write more about CNI's in a separate blog post ;) But to make a Kubernetes cluster IPv6 capable, we need to install a CNI which supports IPv6. Cilium is my CNI of choice as it support IPv6, has a large community around it and is a CNCF graduate project which speaks for it's maturity.
13+
14+
**To get a functional IPv6 capable kubernetes cluster on a MacOS we need the following**
215

3-
I have been using [orbstack](https://orbstack.dev) for over two years now as a drop in replacement for Docker desktop and I have to say it's beyond impressive in terms of performance and feature set. My main motivation to move away from Docker desktop was because it does not support IPv6 on a MacOS. The next thing I tried was Colima but that doesn't support IPv6 either.
16+
- [orbstack](https://orbstack.dev)
17+
- [KIND](https://kind.sigs.k8s.io)
18+
- [Cilium] (https://cilium.io)
419

520
### Orbstack supports IPv6 containers on MacOS
21+
22+
After installing [orbstack](https://orbstack.dev) make sure your docker context is pointing to Orbstack. You may have to explicitly switch the docker context to orbstack if you have Docker desktop installed. In my case, I uninstalled Docker desktop.
23+
624
```bash
725
~
826
❯ docker context ls
927
NAME DESCRIPTION DOCKER ENDPOINT ERROR
1028
default Current DOCKER_HOST based configuration unix:///var/run/docker.sock
1129
desktop-linux unix:///Users/kagraw/.docker/run/docker.sock
1230
orbstack * OrbStack unix:///Users/kagraw/.orbstack/run/docker.sock
31+
```
1332

14-
33+
Enable IPv6 in Docker daemon with the following config.
34+
```sh
1535
❯ cat .orbstack/config/docker.json
1636
{
1737
"ip6tables" : false,
1838
"ipv6" : true
1939
}
2040
```
2141

42+
Create a file named `kind-config.yaml` to pre-configure KIND with the following config options. Notice that I am disabling the default CNI (flannel) so I can install Cilium 😋
43+
2244
#### kind-config.yaml
2345
```YAML
2446
---
@@ -32,23 +54,108 @@ networking:
3254
ipFamily: dual
3355
disableDefaultCNI: true
3456
# IPv6 prefix must be specified first
35-
serviceSubnet: fd00:10:96::/112,10.96.0.0/12
57+
serviceSubnet: fd00:10:96::/112,10.96.0.0/16
3658
nodes:
3759
- role: control-plane
3860
- role: worker
3961
- role: worker
4062
```
4163
42-
#### IPv6 enabled #KIND cluster
64+
### Create KIND cluster
65+
66+
The following snippet assumes that you already have the following already installed on your Mac. If not, you can install them using homebrew.
67+
- `helm`
68+
- `kubectl`
69+
- `cilium-cli`
70+
71+
```bash
72+
# Creates a new cluster with our custom config
73+
❯ kind create cluster --config kind-config.yaml
74+
Creating cluster "kind" ...
75+
✓ Ensuring node image (kindest/node:v1.32.2) 🖼
76+
✓ Preparing nodes 📦 📦 📦
77+
✓ Writing configuration 📜
78+
✓ Starting control-plane 🕹️
79+
✓ Installing StorageClass 💾
80+
✓ Joining worker nodes 🚜
81+
Set kubectl context to "kind-kind"
82+
You can now use your cluster with:
83+
84+
kubectl cluster-info --context kind-kind
85+
86+
Thanks for using kind! 😊
4387
```
44-
# Creates a new cluster
45-
❯ kind create cluster --config ~/.config/kind/kind-config.yaml
4688

47-
# Install Cilium with IPv6 enabled
48-
❯ helm install cilium cilium/cilium --namespace=kube-system --set ipv6.enabled=true
89+
Next we install Cilium CNI with IPv6 enabled
90+
```sh
91+
❯ helm install cilium cilium/cilium --namespace=kube-system --set ipv6.enabled=true --set ipam.mode=kubernetes
4992
```
5093

51-
#### Delete a #KIND cluster
94+
Optionally, we can enable Hubble as well!
95+
```bash
96+
❯ helm upgrade -n kube-system \
97+
cilium cilium/cilium \
98+
--reuse-values --version 1.17.1 \
99+
--set hubble.relay.enabled=true \
100+
--set hubble.ui.enabled=true
52101
```
53-
❯ kind delete cluster --name $(kind get clusters)
102+
103+
The installation takes about 2-3 mins. We can monitor progress using the following
54104
```
105+
❯ cilium status --wait
106+
107+
❯ kubectl get nodes -o wide | awk '{print $1, $2, $3, $5, $6}' | column -t
108+
NAME STATUS ROLES VERSION INTERNAL-IP
109+
kind-control-plane Ready control-plane v1.32.2 fc00:f853:ccd:e793::2
110+
kind-worker Ready worker v1.32.2 fc00:f853:ccd:e793::3
111+
kind-worker2 Ready worker v1.32.2 fc00:f853:ccd:e793::4
112+
```
113+
114+
Now let's try deploying a simple application and verify connectivity over IPv6.
115+
116+
### Deploy an app and verify connectivity over IPv6
117+
```bash
118+
❯ kubectl create deployment --image nginx nginx --port 80
119+
deployment.apps/nginx created
120+
121+
❯ kubectl expose deployment nginx --type NodePort
122+
service/nginx exposed
123+
124+
❯ kubectl get svc
125+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
126+
nginx NodePort fd00:10:96::dbc9 <none> 80:30368/TCP 12s
127+
```
128+
129+
External IP shows as none but that is expected since we created a service of type `NodePort` which is exposed over port `30368`. To access a NodePort service we can send a http GET request to any of the cluster nodes over this port.
130+
131+
```bash
132+
❯ curl -6 http://\[fc00:f853:ccd:e793::3\]:30368
133+
<!DOCTYPE html>
134+
<html>
135+
<head>
136+
<title>Welcome to nginx!</title>
137+
<style>
138+
html { color-scheme: light dark; }
139+
body { width: 35em; margin: 0 auto;
140+
font-family: Tahoma, Verdana, Arial, sans-serif; }
141+
</style>
142+
</head>
143+
<body>
144+
<h1>Welcome to nginx!</h1>
145+
<p>If you see this page, the nginx web server is successfully installed and
146+
working. Further configuration is required.</p>
147+
148+
<p>For online documentation and support please refer to
149+
<a href="http://nginx.org/">nginx.org</a>.<br/>
150+
Commercial support is available at
151+
<a href="http://nginx.com/">nginx.com</a>.</p>
152+
153+
<p><em>Thank you for using nginx.</em></p>
154+
</body>
155+
</html>
156+
```
157+
158+
Voila!🍾 our application is running on Kubernetes and is accessible over IPv6!
159+
160+
### Conclusion
161+
Running an IPv6 capable Kubernetes cluster is absolutely possible on a MacOS and developers can leverage this setup to develop and test their applications in a IPv6 native environment.

0 commit comments

Comments
 (0)