Using Kind to Play with K8s

如果直接使用 kubernetes 的线上版本进行调试,需要资源太多了。使用 minikube 有时候又无法启动集群。 因此,开发者可以考虑使用 Kind 来部署测试 Kubernetes。

This article is about using Kind to create a Kubernetes (K8s) cluster and debug it.

By default, Kind does not support load balancers. If you want to test your apps, use NodePort or ClusterIP instead.

Source code: svtter/example-code-for-kind.

Using NodePort to View Service

Get the node’s IP to visit:

(base) ➜  cathodic kubectl get nodes -o wide
NAME                 STATUS   ROLES           AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE                         KERNEL-VERSION   CONTAINER-RUNTIME
kind-control-plane   Ready    control-plane   22h   v1.30.0   172.18.0.2    <none>        Debian GNU/Linux 12 (bookworm)   6.1.0-18-amd64   containerd://1.7.15

View the service IP:

(base) ➜  cathodic kubectl get service nginx-service
NAME            TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
nginx-service   NodePort   10.96.65.77   <none>        80:30160/TCP   26m

Now, use curl -L http://172.18.0.2:30160 to visit the Nginx service.

Using LoadBalancer

  • Install cloud-provider-kind via this loadbalancer.
  • Start Kind, unlabel the node, and start cloud-provider-kind according to this link.

也可以看看