筹备服务器

3台Linux主机,2核4G,50G硬盘

内网IP(可相互ssh)hostname
10.206.0.17master
10.206.0.12node1
10.206.0.16node2

初始化装置环境

systemctl stop firewalldsystemctl disable firewalldsed -i 's/enforcing/disabled/' /etc/selinux/config sed -ri 's/.*swap.*/#&/' /etc/fstabcat > /etc/sysctl.d/k8s.conf << EOF net.bridge.bridge-nf-call-ip6tables = 1net.bridge.bridge-nf-call-iptables = 1 EOFsysctl --systemyum install ntpdate -yntpdate time.windows.com

装置依赖

更新yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bakwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repowget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repoyum clean allyum makecacheyum update -y#查看以后yum源yum repolist

装置依赖

yum install -y socatyum install -y conntrack

配置阿里镜像减速

设置仓库地址:https://help.aliyun.com/docum...

cat > /etc/docker/daemon.json << EOF{   "registry-mirrors": ["https://xxx.mirror.aliyuncs.com"] }EOF

增加阿里源

cat > /etc/yum.repos.d/kubernetes.repo << EOF [kubernetes] name=Kubernetesbaseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 epo_gpgcheck=0 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF

多节点装置

拉取KubeKey

export KKZONE=cncurl -sfL https://get-kk.kubesphere.io | VERSION=v1.1.1 sh -chmod +x kk

创立配置文件

./kk create config --with-kubernetes v1.20.4 --with-kubesphere v3.1.1

编辑配置文件

apiVersion: kubekey.kubesphere.io/v1alpha1kind: Clustermetadata:  name: samplespec:  hosts:  - {name: master, address: 10.206.0.17, internalAddress: 10.206.0.17, user: root, password: 123456}  - {name: node1, address: 10.206.0.12, internalAddress: 10.206.0.12, user: root, password: 123456}  - {name: node2, address: 10.206.0.16, internalAddress: 10.206.0.16, user: root, password: 123456}  roleGroups:    etcd:    - master    master:    - master    worker:    - node1    - node2

开始装置

./kk create cluster -f config-sample.yaml

装置实现

参考文档

  1. 多节点装置KubeSphere
  2. CentOS7 yum源批改为阿里,配置阿里epel源