mirror of https://github.com/easzlab/kubeasz.git
增加CentOS 7支持
parent
bbb1bbd8d1
commit
2c8d59abcd
|
@ -13,5 +13,6 @@
|
|||
|
||||
# [可选]多master部署时的负载均衡配置
|
||||
- hosts: lb
|
||||
gather_facts: True
|
||||
roles:
|
||||
- lb
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
- hosts: kube-cluster
|
||||
gather_facts: True
|
||||
roles:
|
||||
- docker
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
**二进制方式部署优势:有助于理解系统各组件的交互原理和熟悉组件启动参数,有助于快速排查解决实际问题**
|
||||
|
||||
文档基于`Ubuntu 16.04`,其他系统如`CentOS 7`需要读者自行替换部分命令;由于使用经验有限和简化脚本考虑,已经尽量避免`ansible-playbook`的高级特性和复杂逻辑。
|
||||
文档基于`Ubuntu 16.04/CentOS 7`,其他系统需要读者自行替换部分命令;由于使用经验有限和简化脚本考虑,已经尽量避免`ansible-playbook`的高级特性和复杂逻辑。
|
||||
|
||||
你可能需要掌握基本`kubernetes` `docker` `linux shell` 知识,关于`ansible`建议阅读 [ansible超快入门](http://weiweidefeng.blog.51cto.com/1957995/1895261) 基本够用。
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## 快速指南
|
||||
|
||||
以下为快速体验k8s集群的测试、开发环境--AllinOne部署,觉得比官方的minikube方便、简单很多。
|
||||
以下为基于Ubuntu16.04 快速体验k8s集群的测试、开发环境--AllinOne部署,觉得比官方的minikube方便、简单很多。CentOS7 指南请点[这里](quickStartCentOS7.md)
|
||||
|
||||
### 1.准备一台虚机(推荐内存3G,硬盘20G以上),最小化安装Ubuntu16.04 server,配置基础网络、更新源、SSH登陆等。
|
||||
### 2.安装python2/git/python-pip/ansible
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
## 快速指南
|
||||
|
||||
### 1.准备一台虚机(推荐内存3G,硬盘20G以上),最小化安装最新 CentOS7,配置基础网络、更新源、SSH登陆等。
|
||||
|
||||
+ 关闭selinux: `echo SELINUX=disabled > /etc/selinux/config`
|
||||
|
||||
### 2.安装python2/git/python-pip/ansible
|
||||
``` bash
|
||||
# 文档中脚本默认均以root用户执行
|
||||
# 安装 epel 源并更新
|
||||
yum install epel-release -y
|
||||
yum update
|
||||
# 删除不要的默认安装
|
||||
yum erase firewalld firewalld-filesystem python-firewall -y
|
||||
# 安装依赖工具
|
||||
yum install git python python-pip -y
|
||||
# 安装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
|
||||
# 配置ansible ssh密钥登陆
|
||||
ssh-keygen -t rsa -b 2048 回车 回车 回车
|
||||
ssh-copy-id $IP #$IP为本虚机地址,按照提示输入yes 和root密码
|
||||
```
|
||||
### 3.安装kubernetes集群
|
||||
``` 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.allinone.example hosts
|
||||
然后根据实际情况修改此hosts文件,所有节点都是本虚机IP
|
||||
# 采用一步安装或者分步安装
|
||||
ansible-playbook 90.setup.yml # 一步安装
|
||||
#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
|
||||
```
|
||||
如果执行成功,k8s集群就安装好了。
|
||||
|
||||
### 4.验证安装
|
||||
``` bash
|
||||
# 如果提示kubectl: command not found,退出重新ssh登陆一下,环境变量生效即可
|
||||
kubectl version
|
||||
kubectl get componentstatus # 可以看到scheduler/controller-manager/etcd等组件 Healthy
|
||||
kubectl cluster-info # 可以看到kubernetes master(apiserver)组件 running
|
||||
kubectl get node # 可以看到单 node Ready状态
|
||||
kubectl get pod --all-namespaces # 可以查看所有集群pod状态
|
||||
kubectl get svc --all-namespaces # 可以查看所有集群服务状态
|
||||
calicoctl node status # 可以在master或者node节点上查看calico网络状态
|
||||
```
|
||||
### 5.安装主要组件
|
||||
``` bash
|
||||
# 安装kubedns
|
||||
kubectl create -f manifests/kubedns
|
||||
# 安装heapster
|
||||
kubectl create -f manifests/heapster
|
||||
# 安装dashboard
|
||||
kubectl create -f manifests/dashboard
|
||||
```
|
|
@ -30,12 +30,14 @@
|
|||
shell: systemctl daemon-reload && systemctl enable docker && systemctl restart docker
|
||||
|
||||
## 可选 ------安装docker查询镜像 tag的小工具----
|
||||
- name: apt更新缓存刷新
|
||||
apt: update_cache=yes cache_valid_time=72000
|
||||
- name: 安装轻量JSON处理程序
|
||||
apt: name=jq state=latest
|
||||
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version = "16"
|
||||
tags: docker-tag
|
||||
|
||||
- name: 安装轻量JSON处理程序
|
||||
apt: name=jq state=latest
|
||||
yum: name=jq state=latest
|
||||
when: ansible_distribution == "CentOS" and ansible_distribution_major_version = "7"
|
||||
tags: docker-tag
|
||||
|
||||
- name: 下载 docker-tag
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
|
||||
#
|
||||
- name: apt更新缓存刷新
|
||||
apt: update_cache=yes cache_valid_time=72000
|
||||
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version = "16"
|
||||
|
||||
- name: 安装 haproxy
|
||||
- name: 安装 haproxy using apt
|
||||
apt: name=haproxy state=latest
|
||||
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version = "16"
|
||||
|
||||
- name: 安装 haproxy using yum
|
||||
yum: name=haproxy state=latest
|
||||
when: ansible_distribution == "CentOS" and ansible_distribution_major_version = "7"
|
||||
|
||||
- name: 创建haproxy配置目录
|
||||
file: name=/etc/haproxy state=directory
|
||||
|
@ -11,8 +17,13 @@
|
|||
- name: 配置 haproxy
|
||||
template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg
|
||||
|
||||
- name: 安装 keepalived
|
||||
- name: 安装 keepalived using apt
|
||||
apt: name=keepalived state=latest
|
||||
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version = "16"
|
||||
|
||||
- name: 安装 keepalived using yum
|
||||
yum: name=keepalived state=latest
|
||||
when: ansible_distribution == "CentOS" and ansible_distribution_major_version = "7"
|
||||
|
||||
- name: 创建keepalived配置目录
|
||||
file: name=/etc/keepalived state=directory
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# copy: src=hosts.j2 dest=/etc/hosts
|
||||
|
||||
- name: 写入环境变量$PATH
|
||||
shell: "sed -i '/export PATH/d' /etc/profile && \
|
||||
shell: "sed -i '/export PATH=/d' /etc/profile && \
|
||||
echo export PATH={{ bin_dir }}:$PATH >> /etc/profile"
|
||||
|
||||
- name: 下载证书工具 CFSSL
|
||||
|
|
Loading…
Reference in New Issue