关于docker:vmware15centos8部署rke高可用集群

42次阅读

共计 2595 个字符,预计需要花费 7 分钟才能阅读完成。

1. 虚拟机筹备

 三台 centos8 虚拟机
采纳 nat 形式连贯外网
所以虚拟机固定 ip 地址 

1.1 nat 形式连贯外网

 此处不介绍 

1.2 虚拟机应用固定 ip 地址

留神点 1:

vmware 外部网络的设置,抉择 nat 的 vmware8 网卡后,不勾选 dhcp 服务

留神点 2:

虚拟机外部设置文件 /etc/sysconfig/network-script/ifcfg-ens##
批改以下值:

BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.*.*
NETMASK=255.255.*.*
GATEWAY=192.168.*.*
DNS1=114.114.114.114

控制台执行

nmcli c reload

1.3 创立普通用户

useradd ###(用户名)
usermod -aG docker ###(用户名)
passwd ###

vi /etc/sudoers
找到这一行:"root ALL=(ALL) ALL",在上面增加 "xxx ALL=(ALL) ALL"(这里的 xxx 是你的用户名)

2. 虚拟机环境筹备

2.1 配置 hosts 文件

批改 /etc/hosts 文件,退出以下

IP name

2.2docker 装置

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

2.3 更换 docker 仓库

# 此处批改为中科大仓库
vi /etc/docker/daemon.json

"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]

2.4 敞开 selinux 和 swap

sed -i '/^SELINUX/s/enforcing/disabled/' /etc/selinux/config
sed -i 's/.*swap.*/#&/' /etc/fstab

2.5 敞开防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

2.6 同步时区

timedatectl set-timezone Asia/Shanghai

3 集群装置

3.1 下载 rke

wget https://github.com/rancher/rke/releases/download/v1.1.4/rke_linux-amd64
chmod +x rke_linux_amd64

3.2 开始配置 cluster.yaml

 执行 ./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]:

3.3 初始化集群至实现

./rke_linux_amd64 up
mv kube_config_cluster.yml .kube/config

3.4 装置 kubectl 工具

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

3.5 装置实现

正文完
 0