View and test Harbor REST API via Swagger

View and test Harbor REST API via Swagger

官方原文参考
###目录:harbor/docs/configure_swagger.md
这里写图片描述
####1>下载prepare-swagger.sh和swagger.yaml 文件到本地文件夹
我自己文件目录:/opt/harbor-swagger-ui

[root@localhost harbor-swagger-ui]# wget https://raw.githubusercontent.com/vmware/harbor/master/docs/prepare-swagger.sh https://raw.githubusercontent.com/vmware/harbor/master/docs/swagger.yaml
--2018-07-19 15:35:07--  https://raw.githubusercontent.com/vmware/harbor/master/docs/prepare-swagger.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.72.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.72.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1080 (1.1K) [text/plain]
Saving to: ‘prepare-swagger.sh’

100%[====================================================================================================>] 1,080       --.-K/s   in 0s      

2018-07-19 15:35:57 (111 MB/s) - ‘prepare-swagger.sh’ saved [1080/1080]

--2018-07-19 15:35:57--  https://raw.githubusercontent.com/vmware/harbor/master/docs/swagger.yaml
Reusing existing connection to raw.githubusercontent.com:443.
HTTP request sent, awaiting response... 200 OK
Length: 112066 (109K) [text/plain]
Saving to: ‘swagger.yaml’

100%[====================================================================================================>] 112,066     26.3KB/s   in 4.2s   

2018-07-19 15:36:02 (26.3 KB/s) - ‘swagger.yaml’ saved [112066/112066]

FINISHED --2018-07-19 15:36:02--
Total wall clock time: 54s
Downloaded: 2 files, 110K in 4.2s (26.6 KB/s)

####2>编辑文件prepare-swagger.sh.

vi prepare-swagger.sh

编辑协议用http或者https【根据安装harbor来定】,自己harbor服务IP地址

SCHEME=<HARBOR_SERVER_SCHEME>
SERVER_IP=<HARBOR_SERVER_DOMAIN>

这里写图片描述
另外:如果端口不是默认的80的话,这里也要配置一致内容,不然会提示不成功
在这里插入图片描述

Change the file mode

[root@localhost harbor-swagger-ui]# chmod +x prepare-swagger.sh

在当前目前下运行shell script,下载文件和创建文件等,可仔细看脚本便知

 [root@localhost harbor-swagger-ui]# ./prepare-swagger.sh
Doing some clean up...
Downloading Swagger UI release package...
--2018-07-19 15:49:34--  https://github.com/swagger-api/swagger-ui/archive/v2.1.4.tar.gz
Resolving github.com (github.com)... 13.250.177.223, 52.74.223.119, 13.229.188.59
Connecting to github.com (github.com)|13.250.177.223|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/swagger-api/swagger-ui/tar.gz/v2.1.4 [following]
--2018-07-19 15:49:42--  https://codeload.github.com/swagger-api/swagger-ui/tar.gz/v2.1.4
Resolving codeload.github.com (codeload.github.com)... 13.229.189.0, 13.250.162.133, 54.251.140.56
Connecting to codeload.github.com (codeload.github.com)|13.229.189.0|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1036338 (1012K) [application/x-gzip]
Saving to: ‘swagger.tar.gz’

100%[====================================================================================================>] 1,036,338   41.1KB/s   in 13s    

2018-07-19 15:49:57 (80.2 KB/s) - ‘swagger.tar.gz’ saved [1036338/1036338]

Untarring Swagger UI package to the static file path...
Executing some processes...
Finish preparation for the Swagger UI.

####3>编辑文件docker-compose.yml.

可以全局查找自己的文件:find | grep docker-compose.yml

[root@localhost /]# find | grep docker-compose.yml
./var/www/html/resource/harbor/docker-compose.yml
./var/www/html/resource/harbor/ha/docker-compose.yml
[root@localhost /]# cd ./var/www/html/resource/harbor/
[root@localhost harbor]# ls
common                    docker-compose.notary.yml  ha          harbor.v1.5.1.tar.gz  LICENSE  prepare
docker-compose.clair.yml  docker-compose.yml         harbor.cfg  install.sh            NOTICE
[root@localhost harbor]# vi docker-compose.yml

添加的内容如下:一定要注意路径问题,检查下是否存在##

...
ui:
  ... 
  volumes:
    - ./common/config/ui/app.conf:/etc/ui/app.conf:z
    - ./common/config/ui/private_key.pem:/etc/ui/private_key.pem:z
    - /data/secretkey:/etc/ui/key:z
    - /data/ca_download/:/etc/ui/ca/:z
    ## add two lines as below 一定要注意路径问题,检查下是否存在##
    - /opt/src/ui/static/vendors/swagger-ui-2.1.4/dist:/harbor/static/vendors/swagger
    - /opt/src/ui/static/resources/yaml/swagger.yaml:/harbor/static/resources/yaml/swagger.yaml
    ...

这里写图片描述
####4>Recreate Harbor containers

[root@localhost harbor]# docker-compose down -v && docker-compose up -d
Stopping harbor-jobservice ... done
Stopping nginx ... done
Stopping harbor-ui ... done
Stopping harbor-adminserver ... done
Stopping harbor-db ... done
Stopping redis ... done
Stopping registry ... done
Stopping harbor-log ... done
Removing harbor-jobservice ... done
Removing nginx ... done
Removing harbor-ui ... done
Removing harbor-adminserver ... done
Removing harbor-db ... done
Removing redis ... done
Removing registry ... done
Removing harbor-log ... done
Removing network harbor_harbor
Creating network "harbor_harbor" with the default driver
Creating harbor-log
Creating registry
Creating harbor-db
Creating harbor-adminserver
Creating redis
Creating harbor-ui
Creating harbor-jobservice
Creating nginx

访问地址:

http://<HARBOR_SERVER>/static/vendors/swagger/index.html

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

[shenhonglei]

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值