Kind 搭建K8S集群

Kind 搭建K8S集群

下载Kind指令

下载链接

创建集群

1
kind create cluster # Default cluster context name is `kind`.

导入镜像

1
kind load docker-image my-custom-image-0 my-custom-image-1

查看kind导入的镜像

1
docker exec -it kind-control-plane crictl images

创建集群支持ingress

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
cat <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
EOF

使用ingress

安装ingress-nginx控制器

由于不可描述的原因,controller下载不下来,这里使用阿里云的源

1
2
3
docker pull registry.aliyuncs.com/kubeadm-ha/ingress-nginx_controller:v1.4.0 
docker tag registry.aliyuncs.com/kubeadm-ha/ingress-nginx_controller:v1.4.0 registry.k8s.io/ingress-nginx/controller:v1.4.0
kind load docker-image registry.k8s.io/ingress-nginx/controller:v1.4.0
1
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml

调整为本地镜像的Yaml:下载deploy.yaml

ingress demo