iptables 默认规则删除
~~~
systemctl stop firewalld
systemctl disable firewalld
iptables -F && iptables -X && iptables -F -t nat && iptables -X -t nat
iptables -P FORWARD ACCEPT
~~~
selinux 关闭
~~~
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
~~~
swap 分区禁用,检查/etc/fstab 是否禁用
~~~
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
~~~
无密码ssh连接其他节点
~~~
ssh-keygen
ssh-copy-id root@"masterIP"
ssh-copy-id root@"nodeIP"
ssh-copy-id root@"harborIP"
~~~
hostname重命名
~~~
hostnamectl set-hostname "新主机名"
~~~
重启虚机,生效
~~~
reboot
~~~
进入auto_k8s_2019-04-13目录下,修改requirement.txt文件
~~~
vim requirement.txt
ansible>=2.4.0
jinja2>=2.9.6
netaddr
pbr>=1.6
ansible-modules-hashivault>=3.9.4
hvac
~~~
进入安装目录auto_k8s_2019-04-13/noah_tools/ubuntu_install,执行 RunVsftpd.sh脚本部署ftp 服务、更换安装源、安装依赖包、安装ansible
~~~
bash -x RunVsftpd.sh
~~~
初始化ansible hosts 配置文件
~~~
[harbor]
192.168.0.4
[k8s-master]
192.168.0.2 hostname=master.sinux.com.cn
[k8s-node]
192.168.0.3 hostname=node.sinux.com.cn
~~~
验证 ansible 权限添加是否成功。
~~~
ansible all -m ping
~~~
~~~
192.168.0.2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.0.3 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.0.4 | SUCCESS => {
"changed": false,
"ping": "pong"
}
~~~
修改master和node节点的源,复制成harbor的源并更新,安装python2.7以及依赖包
~~~
cat /etc/apt/sources.list
deb [arch=amd64 trusted=yes] ftp://192.168.0.4/debs/ ./
apt-get update
apt-get -y install python-minimal python-apt python-pip python-dev
~~~
所有机器执行deploy_docker.yml 部署 docker-ce-17.03
~~~
ansible-playbook -e host=all -e user=root deploy_docker.yml
~~~
执行deploy_harbor.yml 部署harbor 镜像仓库服务,安装之前重启harbor宿主机
~~~
ansible-playbook -e host=192.168.0.4 -e user=root deploy_harbor.yml
~~~
> harbor 管理用户: admin/redhat
>注意 检查 harbor 宿主机是否创建/data 磁盘分区
windows 添加hots 解析访问harbor 服务。创建harbor 公开项目:noah-cloud
每台机器上添加hots 解析访问harbor 服务。
~~~
vim /etc/hosts
添加内容:192.168.0.4 harbor.sinux.com.cn
~~~
所有宿主机登录harbor
~~~
ansible all -m shell -a "docker login harbor.sinux.com.cn -uadmin -p 'redhat' "
~~~
进入 /root/auto_k8s_1.0.1/noah_tools/harbor_tools/ 导入kubernetes 基础安装镜像。总共导入29个镜像
~~~
python harbor_load_ubuntu.py
~~~