Skip to content

Commit

Permalink
更新harbor脚本和文档
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgao1983 committed May 31, 2018
1 parent 1c5ef62 commit f3b788a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions docs/guide/harbor.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type: kubernetes.io/dockerconfigjson
+ 日志目录 `/var/log/harbor`
+ 数据目录 `/data` ,其中最主要是 `/data/database``/data/registry` 目录,如果你要彻底重新安装harbor,删除这两个目录即可

先进入harbor安装目录 `cd /root/local/harbor`,常规操作如下:
先进入harbor安装目录 `cd /opt/harbor`,常规操作如下:

1. 暂停harbor `docker-compose stop` : docker容器stop,并不删除容器
2. 恢复harbor `docker-compose start` : 恢复docker容器运行
Expand All @@ -151,15 +151,15 @@ type: kubernetes.io/dockerconfigjson

``` bash
# 进入harbor解压缩后的目录,停止harbor
cd /root/local/harbor
cd /opt/harbor
docker-compose down

# 备份这个目录
cd ..
mkdir -p /backup && mv harbor /backup/harbor

# 下载更新的离线安装包,并解压
tar zxvf harbor-offline-installer-v1.2.2.tgz -C /root/local
tar zxvf harbor-offline-installer-v1.2.2.tgz -C /opt

# 使用官方数据库迁移工具,备份数据库,修改数据库连接用户和密码,创建数据库备份目录
# 迁移工具使用docker镜像,镜像tag由待升级到目标harbor版本决定,这里由 1.1.2升级到1.2.2,所以使用 tag 1.2
Expand All @@ -171,7 +171,7 @@ docker run -it --rm -e DB_USR=root -e DB_PWD=xxxx -v /data/database:/var/lib/mys
docker run -it --rm -e DB_USR=root -e DB_PWD=xxxx -v /data/database:/var/lib/mysql vmware/harbor-db-migrator:1.2 up head

# 修改新版本 harbor.cfg配置,需要保持与老版本相关配置项保持一致,然后执行安装即可
cd /root/local/harbor
cd /opt/harbor
vi harbor.cfg
./install.sh

Expand Down
20 changes: 10 additions & 10 deletions roles/harbor/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@
- name: 解压harbor离线安装包
unarchive:
src: "{{ base_dir }}/down/harbor-offline-installer-v1.2.2.tgz"
dest: /root/local
dest: /opt
copy: yes
keep_newer: yes
when: result|failed
when: result is failed

- name: 导入harbor所需 docker images
shell: "{{ bin_dir }}/docker load -i /root/local/harbor/harbor.v1.2.2.tar.gz"
when: result|failed
shell: "{{ bin_dir }}/docker load -i /opt/harbor/harbor.v1.2.2.tar.gz"
when: result is failed

- name: 创建harbor证书请求
template: src=harbor-csr.json.j2 dest={{ ca_dir }}/harbor-csr.json
when: result|failed
when: result is failed

- name: 创建harbor证书和私钥
shell: "cd {{ ca_dir }} && {{ bin_dir }}/cfssl gencert \
-ca={{ ca_dir }}/ca.pem \
-ca-key={{ ca_dir }}/ca-key.pem \
-config={{ ca_dir }}/ca-config.json \
-profile=kubernetes harbor-csr.json | {{ bin_dir }}/cfssljson -bare harbor"
when: result|failed
when: result is failed

- name: 配置 harbor.cfg 文件
template: src=harbor.cfg.j2 dest=/root/local/harbor/harbor.cfg
when: result|failed
template: src=harbor.cfg.j2 dest=/opt/harbor/harbor.cfg
when: result is failed

- name: 安装 harbor
shell: "cd /root/local/harbor && \
shell: "cd /opt/harbor && \
export PATH={{ bin_dir }}:$PATH && \
./install.sh"
when: result|failed
when: result is failed

0 comments on commit f3b788a

Please sign in to comment.