MacOS使用kind创建kubernetes集群

安装相关软件

1
2
brew install --cask docker
brew install kind

创建集群

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 默认集群名称为 `kind`.
kind create cluster 

# 自定义集群名称
kind create cluster --name kind-2

# 查看集群
kind get clusters

# 删除集群
kind delete cluster
kind delete cluster --name kind-2
# 切换上下文
kubectl cluster-info --context kind-kind
kubectl cluster-info --context kind-kind-2

导入镜像至kind集群

1
2
3
4
5
6
7
8
9
# kind load docker-image my-custom-image-0 my-custom-image-1
# kind load docker-image my-custom-image-0 my-custom-image-1 --name kind-2
docker pull memcached:1.6.32-alpine3.20
kind load docker-image memcached-controller:v0.0.1 --name kind
kind load docker-image memcached:1.6.32-alpine3.20 --name kind

# 获取kind集群中镜像
# docker exec -it my-node-name crictl images
docker exec -it kind-control-plane crictl images