forked from easzlab/kubeasz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
144 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,122 @@ | ||
## 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 : 真正应用负载的节点,根据需要增加机器配置和节点数 | ||
|
||
生产环境使用建议一个节点只是一个角色,避免性能瓶颈问题,这里演示环境将节点绑定多个角色。 | ||
|
||
## 集群所用到的举例参数如下: | ||
``` bash | ||
#集群 MASTER IP, 需要负载均衡,一般为VIP地址 | ||
MASTER_IP="192.168.1.10" | ||
KUBE_APISERVER="https://192.168.1.10:8443" | ||
|
||
#TLS Bootstrapping 使用的 Token,使用 head -c 16 /dev/urandom | od -An -t x | tr -d ' ' 生成 | ||
BOOTSTRAP_TOKEN="c30302226d4b810e08731702d3890f50" | ||
|
||
# 服务网段 (Service CIDR),部署前路由不可达,部署后集群内使用 IP:Port 可达 | ||
SERVICE_CIDR="10.68.0.0/16" | ||
|
||
# POD 网段 (Cluster CIDR),部署前路由不可达,**部署后**路由可达 | ||
CLUSTER_CIDR="172.20.0.0/16" | ||
|
||
# 服务端口范围 (NodePort Range) | ||
NODE_PORT_RANGE="2000-8000" | ||
|
||
# kubernetes 服务 IP (预分配,一般是 SERVICE_CIDR 中第一个IP) | ||
CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" | ||
|
||
# 集群 DNS 服务 IP (从 SERVICE_CIDR 中预分配) | ||
CLUSTER_DNS_SVC_IP="10.68.0.2" | ||
|
||
# 集群 DNS 域名 | ||
CLUSTER_DNS_DOMAIN="cluster.local." | ||
|
||
# etcd 集群间通信的IP和端口, **根据实际 etcd 集群成员设置** | ||
ETCD_NODES="etcd1=https://192.168.1.1:2380,etcd2=https://192.168.1.2:2380,etcd3=https://192.168.1.3:2380" | ||
|
||
# etcd 集群服务地址列表, **根据实际 etcd 集群成员设置** | ||
ETCD_ENDPOINTS="https://192.168.1.1:2379,https://192.168.1.2:2379,https://192.168.1.3:2379" | ||
|
||
# 集群basic auth 使用的用户名和密码【可选】 | ||
BASIC_AUTH_USER="admin" | ||
BASIC_AUTH_PASS="test1234" | ||
|
||
# ---------附加参数-------------------- | ||
#默认二进制文件目录 | ||
bin_dir="/root/local/bin" | ||
|
||
#证书目录 | ||
ca_dir="/etc/kubernetes/ssl" | ||
|
||
#部署目录,即 ansible 工作目录,建议不要修改 | ||
base_dir="/etc/ansible" | ||
|
||
#私有仓库 harbor服务器 (域名或者IP) 【可选】 | ||
#需要把 harbor服务器证书复制到roles/harbor/files/harbor-ca.crt | ||
HARBOR_SERVER="harbor.mydomain.com" | ||
``` | ||
|
||
## 部署步骤 | ||
|
||
### 1.准备4台虚机(推荐内存3G,硬盘20G以上),最小化安装Ubuntu16.04 server,配置基础网络、更新源、SSH登陆等。 | ||
### 2.在每台机器安装基础软件 | ||
``` bash | ||
# 文档中脚本默认均以root用户执行 | ||
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y | ||
# 删除不要的默认安装 | ||
apt-get purge ufw lxd lxd-client lxcfs lxc-common | ||
# 安装依赖工具 | ||
apt-get install python2.7 | ||
# Ubuntu16.04可能需要配置以下软连接 | ||
ln -s /usr/bin/python2.7 /usr/bin/python | ||
``` | ||
### 3.在deploy节点安装ansible | ||
``` bash | ||
# 安装依赖工具 | ||
apt-get install python2.7 git python-pip | ||
# Ubuntu16.04可能需要配置以下软连接 | ||
ln -s /usr/bin/python2.7 /usr/bin/python | ||
# 安装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/1eSetFSA | ||
# 如果你有合适网络环境也可以按照/down/download.sh自行从官网下载各种tar包到 ./down目录,并执行download.sh | ||
tar zxvf k8s.184.tar.gz | ||
mv bin/* /etc/ansible/bin | ||
# 配置ansible的hosts文件 | ||
cd /etc/ansible | ||
cp example/hosts.m-masters.example hosts | ||
然后根据上文实际规划修改此hosts文件 | ||
# 采用分步安装(确定每一步是否安装成功)或者一步安装 | ||
# 后文将一步一步讲解安装过程 | ||
ansible-playbook 01.prepare.yml | ||
ansible-playbook 02.etcd.yml | ||
ansible-playbook 03.kubectl.yml | ||
ansible-playbook 04.docker.yml | ||
ansible-playbook 05.calico.yml | ||
ansible-playbook 06.kube-master.yml | ||
ansible-playbook 07.kube-node.yml | ||
#ansible-playbook 90.setup.yml # 一步安装 | ||
``` | ||
如果执行成功,k8s集群就安装好了。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters