Kubernetes
单节点
limactl start template://k8s
export KUBECONFIG=$(limactl list k8s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
kubectl create deployment nginx --image nginx:alpine
kubectl create service nodeport nginx --node-port=31080 --tcp=80:80
修改 templates/k8s.yaml 来更改
kubeadm 配置。
另请参见 https://kubernetes.io/docs/reference/setup-tools/kubeadm/。
limactl start template://k3s
export KUBECONFIG=$(limactl list k3s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
kubectl create deployment nginx --image nginx:alpine
kubectl create service nodeport nginx --node-port=31080 --tcp=80:80
另请参见 https://docs.k3s.io。
limactl start template://k0s
export KUBECONFIG=$(limactl list k0s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
kubectl create deployment nginx --image nginx:alpine
kubectl create service nodeport nginx --node-port=31080 --tcp=80:80
limactl start template://experimental/u7s
export KUBECONFIG=$(limactl list u7s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
kubectl create deployment nginx --image nginx:alpine
# NodePorts 在 Usernetes 中默认不可用
kubectl port-forward deployments/nginx 8080:80
多节点
可以通过创建多个通过 (lima:user-v2 网络连接的虚拟机来创建多节点集群。
limactl create --name k8s-0 --network lima:user-v2
limactl create --name k8s-1 --network lima:user-v2
集群必须手动设置,因为内置模板尚不支持多节点模式。 多节点模板的支持在 https://github.com/lima-vm/lima/issues/4100 中跟踪。