Add http_proxy configuration for Clair service

Clair needs Internet access to download vulnerabilities data.

Fix issue https://github.com/vmware/harbor/issues/4272
This commit is contained in:
Jesse Hu 2018-03-28 18:49:40 +08:00
parent cbcca015b0
commit 87c622141b
4 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,3 @@
http_proxy=$http_proxy
https_proxy=$https_proxy
no_proxy=$no_proxy

View File

@ -47,6 +47,8 @@ services:
options: options:
syslog-address: "tcp://127.0.0.1:1514" syslog-address: "tcp://127.0.0.1:1514"
tag: "clair" tag: "clair"
env_file:
./common/config/clair/clair_env
networks: networks:
harbor-clair: harbor-clair:
external: false external: false

View File

@ -36,6 +36,12 @@ log_rotate_count = 50
#are all valid. #are all valid.
log_rotate_size = 200M log_rotate_size = 200M
#Config http proxy for Clair, e.g. http://my.proxy.com:3128
#Clair doesn't need to connect to harbor ui container via http proxy.
http_proxy =
https_proxy =
no_proxy = 127.0.0.1,localhost,ui
#NOTES: The properties between BEGIN INITIAL PROPERTIES and END INITIAL PROPERTIES #NOTES: The properties between BEGIN INITIAL PROPERTIES and END INITIAL PROPERTIES
#only take effect in the first boot, the subsequent changes of these properties #only take effect in the first boot, the subsequent changes of these properties
#should be performed on web ui #should be performed on web ui

View File

@ -550,6 +550,15 @@ if args.clair_mode:
username = clair_db_username, username = clair_db_username,
host = clair_db_host, host = clair_db_host,
port = clair_db_port) port = clair_db_port)
# config http proxy for Clair
http_proxy = rcp.get("configuration", "http_proxy").strip()
https_proxy = rcp.get("configuration", "https_proxy").strip()
no_proxy = rcp.get("configuration", "no_proxy").strip()
clair_env = os.path.join(clair_config_dir, "clair_env")
render(os.path.join(clair_temp_dir, "clair_env"), clair_env,
http_proxy = http_proxy,
https_proxy = https_proxy,
no_proxy = no_proxy)
if args.ha_mode: if args.ha_mode:
prepare_ha(rcp, args) prepare_ha(rcp, args)