作者|段超来源|尔达 Erda 公众号
**导读:Erda 作为一站式云原生 PaaS 平台,现已面向广大开发者完成 70w+ 核心代码全部开源!**在 Erda 开源的同时,我们计划编写《基于 K8s 的云原生 PaaS 平台基础架构》系列文章,希望我们的一点经验可以帮助更多企业完善 PaaS 平台基础架构的建设。
系列文章推荐:
Kind (Kubernets in Docker),是一个可以快速在本地部署一套 K8s 的工具,非常适合本地部署调试或者想要体验最新版本 K8s 的场景。
简单创建
brew install kindkind create cluster --name test
Creating cluster "kind" ... ✓ Ensuring node image (kindest/node:v1.13.4) ✓ Preparing nodes ✓ Creating kubeadm config ✓ Starting control-plane ️ Cluster creation complete. You can now use the cluster with:
[root@node-2 ~]# kubectl get nodeNAME STATUS ROLES AGE VERSIONkind-control-plane Ready master 99s v1.13.4
复制代码
默认会创建一个单节点的集群,想要创建更复杂的集群?配置文件走起。
创建一个特定版本 K8s 的集群
配置文件
kind: ClusterapiVersion: kind.x-k8s.io/v1alpha4nodes:- role: control-plane image: kindest/node:v1.18.15@sha256:5c1b980c4d0e0e8e7eb9f36f7df525d079a96169c8a8f20d8bd108c0d0889cc4- role: worker image: kindest/node:v1.18.15@sha256:5c1b980c4d0e0e8e7eb9f36f7df525d079a96169c8a8f20d8bd108c0d0889cc4- role: worker image: kindest/node:v1.18.15@sha256:5c1b980c4d0e0e8e7eb9f36f7df525d079a96169c8a8f20d8bd108c0d0889cc4
复制代码
创建集群
kind create cluster --name kind --config cluster.yaml
复制代码
其他版本的集群,其镜像列表见这里。
创建一个包含 Ingress 的集群
配置文件
kind: ClusterapiVersion: kind.x-k8s.io/v1alpha4nodes:- role: control-plane image: kindest/node:v1.18.15@sha256:5c1b980c4d0e0e8e7eb9f36f7df525d079a96169c8a8f20d8bd108c0d0889cc4 kubeadmConfigPatches: - | kind: InitConfiguration nodeRegistration: kubeletExtraArgs: node-labels: "ingress-ready=true" extraPortMappings: - containerPort: 80 hostPort: 80 protocol: TCP - containerPort: 443 hostPort: 443 protocol: TCP- role: worker image: kindest/node:v1.18.15@sha256:5c1b980c4d0e0e8e7eb9f36f7df525d079a96169c8a8f20d8bd108c0d0889cc4- role: worker image: kindest/node:v1.18.15@sha256:5c1b980c4d0e0e8e7eb9f36f7df525d079a96169c8a8f20d8bd108c0d0889cc4
复制代码
创建集群
kind create cluster --name kind-ingress --config cluster.yaml
复制代码
部署 Ingress
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml
复制代码
安装完后就可以在本地访问 Ingress 了
curl http://127.0.0.1curl -k https://127.0.0.1:443
复制代码
可玩性
kind 采用容器来模拟 node 节点,因此可以到容器里面进行 node 相关的操作,比如修改 kube-apiserver 的配置文件,查看 etcd 等。
如果关于 Erda 你有更多想要了解的内容,欢迎添加小助手微信(Erda202106)进入交流群讨论,或者直接点击下方链接了解更多!
评论