Skip to content

Commit

Permalink
更新 harbor 安装流程和文档
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Feb 5, 2019
1 parent f28fc48 commit 06ef648
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
18 changes: 12 additions & 6 deletions 11.harbor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] != ''"
9 changes: 4 additions & 5 deletions docs/guide/harbor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 客户端配置

### 安装讲解

Expand Down

0 comments on commit 06ef648

Please sign in to comment.