diff --git a/make/harbor.yml.tmpl b/make/harbor.yml.tmpl index 19f1c17ec..763855fd2 100644 --- a/make/harbor.yml.tmpl +++ b/make/harbor.yml.tmpl @@ -17,6 +17,16 @@ https: certificate: /your/certificate/path private_key: /your/private/key/path +# # Harbor will set ipv4 enabled only by defualt if this block is not configured +# # Otherwise, please uncomment this block to configure your own ip_family stacks +# ip_family: +# # ipv6Enabled set to true if ipv6 is enabled in docker network, currently it affected the nginx related component +# ipv6: +# enabled: false +# # ipv4Enabled set to true by default, currently it affected the nginx related component +# ipv4: +# enabled: true + # # Uncomment following will enable tls communication between all harbor components # internal_tls: # # set enabled to true means internal tls is enabled diff --git a/make/photon/prepare/migrations/version_2_10_0/harbor.yml.jinja b/make/photon/prepare/migrations/version_2_10_0/harbor.yml.jinja index 44a46968f..23e25dcb3 100644 --- a/make/photon/prepare/migrations/version_2_10_0/harbor.yml.jinja +++ b/make/photon/prepare/migrations/version_2_10_0/harbor.yml.jinja @@ -33,6 +33,28 @@ https: # private_key: /your/private/key/path {% endif %} +{% if ip_family is defined %} +# # Harbor will set ipv4 enabled only by defualt if this block is not configured +# # Otherwise, please uncomment this block to configure your own ip_family stacks +ip_family: + # ipv6Enabled set to true if ipv6 is enabled in docker network, currently it affected the nginx related component + ipv6: + enabled: {{ ip_family.ipv6.enabled | lower }} + # ipv4Enabled set to true by default, currently it affected the nginx related component + ipv4: + enabled: {{ ip_family.ipv4.enabled | lower }} +{% else %} +# # Harbor will set ipv4 enabled only by defualt if this block is not configured +# # Otherwise, please uncomment this block to configure your own ip_family stacks +ip_family: + # ipv6Enabled set to true if ipv6 is enabled in docker network, currently it affected the nginx related component + ipv6: + enabled: false + # ipv4Enabled set to true by default, currently it affected the nginx related component + ipv4: + enabled: true +{% endif %} + {% if internal_tls is defined %} # Uncomment following will enable tls communication between all harbor components internal_tls: diff --git a/make/photon/prepare/migrations/version_2_9_0/harbor.yml.jinja b/make/photon/prepare/migrations/version_2_9_0/harbor.yml.jinja index 1ab5ee906..2c429365a 100644 --- a/make/photon/prepare/migrations/version_2_9_0/harbor.yml.jinja +++ b/make/photon/prepare/migrations/version_2_9_0/harbor.yml.jinja @@ -33,6 +33,28 @@ https: # private_key: /your/private/key/path {% endif %} +{% if ip_family is defined %} +# # Harbor will set ipv4 enabled only by defualt if this block is not configured +# # Otherwise, please uncomment this block to configure your own ip_family stacks +ip_family: + # ipv6Enabled set to true if ipv6 is enabled in docker network, currently it affected the nginx related component + ipv6: + enabled: {{ ip_family.ipv6.enabled | lower }} + # ipv4Enabled set to true by default, currently it affected the nginx related component + ipv4: + enabled: {{ ip_family.ipv4.enabled | lower }} +{% else %} +# # Harbor will set ipv4 enabled only by defualt if this block is not configured +# # Otherwise, please uncomment this block to configure your own ip_family stacks +ip_family: + # ipv6Enabled set to true if ipv6 is enabled in docker network, currently it affected the nginx related component + ipv6: + enabled: false + # ipv4Enabled set to true by default, currently it affected the nginx related component + ipv4: + enabled: true +{% endif %} + {% if internal_tls is defined %} # Uncomment following will enable tls communication between all harbor components internal_tls: diff --git a/make/photon/prepare/templates/nginx/nginx.https.conf.jinja b/make/photon/prepare/templates/nginx/nginx.https.conf.jinja index 4c62ae79a..a5d0d8037 100644 --- a/make/photon/prepare/templates/nginx/nginx.https.conf.jinja +++ b/make/photon/prepare/templates/nginx/nginx.https.conf.jinja @@ -50,8 +50,12 @@ http { include /etc/nginx/conf.d/*.server.conf; server { + {% if ip_family.ipv4.enabled %} listen 8443 ssl; + {% endif %} + {% if ip_family.ipv6.enabled %} listen [::]:8443 ssl; + {% endif %} # server_name harbordomain.com; server_tokens off; # SSL diff --git a/make/photon/prepare/templates/portal/nginx.conf.jinja b/make/photon/prepare/templates/portal/nginx.conf.jinja index 01de758fe..3f17e7176 100644 --- a/make/photon/prepare/templates/portal/nginx.conf.jinja +++ b/make/photon/prepare/templates/portal/nginx.conf.jinja @@ -16,8 +16,13 @@ http { server { {% if internal_tls.enabled %} + #ip_family + {% if ip_family.ipv4.enabled %} listen 8443 ssl; + {% endif %} + {% if ip_family.ipv6.enabled %} listen [::]:8443 ssl; + {% endif %} # SSL ssl_certificate /etc/harbor/tls/portal.crt; ssl_certificate_key /etc/harbor/tls/portal.key; diff --git a/make/photon/prepare/utils/configs.py b/make/photon/prepare/utils/configs.py index bb3024935..f47ff4c40 100644 --- a/make/photon/prepare/utils/configs.py +++ b/make/photon/prepare/utils/configs.py @@ -298,6 +298,9 @@ def parse_yaml_config(config_file_path, with_trivy): external_database=config_dict['external_database']) else: config_dict['internal_tls'] = InternalTLS() + + # ip_family config + config_dict['ip_family'] = configs.get('ip_family') or {'ipv4': {'enabled': True}, 'ipv6': {'enabled': False}} # metric configs metric_config = configs.get('metric') diff --git a/make/photon/prepare/utils/nginx.py b/make/photon/prepare/utils/nginx.py index 54d4305d4..0b1ffb8a4 100644 --- a/make/photon/prepare/utils/nginx.py +++ b/make/photon/prepare/utils/nginx.py @@ -63,7 +63,8 @@ def render_nginx_template(config_dict): ssl_cert=SSL_CERT_PATH, ssl_cert_key=SSL_CERT_KEY_PATH, internal_tls=config_dict['internal_tls'], - metric=config_dict['metric']) + metric=config_dict['metric'], + ip_family=config_dict['ip_family']) location_file_pattern = CUSTOM_NGINX_LOCATION_FILE_PATTERN_HTTPS else: diff --git a/make/photon/prepare/utils/portal.py b/make/photon/prepare/utils/portal.py index a2524827b..d41de1264 100644 --- a/make/photon/prepare/utils/portal.py +++ b/make/photon/prepare/utils/portal.py @@ -14,5 +14,6 @@ def prepare_portal(config_dict): str(portal_conf_template_path), portal_conf, internal_tls=config_dict['internal_tls'], + ip_family=config_dict['ip_family'], uid=DEFAULT_UID, gid=DEFAULT_GID)