Harbor的安装部署

立山  金牌会员 | 2024-8-28 09:25:55 | 来自手机 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 579|帖子 579|积分 1737


一、什么是Harbor

Harbor是一个开源的企业级容器镜像仓库,最初由VMware公司的中国团队开发。它旨在提供安全、高性能和易于管理的容器镜像存储、署名和扫描服务。Harbor扩展了开源Docker Distribution的功能,增长了用户通常需要的安全性、身份和管理功能,使得注册表更加接近构建和运行环境,进步了图像传输服从。Harbor支持在注册表之间复制镜像,并提供高级安全功能,如用户管理、访问控制和活动考核。
Harbor的上风在于它专为企业级环境设计,提供了合规性、性能和互操作性,特别适合在Kubernetes和Docker这样的云原生盘算平台上举行镜像管理。
Harbor实用于需要安全、稳固和高效管理大量Docker镜像的企业,尤其是在云环境、假造化环境或物理服务器中。它有助于企业实现镜像的会合存储管理,进步开发、测试和部署服从。最佳实践包罗合理规划项目布局、使用角色基础的访问控制举行权限分配、定期举行镜像扫描和更新,以及根据需要配置高可用性部署
二、安装Docker

参考:Dockr的安装
三、安装Docker Compose

GitHub下载

  • GitHub下载
  1. wget https://github.com/docker/compose/releases/download/v2.26.0/docker-compose-linux-x86_64 -O /usr/local/bin/docker-compose
复制代码

  • 赋予执行权限
  1. sudo chmod +x /usr/local/bin/docker-compose
复制代码

  • 创建软毗连
  1. sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
复制代码

  • 查看docker版本
  1. docker-compose --version
复制代码
镜像源安装

  • 镜像源下载
  1. wget https://mirror.ghproxy.com/https://github.com/docker/compose/releases/download/v2.26.0/docker-compose-linux-x86_64 -O /usr/local/bin/docker-compose
复制代码

  • 赋予执行权限:
  1. sudo chmod +x /usr/local/bin/docker-compose
复制代码

  • 创建软毗连:
  1. sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
复制代码
四、Harbor的安装

镜像源:https://mirror.ghproxy.com/

  • 从github上找到要安装的harbor的地点通过https://mirror.ghproxy.com/来从国内拉取对应的安装包
  • 通过wget https://mirror.ghproxy.com/+对应的githhub上的的安装地点 拉取安装包
  1. wget https://mirror.ghproxy.com/https://github.com/goharbor/harbor/releases/download/v2.1.3/harbor-offline-installer-v2.1.3.tgz
复制代码

  • 将安装包举行解压,解压至/usr/local/
  1. tar -zxf harbor-offline-installer-v2.1.3.tgz -C /usr/local/
复制代码

  • 修改harbor的配置文件
  1. cd /usr/local/harbor/
  2. cp harbor.yml.tmp harbor.yml
  3. vim harbor.yml
复制代码
  1. # Configuration file of Harbor
  2. # The IP address or hostname to access admin UI and registry service.
  3. # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
  4. #
  5. hostname: 域名        #harbor的域名
  6. # http related config
  7. http:
  8.   # port for http, default is 80. If https enabled, this port will redirect to https port
  9.   port: 端口号        #harbor的端口号
  10. #不使用HTTPS将其注释
  11. # https related config
  12. #https:
  13. # https port for harbor, default is 443
  14. # port: 443
  15. # The path of cert and key files for nginx
  16. # certificate: /your/certificate/path
  17. # private_key: /your/private/key/path
  18. # # Uncomment following will enable tls communication between all harbor components
  19. # internal_tls:
  20. #   # set enabled to true means internal tls is enabled
  21. #   enabled: true
  22. #   # put your cert and key files on dir
  23. #   dir: /etc/harbor/tls/internal
  24. # Uncomment external_url if you want to enable external proxy
  25. # And when it enabled the hostname will no longer used
  26. # external_url: https://reg.mydomain.com:8433
  27. # The initial password of Harbor admin
  28. # It only works in first time to install harbor
  29. # Remember Change the admin password from UI after launching Harbor.
  30. harbor_admin_password: 密码 #harbor的admin密码
  31. # Harbor DB configuration
  32. database:
  33.   # The password for the root user of Harbor DB. Change this before any production use.
  34.   password: 密码 #harbor的数据库密码
  35.   # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
  36.   max_idle_conns: 100
  37.   # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
  38.   # Note: the default number of connections is 1024 for postgres of harbor.
  39.   max_open_conns: 900
  40. # The default data volume
  41. data_volume: /data
  42. # Harbor Storage settings by default is using /data dir on local filesystem
  43. # Uncomment storage_service setting If you want to using external storage
  44. # storage_service:
  45. #   # ca_bundle is the path to the custom root ca certificate, which will be injected into the truststore
  46. #   # of registry's and chart repository's containers.  This is usually needed when the user hosts a internal storage with self signed certificate.
  47. #   ca_bundle:
  48. #   # storage backend, default is filesystem, options include filesystem, azure, gcs, s3, swift and oss
  49. #   # for more info about this configuration please refer https://docs.docker.com/registry/configuration/
  50. #   filesystem:
  51. #     maxthreads: 100
  52. #   # set disable to true when you want to disable registry redirect
  53. #   redirect:
  54. #     disabled: false
  55. # Trivy configuration
  56. #
  57. # Trivy DB contains vulnerability information from NVD, Red Hat, and many other upstream vulnerability databases.
  58. # It is downloaded by Trivy from the GitHub release page https://github.com/aquasecurity/trivy-db/releases and cached
  59. # in the local file system. In addition, the database contains the update timestamp so Trivy can detect whether it
  60. # should download a newer version from the Internet or use the cached one. Currently, the database is updated every
  61. # 12 hours and published as a new release to GitHub.
  62. trivy:
  63.   # ignoreUnfixed The flag to display only fixed vulnerabilities
  64.   ignore_unfixed: false
  65.   # skipUpdate The flag to enable or disable Trivy DB downloads from GitHub
  66.   #
  67.   # You might want to enable this flag in test or CI/CD environments to avoid GitHub rate limiting issues.
  68.   # If the flag is enabled you have to download the `trivy-offline.tar.gz` archive manually, extract `trivy.db` and
  69.   # `metadata.json` files and mount them in the `/home/scanner/.cache/trivy/db` path.
  70.   skip_update: false
  71.   #
  72.   # The offline_scan option prevents Trivy from sending API requests to identify dependencies.
  73.   # Scanning JAR files and pom.xml may require Internet access for better detection, but this option tries to avoid it.
  74.   # For example, the offline mode will not try to resolve transitive dependencies in pom.xml when the dependency doesn't
  75.   # exist in the local repositories. It means a number of detected vulnerabilities might be fewer in offline mode.
  76.   # It would work if all the dependencies are in local.
  77.   # This option doesn’t affect DB download. You need to specify "skip-update" as well as "offline-scan" in an air-gapped environment.
  78.   offline_scan: false
  79.   #
  80.   # insecure The flag to skip verifying registry certificate
  81.   insecure: false
  82.   # github_token The GitHub access token to download Trivy DB
  83.   #
  84.   # Anonymous downloads from GitHub are subject to the limit of 60 requests per hour. Normally such rate limit is enough
  85.   # for production operations. If, for any reason, it's not enough, you could increase the rate limit to 5000
  86.   # requests per hour by specifying the GitHub access token. For more details on GitHub rate limiting please consult
  87.   # https://developer.github.com/v3/#rate-limiting
  88.   #
  89.   # You can create a GitHub token by following the instructions in
  90.   # https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
  91.   #
  92.   # github_token: xxx
  93. jobservice:
  94.   # Maximum number of job workers in job service
  95.   max_job_workers: 10
  96. notification:
  97.   # Maximum retry count for webhook job
  98.   webhook_job_max_retry: 10
  99. chart:
  100.   # Change the value of absolute_url to enabled can enable absolute url in chart
  101.   absolute_url: disabled
  102. # Log configurations
  103. log:
  104.   # options are debug, info, warning, error, fatal
  105.   level: info
  106.   # configs for logs in local storage
  107.   local:
  108.     # Log files are rotated log_rotate_count times before being removed. If count is 0, old versions are removed rather than rotated.
  109.     rotate_count: 50
  110.     # Log files are rotated only if they grow bigger than log_rotate_size bytes. If size is followed by k, the size is assumed to be in kilobytes.
  111.     # If the M is used, the size is in megabytes, and if G is used, the size is in gigabytes. So size 100, size 100k, size 100M and size 100G
  112.     # are all valid.
  113.     rotate_size: 200M
  114.     # The directory on your host that store log
  115.     location: /var/log/harbor
  116.   # Uncomment following lines to enable external syslog endpoint.
  117.   # external_endpoint:
  118.   #   # protocol used to transmit log to external endpoint, options is tcp or udp
  119.   #   protocol: tcp
  120.   #   # The host of external endpoint
  121.   #   host: localhost
  122.   #   # Port of external endpoint
  123.   #   port: 5140
  124. #This attribute is for migrator to detect the version of the .cfg file, DO NOT MODIFY!
  125. _version: 2.4.0
  126. # Uncomment external_database if using external database.
  127. # external_database:
  128. #   harbor:
  129. #     host: harbor_db_host
  130. #     port: harbor_db_port
  131. #     db_name: harbor_db_name
  132. #     username: harbor_db_username
  133. #     password: harbor_db_password
  134. #     ssl_mode: disable
  135. #     max_idle_conns: 2
  136. #     max_open_conns: 0
  137. #   notary_signer:
  138. #     host: notary_signer_db_host
  139. #     port: notary_signer_db_port
  140. #     db_name: notary_signer_db_name
  141. #     username: notary_signer_db_username
  142. #     password: notary_signer_db_password
  143. #     ssl_mode: disable
  144. #   notary_server:
  145. #     host: notary_server_db_host
  146. #     port: notary_server_db_port
  147. #     db_name: notary_server_db_name
  148. #     username: notary_server_db_username
  149. #     password: notary_server_db_password
  150. #     ssl_mode: disable
  151. # Uncomment external_redis if using external Redis server
  152. # external_redis:
  153. #   # support redis, redis+sentinel
  154. #   # host for redis: <host_redis>:<port_redis>
  155. #   # host for redis+sentinel:
  156. #   #  <host_sentinel1>:<port_sentinel1>,<host_sentinel2>:<port_sentinel2>,<host_sentinel3>:<port_sentinel3>
  157. #   host: redis:6379
  158. #   password:
  159. #   # sentinel_master_set must be set to support redis+sentinel
  160. #   #sentinel_master_set:
  161. #   # db_index 0 is for core, it's unchangeable
  162. #   registry_db_index: 1
  163. #   jobservice_db_index: 2
  164. #   chartmuseum_db_index: 3
  165. #   trivy_db_index: 5
  166. #   idle_timeout_seconds: 30
  167. # Uncomment uaa for trusting the certificate of uaa instance that is hosted via self-signed cert.
  168. # uaa:
  169. #   ca_file: /path/to/ca
  170. # Global proxy
  171. # Config http proxy for components, e.g. http://my.proxy.com:3128
  172. # Components doesn't need to connect to each others via http proxy.
  173. # Remove component from `components` array if want disable proxy
  174. # for it. If you want use proxy for replication, MUST enable proxy
  175. # for core and jobservice, and set `http_proxy` and `https_proxy`.
  176. # Add domain to the `no_proxy` field, when you want disable proxy
  177. # for some special registry.
  178. proxy:
  179.   http_proxy:
  180.   https_proxy:
  181.   no_proxy:
  182.   components:
  183.     - core
  184.     - jobservice
  185.     - trivy
  186. # metric:
  187. #   enabled: false
  188. #   port: 9090
  189. #   path: /metrics
  190. # Trace related config
  191. # only can enable one trace provider(jaeger or otel) at the same time,
  192. # and when using jaeger as provider, can only enable it with agent mode or collector mode.
  193. # if using jaeger collector mode, uncomment endpoint and uncomment username, password if needed
  194. # if using jaeger agetn mode uncomment agent_host and agent_port
  195. # trace:
  196. #   enabled: true
  197. #   # set sample_rate to 1 if you wanna sampling 100% of trace data; set 0.5 if you wanna sampling 50% of trace data, and so forth
  198. #   sample_rate: 1
  199. #   # # namespace used to differenciate different harbor services
  200. #   # namespace:
  201. #   # # attributes is a key value dict contains user defined attributes used to initialize trace provider
  202. #   # attributes:
  203. #   #   application: harbor
  204. #   # # jaeger should be 1.26 or newer.
  205. #   # jaeger:
  206. #   #   endpoint: http://hostname:14268/api/traces
  207. #   #   username:
  208. #   #   password:
  209. #   #   agent_host: hostname
  210. #   #   # export trace data by jaeger.thrift in compact mode
  211. #   #   agent_port: 6831
  212. #   # otel:
  213. #   #   endpoint: hostname:4318
  214. #   #   url_path: /v1/traces
  215. #   #   compression: false
  216. #   #   insecure: true
  217. #   #   timeout: 10s
复制代码

  • 使用./install.sh
    命令执行安装脚本
  1. ./install.sh
复制代码

  • 在/etc/hosts中添加对应的域名解析
  1. 本机IP        域名 #例:192.168.1.3  ganchengfang.xyz
复制代码
五、Harbor的登录


  • 使用docker login 域名:端口
    的命令行形式登录harbor
  1. docker login 域名:端口
复制代码

  • 使用欣赏器访问harbor
    在导航栏输入 服务器ip:端口 进入harbor的登录界面

  • 在导航栏输入 域名:端口 进入harbor的登岸界面

   注:使用 域名:端口时 需要买一个域名举行绑定(在任何公网都可访问)或修改本地的hosts来举行解析(只有修改过才能访问)

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

立山

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表