harbor GC 回收

Posted jiwd

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了harbor GC 回收相关的知识,希望对你有一定的参考价值。

1、修改harbor目录中的common/config/registry/config.yml

version: 0.1
log:
  level: info
  fields:
    service: registry
storage:
  cache:
    layerinfo: inmemory
  filesystem:
    rootdirectory: /storage
  maintenance:
    uploadpurging:
      enabled: false
  delete:
    enabled: true
http:
  addr: :5000
  secret: placeholder
  debug:
    addr: localhost:5001
#auth:
#  token:
#   issuer: harbor-token-issuer
#    realm: http://192.168.1.165/service/token
#    rootcertbundle: /etc/registry/root.crt
#    service: harbor-registry
notifications:
  endpoints:
  - name: harbor
    disabled: false
    url: http://ui:8080/service/notifications
    timeout: 3000ms
    threshold: 5
    backoff: 1s

注释掉红色部分代码,禁止身份验证

2、编辑docker-compose.yml文件,在registry添加端口和IP

version: ‘2‘
services:
  log:
    image: vmware/harbor-log:v1.5.4
    container_name: harbor-log 
    restart: always
    volumes:
      - /var/log/harbor/:/var/log/docker/:z
      - ./common/config/log/:/etc/logrotate.d/:z
    ports:
      - 127.0.0.1:1514:10514
    networks:
      - harbor
    dns_search: .
  registry:
    #ports: 
    #  - 127.0.0.1:7777:5000
    image: vmware/registry-photon:v2.6.2-v1.5.4
    container_name: registry
    restart: always
    volumes:
      - /home/harbor_registry:/storage:z
      - ./common/config/registry/:/etc/registry/:z
    networks:
      - harbor
    dns_search: .
    environment:
      - GODEBUG=netdns=cgo
    command:
      ["serve", "/etc/registry/config.yml"]
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:  
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "registry"
  mysql:
    image: vmware/harbor-db:v1.5.4
    container_name: harbor-db
    restart: always
    volumes:
      - /data/database:/var/lib/mysql:z
    networks:
      - harbor
    dns_search: .
    env_file:
      - ./common/config/db/env
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:  
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "mysql"
  adminserver:
    image: vmware/harbor-adminserver:v1.5.4
    container_name: harbor-adminserver
    env_file:
      - ./common/config/adminserver/env
    restart: always
    volumes:
      - /data/config/:/etc/adminserver/config/:z
      - /data/secretkey:/etc/adminserver/key:z
      - /data/:/data/:z
    networks:
      - harbor
    dns_search: .
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:  
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "adminserver"
  ui:
    image: vmware/harbor-ui:v1.5.4
    container_name: harbor-ui
    env_file:
      - ./common/config/ui/env
    restart: always
    volumes:
      - ./common/config/ui/app.conf:/etc/ui/app.conf:z
      - ./common/config/ui/private_key.pem:/etc/ui/private_key.pem:z
      - ./common/config/ui/certificates/:/etc/ui/certificates/:z
      - /data/secretkey:/etc/ui/key:z
      - /data/ca_download/:/etc/ui/ca/:z
      - /data/psc/:/etc/ui/token/:z
    networks:
      - harbor
    dns_search: .
    depends_on:
      - log
      - adminserver
      - registry
    logging:
      driver: "syslog"
      options:  
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "ui"
  jobservice:
    image: vmware/harbor-jobservice:v1.5.4
    container_name: harbor-jobservice
    env_file:
      - ./common/config/jobservice/env
    restart: always
    volumes:
      - /data/job_logs:/var/log/jobs:z
      - ./common/config/jobservice/config.yml:/etc/jobservice/config.yml:z
    networks:
      - harbor
    dns_search: .
    depends_on:
      - redis
      - ui
      - adminserver
    logging:
      driver: "syslog"
      options:  
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "jobservice"
  redis:
    image: vmware/redis-photon:v1.5.4
    container_name: redis
    restart: always
    volumes:
      - /data/redis:/data
    networks:
      - harbor
    dns_search: .
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:  
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "redis"
  proxy:
    image: vmware/nginx-photon:v1.5.4
    container_name: nginx
    restart: always
    volumes:
      - ./common/config/nginx:/etc/nginx:z
    networks:
      - harbor
    dns_search: .
    ports:
      - 80:80
      - 443:443
      - 4443:4443
    depends_on:
      - mysql
      - registry
      - ui
      - log
    logging:
      driver: "syslog"
      options:  
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "proxy"
networks:
  harbor:
    external: false

3、执行

  docker-compose down

  docker-compose up -d

4、执行 (注意:命令中的/home/harbor_registry 路径为上面配置文件绿色路径)

docker run --network="host" -it -v /home/harbor_registry:/registry -e REGISTRY_URL=http://127.0.0.1:7777 mortensrasmussen/docker-registry-manifest-cleanup

5、查看可删除blob

docker run -it --name gc --rm --volumes-from registry vmware/registry-photon:v2.6.2-v1.4.0 garbage-collect --dry-run /etc/registry/config.yml

6、删除blob

docker run -it --name gc --rm --volumes-from registry vmware/registry-photon:v2.6.2-v1.4.0 garbage-collect  /etc/registry/config.yml

7、把步骤1和2修改的配置文件还原,重启

  docker-compose down

  docker-compose up -d

 

以上是关于harbor GC 回收的主要内容,如果未能解决你的问题,请参考以下文章

Unity2019 增量式GC(使用时间片段执行GC,减少卡顿)

harbor磁盘爆满,执行垃圾回收清理镜像

面向面试编程代码片段之GC

GC垃圾回收机制

GC垃圾回收机制

怎么验证java的gc是不是会回收了某个不用的对象了。我有段代码有性能问题,需要调优,想知道怎么看