## 安全策略
- iptables 默認規則刪除
- selinux 關閉
- swap 分區禁用,檢查/etc/fstab 是否禁用
## 基礎環境檢查
- 檢查宿主機新增磁盤ID
- hostname重命名
- ssh 公鑰創建
## 自建yum 倉庫
- install vsftpd
- createrepo
## 基礎服務
- ansible 安裝
- ftp yum 服務
- dns 服務
- docker
- harbor
- harbor noah-cloud 基礎鏡像導入
SSH 公鑰創建
ssh-keygen
復制公鑰到所有宿主機
ssh-copy-id root@192.168.10.100
進入安裝目錄/root/auto_k8s_1.0.1/noah_tools/docker_install/roles,執行 RunVsftpd.sh腳本部署yum 服務及ansible
bash -x RunVsftpd.sh
初始化ansible hosts 配置文件。
vim /etc/ansible/hosts
[harbor]
192.168.10.100
[k8s-master]
192.168.10.120 hostname=k8s-master01.sinux.com.cn
192.168.10.121 hostname=k8s-master02.sinux.com.cn
192.168.10.122 hostname=k8s-master03.sinux.com.cn
[k8s-node]
192.168.10.123 hostname=k8s-node01.sinux.com.cn
驗證 ansible 權限添加是否成功。
ansible all -m ping
192.168.10.100 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.10.120 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.10.121 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.10.123 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.10.122 | SUCCESS => {
"changed": false,
"ping": "pong"
}
返回success 及ansible權限添加成功。
### 基礎服務環境變量初始化: cat vars/init.yml
---
harbor_server: harbor.sinux.com.cn
yum_url: 192.168.10.100
harbor_password: redhat
domain: sinux.com.cn
dns_server: 192.168.10.100
reverse_zone: 10.168.192.in-addr.arpa
reverse_file: 192.168.10.zone
執行deploy_dns.yml 部署 dns server
ansible-playbook -e host=192.168.10.100 -e user=root deploy_dns.yml
修改DNS A 記錄
cat /var/named/chroot/var/named/sinux.com.cn.zone
$TTL 1D
@ IN SOA sinux.com.cn. root.sinux.com.cn. (
2015101401 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns.sinux.com.cn.
ns A 192.168.10.100
harbor A 192.168.10.100
k8s-master01 A 192.168.10.120
k8s-master02 A 192.168.10.121
k8s-master03 A 192.168.10.122
k8s-node01 A 192.168.10.123
修改DNS 反向記錄
cat /var/named/chroot/var/named/192.168.10.zone
$TTL 1D
@ IN SOA sinux.com.cn. root.sinux.com.cn. (
2015101402 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns.sinux.com.cn.
100 IN PTR ns.sinux.com.cn.
100 IN PTR harbor.sinux.com.cn.
120 IN PTR k8s-master01.sinux.com.cn.
121 IN PTR k8s-master02.sinux.com.cn.
122 IN PTR k8s-master03.sinux.com.cn.
123 IN PTR k8s-node01.sinux.com.cn.
124 IN PTR k8s-node02.sinux.com.cn.
重啟DNS 服務,并驗證DNS 記錄是否生效
systemctl restart named-chroot.service
dig harbor.sinux.com.cn
; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7 <<>> harbor.sinux.com.cn
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40436
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;harbor.sinux.com.cn. IN A
;; ANSWER SECTION:
harbor.sinux.com.cn. 86400 IN A 192.168.10.100
;; AUTHORITY SECTION:
sinux.com.cn. 86400 IN NS ns.sinux.com.cn.
;; ADDITIONAL SECTION:
ns.sinux.com.cn. 86400 IN A 192.168.10.100
;; Query time: 0 msec
;; SERVER: 192.168.10.100#53(192.168.10.100)
;; WHEN: Sat Jan 05 02:07:51 EST 2019
;; MSG SIZE rcvd: 97
> 注意修改 所有機器 dns 客戶端配置。/etc/resolv.conf
所有機器執行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.10.100 -e user=root deploy_harbor.yml
> harbor 管理用戶: admin/redhat
>注意 檢查 harbor 宿主機是否創建/data 磁盤分區
windows 添加hots 解析訪問harbor 服務。創建harbor 公開項目:noah-cloud
所有宿主機登錄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個鏡像
> 注意修改腳本harbor服務地址
python harbor_load.py