關於Harbor部署過程中儲存路徑修改的實踐
阿新 • • 發佈:2018-11-15
安裝
Harbor安裝的環境要求,具體步驟不再細說,過程很簡單,詳情請見官網文件:
https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
在預設的安裝部署下,harbor的儲存路徑是/data/。在一般的實際部署中大概率有修改的需求,且官方文件在此並沒有詳細地說明。
如下圖所示,根據宿主機根目錄磁碟不同,預設的容量可能不滿足需求:
且僅僅掛載/data/registry(映象儲存路徑)並不能修改上圖中儲存容量的顯示,而是需要遷移整個/data/路徑下harbor的內容。
因此針對如何修改harbor的預設儲存路徑這一問題做下簡要闡述。
如何修改儲存路徑
實踐環境:
作業系統:CentOS 7.2
Docker:1.11 和 17.03.2
Docker-Compose:1.20.1
Harbor:1.6.1
使用離線安裝包
修改內容:
1.harbor.cfg
修改"secretkey"的路徑
#The path of secretkey storage
secretkey_path = /data/harbor-data # 預設是 /data
2.docker-compose.yml
修改原先所有預設為"/data"的volume的掛載路徑
version: '2' services: log: image: goharbor/harbor-log:v1.6.1 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 registry: image: goharbor/registry-photon:v2.6.2-v1.6.1 container_name: registry restart: always volumes: - /data/harbor-data/registry:/storage:z - ./common/config/registry/:/etc/registry/:z networks: - harbor environment: - GODEBUG=netdns=cgo depends_on: - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "registry" postgresql: image: goharbor/harbor-db:v1.6.1 container_name: harbor-db restart: always volumes: - /data/harbor-data//database:/var/lib/postgresql/data:z networks: - harbor env_file: - ./common/config/db/env depends_on: - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "postgresql" adminserver: image: goharbor/harbor-adminserver:v1.6.1 container_name: harbor-adminserver env_file: - ./common/config/adminserver/env restart: always volumes: - /data/harbor-data/config/:/etc/adminserver/config/:z - /data/harbor-data/secretkey:/etc/adminserver/key:z - /data/harbor-data/:/data/:z networks: - harbor depends_on: - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "adminserver" ui: image: goharbor/harbor-ui:v1.6.1 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/harbor-data/secretkey:/etc/ui/key:z - /data/harbor-data/ca_download/:/etc/ui/ca/:z - /data/harbor-data/psc/:/etc/ui/token/:z networks: - harbor depends_on: - log - adminserver - registry logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "ui" jobservice: image: goharbor/harbor-jobservice:v1.6.1 container_name: harbor-jobservice env_file: - ./common/config/jobservice/env restart: always volumes: - /data/harbor-data/job_logs:/var/log/jobs:z - ./common/config/jobservice/config.yml:/etc/jobservice/config.yml:z networks: - harbor depends_on: - redis - ui - adminserver logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "jobservice" redis: image: goharbor/redis-photon:v1.6.1 container_name: redis restart: always volumes: - /data/harbor-data/redis:/var/lib/redis networks: - harbor depends_on: - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "redis" proxy: image: goharbor/nginx-photon:v1.6.1 container_name: nginx restart: always volumes: - ./common/config/nginx:/etc/nginx:z networks: - harbor ports: - 80:80 - 443:443 - 4443:4443 depends_on: - postgresql - registry - ui - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "proxy" networks: harbor: external: false
完成上述修改後執行下述命令重新部署容器即可:
./prepare
docker-compose up -d
注意:
在整個部署過程中,不要手動修改上述關聯掛載路徑下的內容。若要修改相關內容,一定要保證在容器完全移除(docker-compose down)的前提下進行。