mirror of https://github.com/easzlab/kubeasz.git
更新使用文档,可选离线docker镜像下载
parent
ae0f5b242f
commit
94e47f7869
|
@ -83,6 +83,7 @@
|
|||
- "/etc/systemd/system/docker.service"
|
||||
- "/etc/systemd/system/docker.service.requires/"
|
||||
- "/opt/kube/kube-system/"
|
||||
ignore_errors: true
|
||||
|
||||
- name: 清理 iptables
|
||||
shell: "iptables -F && iptables -X \
|
||||
|
|
|
@ -85,58 +85,43 @@ if __name__ == '__main__':
|
|||
sys.exit(__main__._main())
|
||||
```
|
||||
|
||||
### 4.在deploy节点配置免密码登陆
|
||||
- 在deploy节点配置免密码登陆
|
||||
|
||||
``` bash
|
||||
ssh-keygen -t rsa -b 2048 回车 回车 回车
|
||||
ssh-copy-id $IPs #$IPs为所有节点地址包括自身,按照提示输入yes 和root密码
|
||||
```
|
||||
### 5.在deploy节点编排k8s安装
|
||||
### 4.在deploy节点编排k8s安装
|
||||
|
||||
- 4.1 下载项目源码
|
||||
``` bash
|
||||
# 下载项目文件
|
||||
# 方式一:使用git clone
|
||||
git clone https://github.com/gjmzj/kubeasz.git
|
||||
mkdir -p /etc/ansible
|
||||
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
|
||||
# 方式二:从发布页面 https://github.com/gjmzj/kubeasz/releases 下载源码解压到同样目录
|
||||
```
|
||||
- 4.2a 下载二进制文件
|
||||
请从分享的百度云链接下载 https://pan.baidu.com/s/1c4RFaA,解压到/etc/ansible/bin目录,如果你有合适网络环境也可以按照/down/download.sh自行从官网下载各种tar包
|
||||
``` bash
|
||||
tar zxvf k8s.1-9-8.tar.gz # 以安装k8s v1.9.8为例
|
||||
mv bin/* /etc/ansible/bin
|
||||
```
|
||||
- 4.2b [可选]下载离线docker镜像
|
||||
服务器使用内部yum源/apt源,但是无法访问公网情况下,请下载离线docker镜像完成集群安装;从百度云盘把`basic_images_kubeasz_x.y.tar.gz` 下载解压到`/etc/ansible/down` 目录
|
||||
``` bash
|
||||
tar zxvf basic_images_kubeasz_0.2.tar.gz -C /etc/ansible/down
|
||||
```
|
||||
- 4.3 配置集群参数
|
||||
``` bash
|
||||
cd /etc/ansible
|
||||
cp example/hosts.m-masters.example hosts
|
||||
# 根据上文实际规划修改此hosts文件
|
||||
vi hosts
|
||||
```
|
||||
+ 验证ansible安装
|
||||
|
||||
在deploy 节点使用如下命令
|
||||
|
||||
``` bash
|
||||
vim hosts # 根据实际情况修改此hosts文件
|
||||
# 验证ansible安装,正常能看到每个节点返回 SUCCESS
|
||||
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"
|
||||
}
|
||||
```
|
||||
+ 开始集群安装,如果你对集群安装流程不熟悉,请阅读分步安装讲解后一步一步安装,并对每步都进行验证
|
||||
+ [可选]安装集群前对所有节点进行操作系统层面的安全加固 `ansible-playbook roles/os-harden/os-harden.yml`,详情请参考[os-harden项目](https://github.com/dev-sec/ansible-os-hardening)
|
||||
|
||||
- 4.4 开始安装
|
||||
如果你对集群安装流程不熟悉,请阅读项目首页 **安装步骤** 讲解后分步安装,并对 **每步都进行验证**
|
||||
``` bash
|
||||
# 分步安装
|
||||
ansible-playbook 01.prepare.yml
|
||||
|
@ -147,7 +132,10 @@ ansible-playbook 05.kube-node.yml
|
|||
ansible-playbook 06.network.yml
|
||||
ansible-playbook 07.cluster-addon.yml
|
||||
# 一步安装
|
||||
ansible-playbook 90.setup.yml
|
||||
#ansible-playbook 90.setup.yml
|
||||
```
|
||||
|
||||
+ [可选]对集群所有节点进行操作系统层面的安全加固 `ansible-playbook roles/os-harden/os-harden.yml`,详情请参考[os-harden项目](https://github.com/dev-sec/ansible-os-hardening)
|
||||
|
||||
|
||||
[前一篇](quickStart.md) -- [后一篇](01-创建CA证书和环境配置.md)
|
||||
|
|
|
@ -21,3 +21,11 @@ $ sed -i 's/NODE_TO_DEL/192.168.1.1/g' /etc/ansible/tools/clean_one_node.yml
|
|||
```
|
||||
$ ansible-playbook /etc/ansible/tools/clean_one_node.yml
|
||||
```
|
||||
|
||||
## Debug
|
||||
|
||||
如果出现清理失败,类似报错:`... Device or resource busy: '/var/run/docker/netns/xxxxxxxxxx'`,需要手动umount该目录后重新清理
|
||||
``` bash
|
||||
$ umount /var/run/docker/netns/xxxxxxxxxx
|
||||
$ ansible-playbook /etc/ansible/tools/clean_one_node.yml
|
||||
```
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
### 1.基础系统配置
|
||||
|
||||
+ 推荐内存2G/硬盘20G以上
|
||||
+ 推荐内存2G/硬盘30G以上
|
||||
+ 最小化安装`Ubuntu 16.04 server`或者`CentOS 7 Minimal`
|
||||
+ 配置基础网络、更新源、SSH登陆等
|
||||
|
||||
|
@ -14,7 +14,6 @@ Ubuntu 16.04 请执行以下脚本:
|
|||
|
||||
``` bash
|
||||
# 文档中脚本默认均以root用户执行
|
||||
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
|
||||
# 安装依赖工具
|
||||
apt-get install python2.7 git python-pip
|
||||
# Ubuntu16.04可能需要配置以下软连接
|
||||
|
@ -24,9 +23,8 @@ CentOS 7 请执行以下脚本:
|
|||
|
||||
``` bash
|
||||
# 文档中脚本默认均以root用户执行
|
||||
# 安装 epel 源并更新
|
||||
# 安装 epel 源
|
||||
yum install epel-release -y
|
||||
yum update
|
||||
# 安装依赖工具
|
||||
yum install git python python-pip -y
|
||||
```
|
||||
|
@ -65,21 +63,38 @@ if __name__ == '__main__':
|
|||
sys.exit(__main__._main())
|
||||
```
|
||||
|
||||
|
||||
### 4.安装kubernetes集群
|
||||
|
||||
- 4.1 下载项目源码
|
||||
``` bash
|
||||
# 方式一:使用git clone
|
||||
git clone https://github.com/gjmzj/kubeasz.git
|
||||
mkdir -p /etc/ansible
|
||||
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
|
||||
# 方式二:从发布页面 https://github.com/gjmzj/kubeasz/releases 下载源码解压到同样目录
|
||||
```
|
||||
- 4.2a 下载二进制文件
|
||||
请从分享的百度云链接下载 https://pan.baidu.com/s/1c4RFaA,解压到/etc/ansible/bin目录,如果你有合适网络环境也可以按照/down/download.sh自行从官网下载各种tar包
|
||||
``` bash
|
||||
tar zxvf k8s.1-9-8.tar.gz # 以安装k8s v1.9.8为例
|
||||
mv bin/* /etc/ansible/bin
|
||||
# 配置ansible的hosts文件
|
||||
```
|
||||
- 4.2b [可选]下载离线docker镜像
|
||||
服务器使用内部yum源/apt源,但是无法访问公网情况下,请下载离线docker镜像完成集群安装;从百度云盘把`basic_images_kubeasz_x.y.tar.gz` 下载解压到`/etc/ansible/down` 目录
|
||||
``` bash
|
||||
tar zxvf basic_images_kubeasz_0.2.tar.gz -C /etc/ansible/down
|
||||
```
|
||||
- 4.3 配置集群参数
|
||||
``` bash
|
||||
cd /etc/ansible
|
||||
cp example/hosts.allinone.example hosts # 然后根据实际情况修改此hosts文件,所有节点改成本虚机IP
|
||||
# 开始集群安装,如果你对集群安装流程不熟悉,请阅读分步安装讲解后一步一步安装,并对每步都进行验证
|
||||
cp example/hosts.allinone.example hosts
|
||||
vim hosts # 根据实际情况修改此hosts文件,所有节点改成本机IP
|
||||
# 验证ansible安装,正常能看到每个节点返回 SUCCESS
|
||||
ansible all -m ping
|
||||
```
|
||||
- 4.4 开始安装
|
||||
如果你对集群安装流程不熟悉,请阅读项目首页 **安装步骤** 讲解后分步安装,并对 **每步都进行验证**
|
||||
``` bash
|
||||
# 分步安装
|
||||
ansible-playbook 01.prepare.yml
|
||||
ansible-playbook 02.etcd.yml
|
||||
|
@ -91,13 +106,12 @@ ansible-playbook 07.cluster-addon.yml
|
|||
# 一步安装
|
||||
#ansible-playbook 90.setup.yml
|
||||
```
|
||||
如果执行成功,k8s集群就安装好了。详细分步讲解请查看项目目录 `docs` 下相关文档
|
||||
|
||||
+ [可选]对节点进行操作系统层面的安全加固 `ansible-playbook roles/os-harden/os-harden.yml`,详情请参考[os-harden项目](https://github.com/dev-sec/ansible-os-hardening)
|
||||
+ [可选]对集群节点进行操作系统层面的安全加固 `ansible-playbook roles/os-harden/os-harden.yml`,详情请参考[os-harden项目](https://github.com/dev-sec/ansible-os-hardening)
|
||||
|
||||
### 5.验证安装
|
||||
如果提示kubectl: command not found,退出重新ssh登陆一下,环境变量生效即可
|
||||
``` bash
|
||||
# 如果提示kubectl: command not found,退出重新ssh登陆一下,环境变量生效即可
|
||||
kubectl version
|
||||
kubectl get componentstatus # 可以看到scheduler/controller-manager/etcd等组件 Healthy
|
||||
kubectl cluster-info # 可以看到kubernetes master(apiserver)组件 running
|
||||
|
|
Loading…
Reference in New Issue