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
~~~