概述
官方网站:KubeKey (kubesphere.com.cn)
KubeKey(由 Go 语言开发)是一种全新的装置工具,代替了以前应用的基于 ansible 的安装程序。KubeKey 为您提供灵便的装置抉择,您能够仅装置 Kubernetes,也能够同时装置 Kubernetes 和 KubeSphere。
KubeSphere 是 GitHub上的一个开源我的项目,是成千上万名社区用户的聚集地。很多用户都在应用 KubeSphere 运行工作负载。对于在 Linux 上的装置,KubeSphere 既能够部署在云端,也能够部署在本地环境中,例如 AWS EC2、Azure VM 和裸机等。
KubeKey 的几种应用场景:
- 仅装置 Kubernetes;
- 应用一个命令同时装置 Kubernetes 和 KubeSphere;
- 扩缩集群;
- 降级集群;
- 装置 Kubernetes 相干的插件(Chart 或 YAML)。
咱们利用其装置Kubernetes
装置步骤
下载KubeKey
运行以下命令,以确保您从正确的区域下载 KubeKey。
export KKZONE=cn
运行以下命令来下载 KubeKey:
curl -sfL https://get-kk.kubesphere.io | VERSION=v2.2.2 sh -
KubeKey 的最新版本 (v2.2.2),能够更改命令中的版本号来下载特定的版本
筹备Linux 主机
零碎要求
零碎 | 最低要求(每个节点) |
---|---|
Ubuntu 16.04,18.04,20.04, 22.04 | CPU:2 核,内存:4 G,硬盘:40 G |
Debian Buster,Stretch | CPU:2 核,内存:4 G,硬盘:40 G |
CentOS 7.x | CPU:2 核,内存:4 G,硬盘:40 G |
Red Hat Enterprise Linux 7 | CPU:2 核,内存:4 G,硬盘:40 G |
SUSE Linux Enterprise Server 15 /openSUSE Leap 15.2 | CPU:2 核,内存:4 G,硬盘:40 G |
节点要求
- 所有节点必须都能通过 SSH 拜访。
- 所有节点工夫同步。
- 所有节点都应应用 sudo/curl/openssl/tar。
容器运行时
KubeKey 会默认装置最新版本的 Docker。或者,也能够在创立集群前手动装置 Docker 或其余容器运行时。
反对的容器运行时 | 版本 |
---|---|
Docker | 19.3.8+ |
containerd | 最新版 |
CRI-O(试验版,未经充沛测试) | 最新版 |
iSula(试验版,未经充沛测试) | 最新版 |
依赖项要求
KubeKey 能够一起装置 Kubernetes 和 KubeSphere。依据要装置的 Kubernetes 版本,须要装置的依赖项可能会不同。
依赖项 | Kubernetes 版本 ≥ 1.18 | Kubernetes 版本 < 1.18 |
---|---|---|
socat | 必须 | 可选,但倡议装置 |
conntrack | 必须 | 可选,但倡议装置 |
ebtables | 可选,但倡议装置 | 可选,但倡议装置 |
ipset | 可选,但倡议装置 | 可选,但倡议装置 |
网络和 DNS 要求
- 确保 /etc/resolv.conf 中的 DNS 地址可用,否则,可能会导致集群中的 DNS 呈现问题。
- 敞开防火墙规定或平安组。
- 反对的 CNI 插件:Calico 和 Flannel。
KubeKey 所有受反对的 Kubernetes 版本
运行 ./kk version --show-supported-k8s
,查看能应用 KubeKey 装置的所有受反对的 Kubernetes 版本
[email protected]:~# ./kk version --show-supported-k8s。。。v1.21.2v1.21.3v1.21.4v1.21.5v1.21.6v1.21.7v1.21.8v1.21.9v1.21.10v1.21.11v1.21.12v1.21.13v1.22.0v1.22.1v1.22.2v1.22.3v1.22.4v1.22.5v1.22.6v1.22.7v1.22.8v1.22.9v1.22.10v1.23.0v1.23.1v1.23.2v1.23.3v1.23.4v1.23.5v1.23.6v1.23.7v1.23.8v1.24.0v1.24.1
能够看到,还不反对最新的1.25版本。
然而,若需应用 KubeKey 来装置 Kubernetes 和 KubeSphere 3.3.0,请参见下表以查看所有受反对的 Kubernetes 版本。
KubeSphere 版本 | 受反对的 Kubernetes 版本 |
---|---|
v3.3.0 | v1.19.x、v1.20.x、v1.21.x、v1.22.x、v1.23.x(实验性反对) |
创立Cluster配置文件并批改
./kk create config -f config-sample.yaml
[email protected]:/home/zyi#./kk create config -f config-sample.yaml[email protected]:/home/zyi# vim config-sample.yaml apiVersion: kubekey.kubesphere.io/v1alpha2kind: Clustermetadata: name: test-clusterspec: hosts: - {name: cp4, address: 172.16.10.10, internalAddress: 172.16.10.10, password: "cisco123"} - {name: worker41, address: 172.16.10.11, internalAddress: 172.16.10.11, password: "cisco123"} roleGroups: etcd: - cp4 control-plane: - cp4 worker: - cp4 - worker41 controlPlaneEndpoint: ## Internal loadbalancer for apiservers # internalLoadbalancer: haproxy domain: lb.kubesphere.local address: "" port: 6443 kubernetes: version: v1.24.1 clusterName: cluster24.smartx.lab autoRenewCerts: true containerManager: containerd etcd: type: kubekey network: plugin: calico kubePodsCIDR: 10.244.64.0/18 kubeServiceCIDR: 10.244.0.0/18 ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni multusCNI: enabled: false registry: privateRegistry: "" namespaceOverride: "" registryMirrors: [] insecureRegistries: [] addons: []
以上配置应用:
- 两节点cp4/worker41;
- Runtime-Containerd
- Kubernetes 1.24.1
CNI-Calico
运行kk创立集群
./kk create config -f config-sample.yaml
[email protected]:/home/zyi# export KKZONE=cn [email protected]:/home/zyi# ./kk create cluster -f config-sample.yaml _ __ _ _ __ | | / / | | | | / / | |/ / _ _| |__ ___| |/ / ___ _ _ | \| | | | '_ \ / _ \ \ / _ \ | | || |\ \ |_| | |_) | __/ |\ \ __/ |_| |\_| \_/\__,_|_.__/ \___\_| \_/\___|\__, | __/ | |___/12:16:04 UTC [GreetingsModule] Greetings12:16:05 UTC message: [worker41]Greetings, KubeKey!12:16:05 UTC message: [cp4]Greetings, KubeKey!12:16:05 UTC success: [worker41]12:16:05 UTC success: [cp4]12:16:05 UTC [NodePreCheckModule] A pre-check on nodes12:16:05 UTC success: [worker41]12:16:05 UTC success: [cp4]12:16:05 UTC [ConfirmModule] Display confirmation form...Continue this installation? [yes/no]: yes12:16:08 UTC success: [LocalHost]12:16:08 UTC [NodeBinariesModule] Download installation binaries12:16:08 UTC message: [localhost]downloading amd64 kubeadm v1.24.1 ...12:16:08 UTC message: [localhost]kubeadm is existed12:16:08 UTC message: [localhost]downloading amd64 kubelet v1.24.1 ...12:16:09 UTC message: [localhost]kubelet is existed12:16:09 UTC message: [localhost]downloading amd64 kubectl v1.24.1 ...12:16:09 UTC message: [localhost]kubectl is existed12:16:09 UTC message: [localhost]downloading amd64 helm v3.6.3 ......Please check the result using the command: kubectl get pod -A
在Master下面查看集群状况
[email protected]:/home/zyi# kubectl get nodeNAME STATUS ROLES AGE VERSIONcp4 NotReady control-plane,worker 44s v1.24.1worker41 NotReady worker 8s v1.24.1[email protected]:/home/zyi# kubectl get po -ANAMESPACE NAME READY STATUS RESTARTS AGEkube-system calico-kube-controllers-f9f9bbcc9-b2xxx 1/1 Running 0 22skube-system calico-node-mcbpn 1/1 Running 0 22skube-system calico-node-zbm8p 1/1 Running 0 22skube-system coredns-f657fccfd-6tnvr 1/1 Running 0 43skube-system coredns-f657fccfd-rqwsm 1/1 Running 0 43skube-system kube-apiserver-cp4 1/1 Running 0 58skube-system kube-controller-manager-cp4 1/1 Running 0 57skube-system kube-proxy-2q4p9 1/1 Running 0 23skube-system kube-proxy-ml5sx 1/1 Running 0 43skube-system kube-scheduler-cp4 1/1 Running 0 56skube-system nodelocaldns-4srdw 1/1 Running 0 23skube-system nodelocaldns-fd9gx 1/1 Running 0 43s