summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inventory/byo/hosts.example7
-rw-r--r--roles/cockpit-ui/tasks/main.yml1
-rw-r--r--roles/openshift_health_checker/openshift_checks/docker_image_availability.py32
-rw-r--r--roles/openshift_health_checker/test/docker_image_availability_test.py46
-rw-r--r--roles/openshift_hosted_templates/files/v3.6/origin/registry-console.yaml10
-rw-r--r--roles/openshift_hosted_templates/files/v3.7/origin/registry-console.yaml10
6 files changed, 81 insertions, 25 deletions
diff --git a/inventory/byo/hosts.example b/inventory/byo/hosts.example
index 5de43270e..fbe0a97c5 100644
--- a/inventory/byo/hosts.example
+++ b/inventory/byo/hosts.example
@@ -400,10 +400,11 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
#openshift_hosted_routers=[{'name': 'router1', 'certificate': {'certfile': '/path/to/certificate/abc.crt', 'keyfile': '/path/to/certificate/abc.key', 'cafile': '/path/to/certificate/ca.crt'}, 'replicas': 1, 'serviceaccount': 'router', 'namespace': 'default', 'stats_port': 1936, 'edits': [], 'images': 'openshift3/ose-${component}:${version}', 'selector': 'type=router1', 'ports': ['80:80', '443:443']}, {'name': 'router2', 'certificate': {'certfile': '/path/to/certificate/xyz.crt', 'keyfile': '/path/to/certificate/xyz.key', 'cafile': '/path/to/certificate/ca.crt'}, 'replicas': 1, 'serviceaccount': 'router', 'namespace': 'default', 'stats_port': 1936, 'edits': [{'action': 'append', 'key': 'spec.template.spec.containers[0].env', 'value': {'name': 'ROUTE_LABELS', 'value': 'route=external'}}], 'images': 'openshift3/ose-${component}:${version}', 'selector': 'type=router2', 'ports': ['80:80', '443:443']}]
# OpenShift Registry Console Options
-# Override the console image prefix for enterprise deployments, not used in origin
-# default is "registry.access.redhat.com/openshift3/" and the image appended is "registry-console"
+# Override the console image prefix:
+# origin default is "cockpit/" and the image appended is "kubernetes"
+# enterprise default is "registry.access.redhat.com/openshift3/" and the image appended is "registry-console"
#openshift_cockpit_deployer_prefix=registry.example.com/myrepo/
-# Override image version, defaults to latest for origin, matches the product version for enterprise
+# Override image version, defaults to latest for origin, vX.Y product version for enterprise
#openshift_cockpit_deployer_version=1.4.1
# Openshift Registry Options
diff --git a/roles/cockpit-ui/tasks/main.yml b/roles/cockpit-ui/tasks/main.yml
index 244e2cc41..09f4259a2 100644
--- a/roles/cockpit-ui/tasks/main.yml
+++ b/roles/cockpit-ui/tasks/main.yml
@@ -37,7 +37,6 @@
cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ openshift_hosted_kubeconfig }}
changed_when: False
- # TODO: Need to fix the origin and enterprise templates so that they both respect IMAGE_PREFIX
- name: Deploy registry-console
command: >
{{ openshift.common.client_binary }} new-app --template=registry-console
diff --git a/roles/openshift_health_checker/openshift_checks/docker_image_availability.py b/roles/openshift_health_checker/openshift_checks/docker_image_availability.py
index 5beb20503..587c6f85c 100644
--- a/roles/openshift_health_checker/openshift_checks/docker_image_availability.py
+++ b/roles/openshift_health_checker/openshift_checks/docker_image_availability.py
@@ -1,5 +1,6 @@
"""Check that required Docker images are available."""
+import re
from pipes import quote
from ansible.module_utils import six
from openshift_checks import OpenShiftCheck
@@ -11,12 +12,16 @@ DEPLOYMENT_IMAGE_INFO = {
"origin": {
"namespace": "openshift",
"name": "origin",
- "registry_console_image": "cockpit/kubernetes",
+ "registry_console_template": "${prefix}kubernetes:${version}",
+ "registry_console_prefix": "cockpit/",
+ "registry_console_default_version": "latest",
},
"openshift-enterprise": {
"namespace": "openshift3",
"name": "ose",
- "registry_console_image": "registry.access.redhat.com/openshift3/registry-console",
+ "registry_console_template": "${prefix}registry-console:${version}",
+ "registry_console_prefix": "registry.access.redhat.com/openshift3/",
+ "registry_console_default_version": "${short_version}",
},
}
@@ -151,10 +156,7 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck):
if 'oo_nodes_to_config' in host_groups:
for suffix in NODE_IMAGE_SUFFIXES:
required.add(image_url.replace("${component}", suffix).replace("${version}", image_tag))
- # The registry-console is for some reason not prefixed with ose- like the other components.
- # Nor is it versioned the same, so just look for latest.
- # Also a completely different name is used for Origin.
- required.add(image_info["registry_console_image"])
+ required.add(self._registry_console_image(image_tag, image_info))
# images for containerized components
if self.get_var("openshift", "common", "is_containerized"):
@@ -170,6 +172,24 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck):
return required
+ def _registry_console_image(self, image_tag, image_info):
+ """Returns image with logic to parallel what happens with the registry-console template."""
+ # The registry-console is for some reason not prefixed with ose- like the other components.
+ # Nor is it versioned the same. Also a completely different name is used for Origin.
+ prefix = self.get_var(
+ "openshift_cockpit_deployer_prefix",
+ default=image_info["registry_console_prefix"],
+ )
+
+ # enterprise template just uses v3.6, v3.7, etc
+ match = re.match(r'v\d+\.\d+', image_tag)
+ short_version = match.group() if match else image_tag
+ version = image_info["registry_console_default_version"].replace("${short_version}", short_version)
+ version = self.get_var("openshift_cockpit_deployer_version", default=version)
+
+ template = image_info["registry_console_template"]
+ return template.replace('${prefix}', prefix).replace('${version}', version)
+
def local_images(self, images):
"""Filter a list of images and return those available locally."""
found_images = []
diff --git a/roles/openshift_health_checker/test/docker_image_availability_test.py b/roles/openshift_health_checker/test/docker_image_availability_test.py
index dec99e5db..484aa72e0 100644
--- a/roles/openshift_health_checker/test/docker_image_availability_test.py
+++ b/roles/openshift_health_checker/test/docker_image_availability_test.py
@@ -1,6 +1,6 @@
import pytest
-from openshift_checks.docker_image_availability import DockerImageAvailability
+from openshift_checks.docker_image_availability import DockerImageAvailability, DEPLOYMENT_IMAGE_INFO
@pytest.fixture()
@@ -180,7 +180,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo
'openshift/origin-deployer:vtest',
'openshift/origin-docker-registry:vtest',
'openshift/origin-haproxy-router:vtest',
- 'cockpit/kubernetes', # origin version of registry-console
+ 'cockpit/kubernetes:latest', # origin version of registry-console
])
),
( # set a different URL for images
@@ -190,7 +190,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo
'foo.io/openshift/origin-deployer:vtest',
'foo.io/openshift/origin-docker-registry:vtest',
'foo.io/openshift/origin-haproxy-router:vtest',
- 'cockpit/kubernetes', # AFAICS this is not built from the URL
+ 'cockpit/kubernetes:latest', # AFAICS this is not built from the URL
])
),
(
@@ -201,7 +201,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo
'openshift/origin-deployer:vtest',
'openshift/origin-docker-registry:vtest',
'openshift/origin-haproxy-router:vtest',
- 'cockpit/kubernetes',
+ 'cockpit/kubernetes:latest',
# containerized component images
'openshift/origin:vtest',
'openshift/node:vtest',
@@ -217,7 +217,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo
'foo.io/openshift3/ose-docker-registry:f13ac45',
'foo.io/openshift3/ose-haproxy-router:f13ac45',
# registry-console is not constructed/versioned the same as the others.
- 'registry.access.redhat.com/openshift3/registry-console',
+ 'registry.access.redhat.com/openshift3/registry-console:vtest',
# containerized images aren't built from oreg_url
'openshift3/node:vtest',
'openshift3/openvswitch:vtest',
@@ -249,6 +249,42 @@ def test_required_images(deployment_type, is_containerized, groups, oreg_url, ex
assert expected == DockerImageAvailability(task_vars=task_vars).required_images()
+@pytest.mark.parametrize("task_vars, expected", [
+ (
+ dict(
+ openshift_deployment_type="origin",
+ openshift_image_tag="vtest",
+ ),
+ "cockpit/kubernetes:latest",
+ ), (
+ dict(
+ openshift_deployment_type="openshift-enterprise",
+ openshift_image_tag="vtest",
+ ),
+ "registry.access.redhat.com/openshift3/registry-console:vtest",
+ ), (
+ dict(
+ openshift_deployment_type="openshift-enterprise",
+ openshift_image_tag="v3.7.0-alpha.0",
+ openshift_cockpit_deployer_prefix="registry.example.com/spam/",
+ ),
+ "registry.example.com/spam/registry-console:v3.7",
+ ), (
+ dict(
+ openshift_deployment_type="origin",
+ openshift_image_tag="v3.7.0-alpha.0",
+ openshift_cockpit_deployer_prefix="registry.example.com/eggs/",
+ openshift_cockpit_deployer_version="spam",
+ ),
+ "registry.example.com/eggs/kubernetes:spam",
+ ),
+])
+def test_registry_console_image(task_vars, expected):
+ info = DEPLOYMENT_IMAGE_INFO[task_vars["openshift_deployment_type"]]
+ tag = task_vars["openshift_image_tag"]
+ assert expected == DockerImageAvailability(task_vars=task_vars)._registry_console_image(tag, info)
+
+
def test_containerized_etcd():
task_vars = dict(
openshift=dict(
diff --git a/roles/openshift_hosted_templates/files/v3.6/origin/registry-console.yaml b/roles/openshift_hosted_templates/files/v3.6/origin/registry-console.yaml
index 6811ece28..a78146ca4 100644
--- a/roles/openshift_hosted_templates/files/v3.6/origin/registry-console.yaml
+++ b/roles/openshift_hosted_templates/files/v3.6/origin/registry-console.yaml
@@ -27,7 +27,7 @@ objects:
spec:
containers:
- name: registry-console
- image: ${IMAGE_NAME}:${IMAGE_VERSION}
+ image: ${IMAGE_PREFIX}kubernetes:${IMAGE_VERSION}
ports:
- containerPort: 9090
protocol: TCP
@@ -89,7 +89,7 @@ objects:
- annotations: null
from:
kind: DockerImage
- name: ${IMAGE_NAME}:${IMAGE_VERSION}
+ name: ${IMAGE_PREFIX}kubernetes:${IMAGE_VERSION}
name: ${IMAGE_VERSION}
- kind: OAuthClient
apiVersion: v1
@@ -100,9 +100,9 @@ objects:
redirectURIs:
- "${COCKPIT_KUBE_URL}"
parameters:
- - description: "Container image name"
- name: IMAGE_NAME
- value: "cockpit/kubernetes"
+ - description: 'Specify "registry/namespace" prefix for container image; e.g. for "registry.example.com/cockpit/kubernetes:latest", set prefix "registry.example.com/cockpit/"'
+ name: IMAGE_PREFIX
+ value: "cockpit/"
- description: 'Specify image version; e.g. for "cockpit/kubernetes:latest", set version "latest"'
name: IMAGE_VERSION
value: latest
diff --git a/roles/openshift_hosted_templates/files/v3.7/origin/registry-console.yaml b/roles/openshift_hosted_templates/files/v3.7/origin/registry-console.yaml
index 6811ece28..a78146ca4 100644
--- a/roles/openshift_hosted_templates/files/v3.7/origin/registry-console.yaml
+++ b/roles/openshift_hosted_templates/files/v3.7/origin/registry-console.yaml
@@ -27,7 +27,7 @@ objects:
spec:
containers:
- name: registry-console
- image: ${IMAGE_NAME}:${IMAGE_VERSION}
+ image: ${IMAGE_PREFIX}kubernetes:${IMAGE_VERSION}
ports:
- containerPort: 9090
protocol: TCP
@@ -89,7 +89,7 @@ objects:
- annotations: null
from:
kind: DockerImage
- name: ${IMAGE_NAME}:${IMAGE_VERSION}
+ name: ${IMAGE_PREFIX}kubernetes:${IMAGE_VERSION}
name: ${IMAGE_VERSION}
- kind: OAuthClient
apiVersion: v1
@@ -100,9 +100,9 @@ objects:
redirectURIs:
- "${COCKPIT_KUBE_URL}"
parameters:
- - description: "Container image name"
- name: IMAGE_NAME
- value: "cockpit/kubernetes"
+ - description: 'Specify "registry/namespace" prefix for container image; e.g. for "registry.example.com/cockpit/kubernetes:latest", set prefix "registry.example.com/cockpit/"'
+ name: IMAGE_PREFIX
+ value: "cockpit/"
- description: 'Specify image version; e.g. for "cockpit/kubernetes:latest", set version "latest"'
name: IMAGE_VERSION
value: latest