更新 harbor 安装流程和文档

pull/453/head
gjmzj 2019-02-05 12:32:52 +08:00
parent f28fc48d5e
commit 06ef648653
2 changed files with 16 additions and 11 deletions

View File

@ -19,19 +19,25 @@
- new-master
- kube-node
- new-node
vars:
harbor_domain: "{{ hostvars[groups.harbor[0]]['HARBOR_DOMAIN'] }}"
tasks:
- name: Define 'harbor_host', a domain
set_fact: harbor_host="{{ hostvars[groups.harbor[0]]['HARBOR_DOMAIN'] }}"
- name: Define 'harbor_host', an IP Addr
set_fact: harbor_host="{{ groups['harbor'][0] }}"
when: "hostvars[groups.harbor[0]]['HARBOR_DOMAIN'] == ''"
- name: Creating cert dir of the HARBOR SERVER for the docker daemon
file: name=/etc/docker/certs.d/{{ harbor_domain }} state=directory
file: name=/etc/docker/certs.d/{{ harbor_host }} state=directory
- name: Installing the HARBOR SERVER's cert on k8s nodes
copy: src={{ base_dir }}/down/ca.pem dest=/etc/docker/certs.d/{{ harbor_domain }}/ca.crt
copy: src={{ base_dir }}/down/ca.pem dest=/etc/docker/certs.d/{{ harbor_host }}/ca.crt
# [optional] if you have a DNS server, add an 'A record' instead
- name: Adding an '/etc/hosts' entry for the HARBOR DOMAIN
lineinfile:
dest: /etc/hosts
state: present
regexp: '{{ harbor_domain }}'
line: "{{ groups['harbor'][0] }} {{ harbor_domain }}"
regexp: '{{ harbor_host }}'
line: "{{ groups['harbor'][0] }} {{ harbor_host }}"
when: "hostvars[groups.harbor[0]]['HARBOR_DOMAIN'] != ''"

View File

@ -12,18 +12,17 @@ mv docker-compose-Linux-x86_64 /etc/ansible/bin/docker-compose
```
2. 在deploy节点下载最新的 [harbor](https://github.com/vmware/harbor/releases) 离线安装包,把它放到项目 `/etc/ansible/down` 目录下,也可以从分享的百度云盘下载
3. 由于ansible解压的一些问题需要将官方的tgz包重新打包为zip包
4. 在deploy节点编辑/etc/ansible/hosts文件可以参考 `example`目录下的模板,修改部分举例如下
3. 在deploy节点编辑/etc/ansible/hosts文件可以参考 `example`目录下的模板,修改部分举例如下
``` bash
# 参数 NEW_INSTALL=(yes/no)yes表示新建 harbor并配置k8s节点的docker可以使用harbor仓库
# no 表示仅配置k8s节点的docker使用已有的harbor仓库
# 如果不需要设置域名访问 harbor可以配置参数 HARBOR_DOMAIN=""
[harbor]
#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no
192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=yes
```
5. 在deploy节点执行 `ansible-playbook /etc/ansible/11.harbor.yml`完成harbor安装和docker 客户端配置
4. 在deploy节点执行 `ansible-playbook /etc/ansible/11.harbor.yml`完成harbor安装和docker 客户端配置
### 安装讲解