istry.aliyuncs.com/google_containersnodes:- role: control-plane- role: control-plane- role: control-plane- role: worker- role: worker- role: worker
这里,我们通过直接在配置文件里使用国内容器镜像源的方式解决了官方容器镜像源不可用的问题,同时也达到了加速集群创建的目的 。
- 创建高可用 Kubernetes 集群
Kubernetes集群搭建 。$ kind create cluster --name my-cluster-ha --config my-cluster-ha.yamlCreating cluster "my-cluster-ha" ... ? Ensuring node image (kindest/node:v1.15.3) ? Preparing nodes ? Starting the external load balancer ?? ? Creating kubeadm config ? Starting control-plane ? ? Joining more control-plane nodes ? Joining worker nodes Cluster creation complete. You can now use the cluster with:export KUBECONFIG="$(kind get kubeconfig-path --name="my-cluster-ha")"kubectl cluster-infomaster $ export KUBECONFIG="$(kind get kubeconfig-path --name="my-cluster-ha")"master $ kubectl cluster-infoKubernetes master is running at https://localhost:44019KubeDNS is running at https://localhost:44019/api/v1/namespaces/kube-system/services/kube-dns:dns/proxyTo further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.同样,我们根据上面命令执行完后,输出的提示信息进行操作来验证一下集群是否部署成功 。$ kubectl get nodesNAME STATUS ROLES AGE VERSIONmy-cluster-ha-control-plane Ready master 3m42s v1.15.3my-cluster-ha-control-plane2 Ready master 3m24s v1.15.3my-cluster-ha-control-plane3 Ready master 2m13s v1.15.3my-cluster-ha-worker Ready <none> 96s v1.15.3my-cluster-ha-worker2 Ready <none> 98s v1.15.3my-cluster-ha-worker3 Ready <none> 95s v1.15.3从上面的输出结果,可以看到包含了多个 master 节点,说明高可用的 Kubernetes集群已经搭建成功 。其它相关知识Kind 的镜像里的秘密
Kind镜像一共分为两类,一类是Base镜像,另一类是Node镜像 。- Base 镜像
ubuntu:19.04作为基础镜像,并做了下面的调整:- 安装
Systemd相关的包,并调整一些配置以适应在容器内运行 。
- 安装
Kubernetes运行时的依赖包,比如:Conntrack、Socat、CNI等 。
- 安装容器运行环境,比如:
Containerd、Crictl等 。
- 配置自己的
ENTRYPOINT脚本,以适应和调整容器内运行的问题 。
- Node 镜像
Node镜像的构建比较复杂,目前是通过运行Base镜像并在Base镜像内执行操作,再保存此容器内容为镜像的方式来构建的,包含的操作有:- 构建
Kubernetes相关资源,比如:二进制文件和镜像 。
- 运行一个用于构建的容器
- 把构建的
Kubernetes相关资源复制到容器里
- 调整部分组件配置参数,以支持在容器内运行
- 预先拉去运行环境需要的镜像
- 通过
docker commit方式保存当前的构建容器为Node镜像
如何快速删除一个集群如果你不需要本地的集群环境,通过以下命令进行删除:
$ kind delete cluster --name my-clusterDeleting cluster "my-cluster" ...$KUBECONFIG is still set to use /root/.kube/kind-config-my-cluster even though that file has been deleted, remember to unset it至此,我们就演示完了如何使用 Kind快速搭建一个Kubernetes集群 。不过有一个你需要注意的地方,Kind搭建的集群不适用于生产环境中使用 。但是如果你想在本地快速构建一个Kubernetes集群环境,并且不想占用太多的硬件资源,那么Kind会是你不错的选择 。
推荐阅读
- 如何查看其他人在你的WiFi上浏览的内容?
- 梦见剖鱼什么意思 梦见别人在剖鱼
- python使用SocketServer实现网络服务器
- 大家都在说的分布式系统到底是什么?
- 支付开发填坑记之支付宝
- 坦洋工夫红茶分布在什么地方 有什么特点
- 男朋友碰腰部是试探吗 男人碰你腰是试探吗
- 男生牵手但是没有说喜欢 男生牵我手但没表白是什么意思
- 水槽安装步骤及注意事项
- 茶与茶叶茶
