mirror of
https://github.com/goharbor/harbor
synced 2025-04-21 21:44:12 +00:00
Add registry storage config in harbor.cfg (#3918)
Refer to https://docs.docker.com/registry/configuration/#storage for all available configuration.
This commit is contained in:
parent
f20103dc0c
commit
b1b316a97b
@ -6,8 +6,7 @@ log:
|
|||||||
storage:
|
storage:
|
||||||
cache:
|
cache:
|
||||||
layerinfo: inmemory
|
layerinfo: inmemory
|
||||||
filesystem:
|
$storage_provider_info
|
||||||
rootdirectory: /storage
|
|
||||||
maintenance:
|
maintenance:
|
||||||
uploadpurging:
|
uploadpurging:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
@ -6,7 +6,7 @@ log:
|
|||||||
storage:
|
storage:
|
||||||
cache:
|
cache:
|
||||||
layerinfo: redis
|
layerinfo: redis
|
||||||
Place_holder_for_Storage_configureation
|
$storage_provider_info
|
||||||
maintenance:
|
maintenance:
|
||||||
uploadpurging:
|
uploadpurging:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
@ -133,14 +133,21 @@ clair_db_username = postgres
|
|||||||
|
|
||||||
#Clair default database
|
#Clair default database
|
||||||
clair_db = postgres
|
clair_db = postgres
|
||||||
|
|
||||||
|
|
||||||
################### end of HA section #####################
|
################### end of HA section #####################
|
||||||
|
|
||||||
#************************END INITIAL PROPERTIES************************
|
#************************END INITIAL PROPERTIES************************
|
||||||
|
|
||||||
#The following attributes only need to be set when auth mode is uaa_auth
|
#The following attributes only need to be set when auth mode is uaa_auth
|
||||||
uaa_endpoint = uaa.mydomain.org
|
uaa_endpoint = uaa.mydomain.org
|
||||||
uaa_clientid = id
|
uaa_clientid = id
|
||||||
uaa_clientsecret = secret
|
uaa_clientsecret = secret
|
||||||
uaa_verify_cert = true
|
uaa_verify_cert = true
|
||||||
uaa_ca_cert = /path/to/ca.pem
|
uaa_ca_cert = /path/to/ca.pem
|
||||||
#############
|
|
||||||
|
|
||||||
|
### Docker Registry setting ###
|
||||||
|
#registry_storage_provider can be: filesystem, s3, gcs, azure, etc.
|
||||||
|
registry_storage_provider_name = filesystem
|
||||||
|
#registry_storage_provider_config is a comma separated "key: value" pairs, e.g. "key1: value, key2: value2".
|
||||||
|
#Refer to https://docs.docker.com/registry/configuration/#storage for all available configuration.
|
||||||
|
registry_storage_provider_config =
|
||||||
|
42
make/prepare
42
make/prepare
@ -23,13 +23,16 @@ def validate(conf, args):
|
|||||||
if args.ha_mode:
|
if args.ha_mode:
|
||||||
db_host = rcp.get("configuration", "db_host")
|
db_host = rcp.get("configuration", "db_host")
|
||||||
if db_host == "mysql":
|
if db_host == "mysql":
|
||||||
raise Exception("Error: In HA mode, db_host in harbor.cfg needs to point to an external DB address")
|
raise Exception("Error: In HA mode, db_host in harbor.cfg needs to point to an external DB address.")
|
||||||
registry_config_path = os.path.join(templates_dir,"registry","config_ha.yml")
|
registry_storage_provider_name = rcp.get("configuration",
|
||||||
if check_storage_config(registry_config_path):
|
"registry_storage_provider_name").strip()
|
||||||
raise Exception("Error: In HA model shared storage configuration is required registry, refer HA installation guide for detail.")
|
if registry_storage_provider_name == "filesystem" and not args.yes:
|
||||||
|
msg = 'Is the Harbor Docker Registry configured to use shared storage (e.g. NFS, S3, GCS, etc.)? [yes/no]:'
|
||||||
|
if raw_input(msg).lower() != "yes":
|
||||||
|
raise Exception("Error: In HA mode, shared storage configuration for Docker Registry in harbor.cfg is required. Refer to HA installation guide for details.")
|
||||||
redis_url = rcp.get("configuration", "redis_url")
|
redis_url = rcp.get("configuration", "redis_url")
|
||||||
if redis_url is None or len(redis_url) < 1:
|
if redis_url is None or len(redis_url) < 1:
|
||||||
raise Exception("Error: In HA mode redis is required redis_url need to point to an redis cluster")
|
raise Exception("Error: In HA mode, redis_url in harbor.cfg needs to point to a Redis cluster.")
|
||||||
if args.notary_mode:
|
if args.notary_mode:
|
||||||
raise Exception("Error: HA mode doesn't support Notary currently")
|
raise Exception("Error: HA mode doesn't support Notary currently")
|
||||||
if args.clair_mode:
|
if args.clair_mode:
|
||||||
@ -117,11 +120,6 @@ def prepare_ha(conf, args):
|
|||||||
if os.path.isfile(secret_key):
|
if os.path.isfile(secret_key):
|
||||||
shutil.copy2(secret_key, shared_secret_key)
|
shutil.copy2(secret_key, shared_secret_key)
|
||||||
|
|
||||||
def check_storage_config(path):
|
|
||||||
if 'Place_holder_for_Storage_configureation' in open(path).read():
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_secret_key(path):
|
def get_secret_key(path):
|
||||||
secret_key = _get_secret(path, "secretkey")
|
secret_key = _get_secret(path, "secretkey")
|
||||||
if len(secret_key) != 16:
|
if len(secret_key) != 16:
|
||||||
@ -180,6 +178,7 @@ parser.add_argument('--conf', dest='cfgfile', default=base_dir+'/harbor.cfg',typ
|
|||||||
parser.add_argument('--with-notary', dest='notary_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with notary")
|
parser.add_argument('--with-notary', dest='notary_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with notary")
|
||||||
parser.add_argument('--with-clair', dest='clair_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with clair")
|
parser.add_argument('--with-clair', dest='clair_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with clair")
|
||||||
parser.add_argument('--ha', dest='ha_mode', default=False, action='store_true', help="the Harbor instance is to be deployed in HA mode")
|
parser.add_argument('--ha', dest='ha_mode', default=False, action='store_true', help="the Harbor instance is to be deployed in HA mode")
|
||||||
|
parser.add_argument('--yes', dest='yes', default=False, action='store_true', help="Answer yes to all questions")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
delfile(config_dir)
|
delfile(config_dir)
|
||||||
@ -260,7 +259,6 @@ if rcp.has_option("configuration", "redis_url"):
|
|||||||
redis_url = rcp.get("configuration", "redis_url")
|
redis_url = rcp.get("configuration", "redis_url")
|
||||||
else:
|
else:
|
||||||
redis_url = ""
|
redis_url = ""
|
||||||
########
|
|
||||||
|
|
||||||
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
||||||
jobservice_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
jobservice_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
||||||
@ -357,17 +355,23 @@ render(os.path.join(templates_dir, "ui", "env"),
|
|||||||
jobservice_secret=jobservice_secret,
|
jobservice_secret=jobservice_secret,
|
||||||
redis_url = redis_url
|
redis_url = redis_url
|
||||||
)
|
)
|
||||||
if args.ha_mode:
|
|
||||||
render(os.path.join(templates_dir, "registry",
|
registry_config_file = "config_ha.yml" if args.ha_mode else "config.yml"
|
||||||
"config_ha.yml"),
|
storage_provider_name = rcp.get("configuration", "registry_storage_provider_name").strip()
|
||||||
|
storage_provider_config = rcp.get("configuration", "registry_storage_provider_config").strip()
|
||||||
|
if storage_provider_name == "filesystem":
|
||||||
|
if not storage_provider_config:
|
||||||
|
storage_provider_config = "rootdirectory: /storage"
|
||||||
|
elif "rootdirectory:" not in storage_provider_config:
|
||||||
|
storage_provider_config = "rootdirectory: /storage" + "," + storage_provider_config
|
||||||
|
# generate storage configuration section in yaml format
|
||||||
|
storage_provider_info = ('\n' + ' ' * 4).join(
|
||||||
|
[storage_provider_name + ':'] + map(string.strip, storage_provider_config.split(",")))
|
||||||
|
render(os.path.join(templates_dir, "registry", registry_config_file),
|
||||||
registry_conf,
|
registry_conf,
|
||||||
|
storage_provider_info=storage_provider_info,
|
||||||
ui_url=ui_url,
|
ui_url=ui_url,
|
||||||
redis_url=redis_url)
|
redis_url=redis_url)
|
||||||
else:
|
|
||||||
render(os.path.join(templates_dir, "registry",
|
|
||||||
"config.yml"),
|
|
||||||
registry_conf,
|
|
||||||
ui_url=ui_url)
|
|
||||||
|
|
||||||
render(os.path.join(templates_dir, "db", "env"),
|
render(os.path.join(templates_dir, "db", "env"),
|
||||||
db_conf_env,
|
db_conf_env,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user