Merge "Strip out port from the alternative registry url"

This commit is contained in:
Zuul 2019-10-09 20:17:13 +00:00 committed by Gerrit Code Review
commit 72b3eb6251
3 changed files with 37 additions and 2 deletions

View File

@ -15,7 +15,31 @@ MAX_DOWNLOAD_THREAD = 5
def download_an_image(img):
local_img = 'registry.local:9001/' + img
# This function is to pull image from public/private
# registry and push to local registry.
#
# Examples of passed img reference:
# - k8s.gcr.io/kube-proxy:v.16.0
# - privateregistry.io:5000/kube-proxy:v1.16.0
#
# To push to local registry, local registry url
# 'registry.local:9001' needs to be prepended to
# image reference. The registry url of passed img
# may contains a port, if it has a port, we strip
# it out as Docker does not allow the format of
# the image that has port in repositories/namespaces
# i.e.
# Invalid format:
# registry.local:9001/privateregistry.io:5000/kube-proxy:v1.16.0
registry_url = img[:img.find('/')]
if ':' in registry_url:
img_name = img[img.find('/'):]
new_img = registry_url.split(':')[0] + img_name
else:
new_img = img
local_img = 'registry.local:9001/' + new_img
err_msg = " Image %s download failed: " % img
for i in range(MAX_DOWNLOAD_ATTEMPTS):

View File

@ -115,7 +115,7 @@
ETCD_ENDPOINT: "http://{{ cluster_floating_address | ipwrap }}:2379"
POD_NETWORK_CIDR: "{{ cluster_pod_subnet }}"
SERVICE_NETWORK_CIDR: "{{ cluster_service_subnet }}"
K8S_REGISTRY: "{{ k8s_registry.url }}"
K8S_REGISTRY: "{{ k8s_registry.url | regex_replace(':[0-9]+', '') }}"
- name: Add apiserver certificate SANs to kubeadm
replace:

View File

@ -220,6 +220,17 @@
registry: "{{ local_registry }}"
state: absent
- name: Strip out port from Tiller, Armada, Calico, Multus, Sriov image tags
set_fact:
tiller_img: "{{ tiller_img | regex_replace(':[0-9]+/', '/') }}"
armada_img: "{{ armada_img | regex_replace(':[0-9]+/', '/') }}"
calico_cni_img: "{{ calico_cni_img | regex_replace(':[0-9]+/', '/') }}"
calico_node_img: "{{ calico_node_img | regex_replace(':[0-9]+/', '/') }}"
calico_kube_controllers_img: "{{ calico_kube_controllers_img | regex_replace(':[0-9]+/', '/') }}"
multus_img: "{{ multus_img | regex_replace(':[0-9]+/', '/') }}"
sriov_cni_img: "{{ sriov_cni_img | regex_replace(':[0-9]+/', '/') }}"
sriov_network_device_img: "{{ sriov_network_device_img | regex_replace(':[0-9]+/', '/') }}"
- name: Remove local registry host from /etc/hosts
command: >-
sed -i -e 's|'$CONTROLLER_ADDRESS'\t'$CONTROLLER'\t'$LOCAL_REGISTRY'|'$CONTROLLER_ADDRESS'\t'$CONTROLLER'|g' /etc/hosts