kubeasz/docs/00-集群规划和基础参数设定.md

129 lines
4.1 KiB
Markdown
Raw Normal View History

2017-11-27 20:22:53 +08:00
## 00-集群规划和基础参数设定.md
多节点高可用集群部署步骤与[AllinOne部署](quickStart.md)基本一致增加LB 负载均衡部署步骤。
## 高可用集群所需节点配置如下:
+ 部署节点------x1 : 运行这份 ansible 脚本的节点
+ etcd节点------x3 : 注意etcd集群必须是1,3,5,7...奇数个节点
+ master节点----x2 : 根据实际集群规模可以增加节点数需要额外规划一个master VIP(虚地址)
+ lb节点--------x2 : 负载均衡节点两个,安装 haproxy+keepalived
+ node节点------x3 : 真正应用负载的节点,根据需要增加机器配置和节点数
2018-03-02 15:16:40 +08:00
请注意对于多节点集群请确保各节点时区设置一致并使用ntp服务器同步各节点时间。
生产环境使用建议一个节点只是一个角色这里演示环境将节点绑定多个角色。项目预定义了3个例子请修改后完成适合你的集群规划。
2018-01-05 23:05:22 +08:00
+ [单节点](../example/hosts.allinone.example)
+ [单主多节点](../example/hosts.s-master.example)
+ [多主多节点](../example/hosts.m-masters.example)
## 部署步骤
按照[多主多节点](../example/hosts.m-masters.example)示例的节点配置准备4台虚机测试搭建一个多主高可用集群。
2017-12-18 22:56:59 +08:00
### 1.基础系统配置
+ 推荐内存2G/硬盘20G以上
+ 最小化安装`Ubuntu 16.04 server`或者`CentOS 7 Minimal`
+ 配置基础网络、更新源、SSH登陆等
2017-12-21 19:24:39 +08:00
### 2.在每个节点安装依赖工具
2017-12-18 22:56:59 +08:00
Ubuntu 16.04 请执行以下脚本:
``` bash
# 文档中脚本默认均以root用户执行
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
2017-12-18 22:56:59 +08:00
# 安装python2
apt-get install python2.7
# Ubuntu16.04可能需要配置以下软连接
ln -s /usr/bin/python2.7 /usr/bin/python
```
2017-12-18 22:56:59 +08:00
CentOS 7 请执行以下脚本:
``` bash
2017-12-18 22:56:59 +08:00
# 文档中脚本默认均以root用户执行
# 安装 epel 源并更新
yum install epel-release -y
yum update
# 安装python
yum install python -y
```
2017-12-21 19:24:39 +08:00
### 3.在deploy节点安装及准备ansible
2017-12-18 22:56:59 +08:00
``` bash
# Ubuntu 16.04
apt-get install git python-pip -y
# CentOS 7
yum install git python-pip -y
# pip安装ansible(国内如果安装太慢可以直接用pip阿里云加速)
#pip install pip --upgrade
#pip install ansible
pip install pip --upgrade -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install --no-cache-dir ansible -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
```
2017-12-21 19:24:39 +08:00
### 4.在deploy节点配置免密码登陆
2017-12-18 22:56:59 +08:00
``` bash
ssh-keygen -t rsa -b 2048 回车 回车 回车
2017-12-21 19:24:39 +08:00
ssh-copy-id $IPs #$IPs为所有节点地址包括自身按照提示输入yes 和root密码
```
2017-12-21 16:24:41 +08:00
### 5.在deploy节点编排k8s安装
``` bash
2017-12-21 19:24:39 +08:00
# 下载项目文件
2017-12-21 16:24:41 +08:00
git clone https://github.com/gjmzj/kubeasz.git
2018-03-20 15:52:13 +08:00
mkdir -p /etc/ansible
mv kubeasz/* /etc/ansible
# 下载已打包好的binaries解压到/etc/ansible/bin目录
# 国内请从百度云链接下载 https://pan.baidu.com/s/1c4RFaA
2017-12-21 16:24:41 +08:00
# 如果你有合适网络环境也可以按照/down/download.sh自行从官网下载各种tar包到 ./down目录并执行download.sh
tar zxvf k8s.193.tar.gz
2017-12-21 16:24:41 +08:00
mv bin/* /etc/ansible/bin
cd /etc/ansible
cp example/hosts.m-masters.example hosts
2018-01-05 23:05:22 +08:00
# 根据上文实际规划修改此hosts文件
vi hosts
2017-12-21 16:24:41 +08:00
```
+ 验证ansible安装
2018-01-05 23:05:22 +08:00
在deploy 节点使用如下命令
``` bash
ansible all -m ping
```
如果配置正确可以看到类似输出:
``` text
192.168.1.42 | SUCCESS => {
"changed": false,
"failed": false,
"ping": "pong"
}
192.168.1.43 | SUCCESS => {
"changed": false,
"failed": false,
"ping": "pong"
}
192.168.1.44 | SUCCESS => {
"changed": false,
"failed": false,
"ping": "pong"
}
```
+ 开始集群安装,如果你对集群安装流程不熟悉,请阅读分步安装讲解后一步一步安装,并对每步都进行验证
2017-12-18 22:56:59 +08:00
``` bash
# 分步安装
ansible-playbook 01.prepare.yml
ansible-playbook 02.etcd.yml
ansible-playbook 03.docker.yml
ansible-playbook 04.kube-master.yml
ansible-playbook 05.kube-node.yml
ansible-playbook 06.network.yml
# 一步安装
ansible-playbook 90.setup.yml
```
2017-12-18 22:56:59 +08:00
[前一篇](quickStart.md) -- [后一篇](01-创建CA证书和环境配置.md)