su rke
cd~
ssh-keygen
[rke@master.ssh]$ssh-copy-id rke@slaver2
[rke@master.ssh]$ssh-copy-id rke@slaver1
[rke@master.ssh]$ssh-copy-id rke@master
为了方便理解,我们把通RKE部署的Kubernetes集群称为“RKE集群”,RKE集群包括Rancher在Windows节点或其他现有自定义节点上启动的集群,以及Rancher在Azure、Digital Ocean、EC2、阿里云或vSphere等上使用新节点启动的集群。
搭建RKE集群有两种方式,一种是yaml文件的声明是搭建,参考https://docs.rancher.cn/docs/rke/example-yamls/_index;另一种是手动生成式搭建,这里我选择手动生成式搭建,是为了更充分的理解每一行标识的意义,学习理解的更透彻。
rke config--name cluster.yml
[+]Cluster Level SSH Private Key Path[~/.ssh/id_rsa]:使用~/.ssh/id_rsa[+]Number of Hosts[1]:集群主机个数[+]SSH Address of host(1)[none]:主机1地址[+]SSH Port of host(1)[22]:SSH端口[+]SSH Private Key Path of host(192.168.241.134)[none]:使用~/.ssh/id_rsa[+]SSH User of host(192.168.241.134)[ubuntu]:SSH用户名,这里使用rancher[+]Is host(192.168.241.134)a Control Plane host(y/n)?[y]:是否运行Control Plane[+]Is host(192.168.241.134)a Worker host(y/n)?[n]:是否是worker[+]Is host(192.168.241.134)an etcd host(y/n)?[n]:是否运行etcd[+]Override Hostname of host(192.168.241.134)[none]:是否重设hostname[+]Internal IP of host(192.168.241.134)[none]:主机内部IP[+]Docker socket path on host(192.168.241.134)[/var/run/docker.sock]:docker sock路径,使用默认[+]SSH Address of host(2)[none]:主机2的配置,后续配置相同,不再赘述......[+]Network Plugin Type(flannel,calico,weave,canal)[canal]:网络插件类型[+]Authentication Strategy[x509]:认证策略[+]Authorization Mode(rbac,none)[rbac]:认证模式[+]Kubernetes Docker image[rancher/hyperkube:v1.15.5-rancher1]:k8s镜像名[+]Cluster domain[cluster.local]:集群域名[+]Service Cluster IP Range[10.43.0.0/16]:集群内服务IP的范围[+]Enable PodSecurityPolicy[n]:pod安全策略[+]Cluster Network CIDR[10.42.0.0/16]:集群网络范围[+]Cluster DNS Service IP[10.43.0.10]:集群DNS的IP[+]Add addon manifest URLs or YAML files[no]:是否增加插件manifest URL或配置文件
rke up--config cluster.yml
Finished building Kubernetes cluster successfully
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.21.8/bin/linux/amd64/kubectlchmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
mkdir -p ~/.local/bin/kubectl
kubectl version --client
yum install bash-completion -y
source /usr/share/bash-completion/bash_completion
source <(kubectl completion bash)
kubectl completion bash >/etc/bash_completion.d/kubectl
kubectl get nodes
因为安装操作流程过长,所以分开几篇文章写,未完待续,嘻嘻,后续内容剧透:
helm和cert-manager的安装事宜,欢迎对RKE安装高可用k8s集群,部署高可用rancher集群感兴趣的同学持续关注作者哟