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

128 lines
4.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## 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 : 真正应用负载的节点,根据需要增加机器配置和节点数
请注意对于多节点集群请确保各节点时区设置一致并使用ntp服务器同步各节点时间。
生产环境使用建议一个节点只是一个角色这里演示环境将节点绑定多个角色。项目预定义了3个例子请修改后完成适合你的集群规划。
+ [单节点](../example/hosts.allinone.example)
+ [单主多节点](../example/hosts.s-master.example)
+ [多主多节点](../example/hosts.m-masters.example)
## 部署步骤
按照[多主多节点](../example/hosts.m-masters.example)示例的节点配置准备4台虚机测试搭建一个多主高可用集群。
### 1.基础系统配置
+ 推荐内存2G/硬盘20G以上
+ 最小化安装`Ubuntu 16.04 server`或者`CentOS 7 Minimal`
+ 配置基础网络、更新源、SSH登陆等
### 2.在每个节点安装依赖工具
Ubuntu 16.04 请执行以下脚本:
``` bash
# 文档中脚本默认均以root用户执行
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
# 安装python2
apt-get install python2.7
# Ubuntu16.04可能需要配置以下软连接
ln -s /usr/bin/python2.7 /usr/bin/python
```
CentOS 7 请执行以下脚本:
``` bash
# 文档中脚本默认均以root用户执行
# 安装 epel 源并更新
yum install epel-release -y
yum update
# 安装python
yum install python -y
```
### 3.在deploy节点安装及准备ansible
``` 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
```
### 4.在deploy节点配置免密码登陆
``` bash
ssh-keygen -t rsa -b 2048 回车 回车 回车
ssh-copy-id $IPs #$IPs为所有节点地址包括自身按照提示输入yes 和root密码
```
### 5.在deploy节点编排k8s安装
``` bash
# 下载项目文件
git clone https://github.com/gjmzj/kubeasz.git
mv kubeasz /etc/ansible
# 下载已打包好的binaries解压到/etc/ansible/bin目录
# 国内请从百度云链接下载 https://pan.baidu.com/s/1c4RFaA
# 如果你有合适网络环境也可以按照/down/download.sh自行从官网下载各种tar包到 ./down目录并执行download.sh
tar zxvf k8s.193.tar.gz
mv bin/* /etc/ansible/bin
cd /etc/ansible
cp example/hosts.m-masters.example hosts
# 根据上文实际规划修改此hosts文件
vi hosts
```
+ 验证ansible安装
在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"
}
```
+ 开始集群安装,如果你对集群安装流程不熟悉,请阅读分步安装讲解后一步一步安装,并对每步都进行验证
``` 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
```
[前一篇](quickStart.md) -- [后一篇](01-创建CA证书和环境配置.md)