三臺centos8虛擬機 採用nat方式鏈接外網 因此虛擬機固定ip地址
此處不介紹
vmware內部網絡的設置,選擇nat的vmware8網卡後,不勾選dhcp服務linux
虛擬機內部設置文件/etc/sysconfig/network-script/ifcfg-ens##
修改如下值:git
BOOTPROTO=static ONBOOT=yes IPADDR=192.168.*.* NETMASK=255.255.*.* GATEWAY=192.168.*.* DNS1=114.114.114.114
控制檯執行github
nmcli c reload
useradd ###(用戶名) usermod -aG docker ###(用戶名) passwd ### vi /etc/sudoers 找到這一行:"root ALL=(ALL) ALL", 在下面添加"xxx ALL=(ALL) ALL"(這裏的xxx是你的用戶名)
修改/etc/hosts文件,加入如下docker
IP name
yum config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install -y --setopt=obsoletes=0 docker-ce-18.06.1.ce-3.el7 systemctl start docker systemctl enable docker
# 此處修改成中科大倉庫 vi /etc/docker/daemon.json "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
sed -i '/^SELINUX/s/enforcing/disabled/' /etc/selinux/config sed -i 's/.*swap.*/#&/' /etc/fstab
systemctl stop firewalld.service systemctl disable firewalld.service
timedatectl set-timezone Asia/Shanghai
wget https://github.com/rancher/rke/releases/download/v1.1.4/rke_linux-amd64 chmod +x rke_linux_amd64
執行 ./rke_linux_amd64 config [+] Cluster Level SSH Private Key Path [~/.ssh/id_rsa]: [+] Number of Hosts [1]: 主機數量 [+] SSH Address of host (1) [none]: ip地址 [+] SSH Port of host (1) [22]: 端口 [+] SSH Private Key Path of host (ip地址) [none]: [-] You have entered empty SSH key path, trying fetch from SSH key parameter [+] SSH Private Key of host (ip地址) [none]: [-] You have entered empty SSH key, defaulting to cluster level SSH key: ~/.ssh/id_rsa [+] SSH User of host (ip地址) [ubuntu]: 用戶名 [+] Is host (ip地址) a Control Plane host (y/n)? [y]: 控制平面 [+] Is host (ip地址) a Worker host (y/n)? [n]: 工做節點 [+] Is host (ip地址) an etcd host (y/n)? [n]: etcd服務 [+] Override Hostname of host (ip地址) [none]: 重命名節點 [+] Internal IP of host (ip地址) [none]: [+] Docker socket path on host (ip地址) [/var/run/docker.sock]: [+] Network Plugin Type (flannel, calico, weave, canal) [canal]: calico(網絡插件選擇) [+] Authentication Strategy [x509]: [+] Authorization Mode (rbac, none) [rbac]: [+] Kubernetes Docker image [rancher/hyperkube:v1.18.6-rancher1]: [+] Cluster domain [cluster.local]: [+] Service Cluster IP Range [10.43.0.0/16]: [+] Enable PodSecurityPolicy [n]: [+] Cluster Network CIDR [10.42.0.0/16]: [+] Cluster DNS Service IP [10.43.0.10]: [+] Add addon manifest URLs or YAML files [no]:
./rke_linux_amd64 up mv kube_config_cluster.yml .kube/config
cat > /etc/yum.repos.d/kubernetes.repo << END [kubernetes] name = kubernetes baseurl = https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 gpgchek = 1 gpgkey = https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg enable = 1 END yum install kubectl-1.18.6