二、k8s之部署私有倉庫(Harbor)

下載harbor-2.1.0安裝包

下載離線安裝包:

$ wget https://github.com/goharbor/harbor/releases/download/v2.1.0-rc2/harbor-offline-installer-v2.1.0-rc2.tgz

解壓!

修改harbor.yml配置信息

$ cp harbor.yml.tmpl harbor.yml
$ vim harbor.yml
# 如何選擇hostname:
	# 1、如果所有機器都在一個局域網,那麼配置內網IP或域名(確保域名已做內網解析或綁定hosts)
	# 2、如果機器跨網絡,只能通過公網訪問,那麼配置本機外網IP或域名
hostname: hub.adaixuezhang.cn
http:
  port: 80
# ssl證書需要購買
# 自制ssl證書參考:https://goharbor.io/docs/2.0.0/install-config/configure-https/ 或 http://www.zhangblog.com/2020/05/13/docker06/
https:
  port: 443
  certificate: /etc/ssl/certs/nginx/hub.adaixuezhang.cn_bundle.crt
  private_key: /etc/ssl/certs/nginx/hub.adaixuezhang.cn.key

# harbor admin用戶密碼
harbor_admin_password: Harbor12345
# 數據庫配置信息
database:
  password: root123
  max_idle_conns: 50
  max_open_conns: 1000

# 數據存儲路徑
data_volume: /data/harbor/data
# 日誌存放目錄
location: /var/log/harbor

安裝

$ ./install.sh

安裝並啓動成功!

訪問Harbor

  • hub.adaixuezhang.cn
  • 用戶名:admin
  • 密碼:Harbor12345

管理harbor進程

如果修改了Harbor的配置文件harbor.yml,因爲Harbor是基於docker-compose服務編排的,我們可以使用docker-compose命令重啓Harbor。

未修改配置文件,重啓Harbor命令:docker-compose start | stop | restart

當然個人建議:如果修改了harbor.yml文件,那麼停止使用docker-compose down,啓動使用 ./install.sh 。

$docker-compose help
Define and run multi-container applications with Docker.

Usage:
  docker-compose [-f <arg>...] [options] [--] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  -f, --file FILE             Specify an alternate compose file
                              (default: docker-compose.yml)
  -p, --project-name NAME     Specify an alternate project name
                              (default: directory name)
  -c, --context NAME          Specify a context name
  --verbose                   Show more output
  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  --no-ansi                   Do not print ANSI control characters
  -v, --version               Print version and exit
  -H, --host HOST             Daemon socket to connect to

  --tls                       Use TLS; implied by --tlsverify
  --tlscacert CA_PATH         Trust certs signed only by this CA
  --tlscert CLIENT_CERT_PATH  Path to TLS certificate file
  --tlskey TLS_KEY_PATH       Path to TLS key file
  --tlsverify                 Use TLS and verify the remote
  --skip-hostname-check       Don't check the daemon's hostname against the
                              name specified in the client certificate
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)
  --compatibility             If set, Compose will attempt to convert keys
                              in v3 files to their non-Swarm equivalent (DEPRECATED)
  --env-file PATH             Specify an alternate environment file

Commands:
  build              Build or rebuild services
  config             Validate and view the Compose file
  create             Create services
  down               Stop and remove containers, networks, images, and volumes
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push service images
  restart            Restart services
  rm                 Remove stopped containers
  run                Run a one-off command
  scale              Set number of containers for a service
  start              Start services
  stop               Stop services
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show version information and quit

參考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章