发布时间:2023-12-03 09:00
KubeKey是go语言开发的一款云原生容器工具,使用 KubeKe可以轻松、高效、灵活地单独或整体安装 Kubernetes 和 KubeSphere。 本节我们体验一下使用KubeKey一键式部署一个k8s集群。
①准备三台centos服务器,内核版本4.15 or later,服务器配置:2核虚拟CPU,4 GB 内存,30GB存储。
服务器配置 name ip m1 192.168.23.131 m2 192.168.23.132 m3 192.168.23.133 ②安装k8s环境依赖,在每台服务器执行以下命令
命令:yum install -y socat conntrack ebtables ipset
③下载KubeKey工具
//导入环境变量 export KKZONE=cn //下载kubekey curl -sfL https://get-kk.kubesphere.io | sh -
④ 使用KubeKey生成一个k8s集群启动文件模板k8s.yaml
命令:./kk create config --with-kubernetes v1.22.1 -f k8s.yaml
⑤ 修改k8s集群启动文件模板
apiVersion: kubekey.kubesphere.io/v1alpha2 kind: Cluster metadata: name: sample spec: hosts: - {name: node1, address: 192.168.23.131, internalAddress: 192.168.23.131, user: root, password: "root"} - {name: node2, address: 192.168.23.132, internalAddress: 192.168.23.132, user: root, password: "root"} - {name: node3, address: 192.168.23.133, internalAddress: 192.168.23.133, user: root, password: "root"} roleGroups: etcd: - node1 control-plane: - node1 worker: - node2 - node3 controlPlaneEndpoint: ## Internal loadbalancer for apiservers internalLoadbalancer: haproxy domain: lb.kubesphere.local address: "" port: 6443 kubernetes: version: v1.22.1 clusterName: cluster.local network: plugin: calico kubePodsCIDR: 10.233.64.0/18 kubeServiceCIDR: 10.233.0.0/18 ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni multusCNI: enabled: false registry: plainHTTP: false privateRegistry: "" namespaceOverride: "" registryMirrors: [] insecureRegistries: [] addons: []
⑥创建k8s集群
命令:./kk create cluster -f k8s.yaml
⑦验证k8s集群
命令:kubectl get nodes
至此一个k8s集群就安装完成了,是不是超级简单。nice day,下期见。。。