harbor镜像仓库自动清理脚本

清除
 curl -u admin:123456 -X POST http://192.168.0.202/api/v2.0/system/gc/schedule  -H 'accept: application/json' -H 'Content-Type: application/json' -d '{ "delete_untagged": "false", "dry_run": "false", "schedule": {"type": "Manual"}}'


创建
curl -u admin:1234567  -X POST "http://{{ inventory_hostname }}/api/v2.0/projects" -H "accept: application/json" -H "Content-Type: application/json" -
d "{ \"project_name\": \"prometheus\", \"metadata\": { \"public\": \"true\" }}"

 

 

创建

#!/bin/bash
cd /data/harbor

DOCKERSTATUS=$(docker-compose  ps -a| grep unhealthy | grep -v grep) 

if [ ! -n "$DOCKERSTATUS" ]; then

   /usr/local/bin/docker-compose down -v 

   /usr/local/bin/docker-compose  up  -d
   
   sleep 180

fi

curl -u admin:123456 -X POST "http://192.168.0.160/api/v2.0/projects" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"project_name\": \"source\", \"metadata\": { \"public\": \"true\" }}"
curl -u admin:123456 -X POST "http://192.168.0.160/api/v2.0/projects" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"project_name\": \"prometheus\", \"metadata\": { \"public\": \"true\" }}"

 

posted @ 2022-05-12 19:32  fengjian1585  阅读(367)  评论(0编辑  收藏  举报