Harbor 2.5 性能优化配置指南:提升效率与安全性
Harbor 2.5 性能优化配置指南:提升效率与安全性
Harbor 是一个开源的容器镜像仓库,它提供了多种功能来管理和存储容器镜像。为了提升 Harbor 的性能和安全性,可以对 harbor.yml 配置文件进行优化。本文将介绍一些常用的优化技巧,并提供示例配置。
优化配置
-
使用外部存储:可以考虑使用外部存储来存储 Harbor 的数据和镜像,以减轻本地文件系统的负担,提高性能和可靠性。在
harbor.yml文件中,可以设置storage_service参数来配置外部存储。 -
调整数据库连接池大小:可以根据实际情况调整数据库连接池的大小,以确保足够的连接数,同时避免过多的空闲连接。在
harbor.yml文件中,可以设置database.max_idle_conns和database.max_open_conns参数来调整连接池的大小。 -
启用 TLS 通信:可以启用 TLS 通信以增强安全性,但需要注意证书的管理和更新。在
harbor.yml文件中,可以设置https和internal_tls参数来启用 TLS 通信。 -
启用日志轮换:可以启用日志轮换以避免日志文件过大,影响性能和可用性。在
harbor.yml文件中,可以设置log.local参数来配置日志轮换。 -
调整 Trivy 配置:可以根据实际情况调整 Trivy 的配置,以确保及时发现漏洞并提高扫描效率。在
harbor.yml文件中,可以设置trivy参数来调整 Trivy 配置。 -
启用上传清理:可以启用上传清理功能以定期清理不再使用的上传文件,以减轻存储负担。在
harbor.yml文件中,可以设置upload_purging参数来启用上传清理功能。
示例配置
# Configuration file of Harbor
# ...
# Harbor Storage settings by default is using /data dir on local filesystem
# Uncomment storage_service setting If you want to using external storage
storage_service:
# ca_bundle is the path to the custom root ca certificate, which will be injected into the truststore
# of registry's and chart repository's containers. This is usually needed when the user hosts a internal storage with self signed certificate.
# ca_bundle:
# storage backend, default is filesystem, options include filesystem, azure, gcs, s3, swift and oss
# for more info about this configuration please refer https://docs.docker.com/registry/configuration/
filesystem:
maxthreads: 100
# set disable to true when you want to disable registry redirect
redirect:
disabled: false
# ...
database:
# ...
max_idle_conns: 100
max_open_conns: 900
# ...
# Trivy configuration
# ...
trivy:
# ...
# skipUpdate The flag to enable or disable Trivy DB downloads from GitHub
skip_update: false
# ...
# ...
# Log configurations
log:
# ...
local:
# ...
rotate_count: 50
rotate_size: 200M
# ...
# ...
# enable purge _upload directories
upload_purging:
enabled: true
age: 168h
interval: 24h
dryrun: false
小结
本文介绍了如何优化 Harbor 2.5 的配置,以提升性能和安全性。通过使用外部存储、调整数据库连接池大小、启用 TLS 通信、日志轮换、Trivy 配置和上传清理等技巧,可以有效地提升 Harbor 的性能和安全性,确保容器镜像的安全存储和管理。
原文地址: https://www.cveoy.top/t/topic/kyi5 著作权归作者所有。请勿转载和采集!