Skip to content

Commit

Permalink
create onprem: replace existing pod
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Dec 24, 2023
1 parent 60906bd commit 0a55028
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
3 changes: 3 additions & 0 deletions ailib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,9 @@ def create_deployment(self, cluster, overrides, force=False, debug=False):
overrides['cluster'] = cluster
self.create_infra_env(infraenv, overrides)
del overrides['cluster']
if not self.saas:
info("Waiting 45s to let time to the iso to be available")
sleep(45)
if 'iso_url' in overrides:
download_iso_path = overrides.get('download_iso_path')
if download_iso_path is None:
Expand Down
58 changes: 34 additions & 24 deletions ailib/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,40 +150,50 @@ def get_ip():


def create_onprem(overrides={}, debug=False):
onprem_version = overrides.get('onprem_version', 'v2.27.0')
if which('podman') is None:
error("You need podman to run this")
sys.exit(1)
with TemporaryDirectory() as tmpdir:
with open(f"{tmpdir}/pod.yml", 'w') as p:
pod_url = "https://raw.githubusercontent.com/openshift/assisted-service/master/deploy/podman/pod.yml"
response = urllib.request.urlopen(pod_url)
p.write(response.read().decode('utf-8'))
with open(f"{tmpdir}/configmap.yml.ori", 'w') as c:
cm_name = 'okd-configmap' if overrides.get('okd', False) else 'configmap'
cm_url = f"https://raw.githubusercontent.com/openshift/assisted-service/master/deploy/podman/{cm_name}.yml"
response = urllib.request.urlopen(cm_url)
c.write(response.read().decode('utf-8'))
ip = overrides.get('ip') or get_ip() or '192.168.122.1'
info(f"Using ip {ip}")
IMAGE_SERVICE_BASE_URL = f'http://{ip}:8888'
SERVICE_BASE_URL = f'http://{ip}:8090'
with open(f"{tmpdir}/configmap.yml", 'wt') as dest:
for line in open(f"{tmpdir}/configmap.yml.ori", 'rt').readlines():
if 'IMAGE_SERVICE_BASE_URL' in line:
dest.write(f" IMAGE_SERVICE_BASE_URL: {IMAGE_SERVICE_BASE_URL}\n")
elif 'SERVICE_BASE_URL:' in line:
dest.write(f" SERVICE_BASE_URL: {SERVICE_BASE_URL}\n")
else:
dest.write(line)
p.write(response.read().decode('utf-8').replace('latest',
onprem_version).replace(f'centos7:{onprem_version}',
'centos7:latest'))
if os.path.exists('configmap.yml'):
info("Using existing configmap.yml")
copy2("configmap.yml", tmpdir)
else:
with open(f"{tmpdir}/configmap.yml.ori", 'w') as c:
cm_name = 'okd-configmap' if overrides.get('okd', False) else 'configmap'
cm_url = "https://raw.githubusercontent.com/openshift/assisted-service/master/deploy/podman/"
cm_url += f"{cm_name}.yml"
response = urllib.request.urlopen(cm_url)
c.write(response.read().decode('utf-8'))
ip = overrides.get('ip') or get_ip() or '192.168.122.1'
info(f"Using ip {ip}")
if ':' in ip and '[' not in ip:
ip = f"[{ip}]"
IMAGE_SERVICE_BASE_URL = f'http://{ip}:8888'
SERVICE_BASE_URL = f'http://{ip}:8090'
with open(f"{tmpdir}/configmap.yml", 'wt') as dest:
for line in open(f"{tmpdir}/configmap.yml.ori", 'rt').readlines():
if 'IMAGE_SERVICE_BASE_URL' in line:
dest.write(f" IMAGE_SERVICE_BASE_URL: {IMAGE_SERVICE_BASE_URL}\n")
elif 'SERVICE_BASE_URL:' in line:
dest.write(f" SERVICE_BASE_URL: {SERVICE_BASE_URL}\n")
else:
dest.write(line)
if overrides.get('keep', False):
copy2(f"{tmpdir}/configmap.yml", '.')
copy2(f"{tmpdir}/pod.yml", '.')
else:
if debug:
print(open(f"{tmpdir}/configmap.yml").read())
info(f"Running: podman play kube --configmap {tmpdir}/configmap.yml {tmpdir}/pod.yml")
storage = '--storage-driver vfs' if 'KUBERNETES_SERVICE_PORT' in os.environ else ''
call(f"podman {storage} play kube --configmap {tmpdir}/configmap.yml {tmpdir}/pod.yml", shell=True)
if debug:
print(open(f"{tmpdir}/configmap.yml").read())
storage = '--storage-driver vfs' if 'KUBERNETES_SERVICE_PORT' in os.environ else ''
cmd = f"podman {storage} play kube --replace --configmap {tmpdir}/configmap.yml {tmpdir}/pod.yml"
info(f"Running: {cmd}")
call(cmd, shell=True)


def delete_onprem(overrides={}, debug=False):
Expand Down
14 changes: 11 additions & 3 deletions ailib/common/registries.conf.templ
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@ unqualified-search-registries = ["registry.access.redhat.com", "docker.io"]
[[registry.mirror]]
location = "%(url)s/ocpmetal"

[[registry]]
prefix = ""
location = "quay.io/edge-infrastructure"
mirror-by-digest-only = false

[[registry.mirror]]
location = "%(url)s/edge-infrastructure"

[[registry]]
prefix = ""
location = "quay.io/openshift-release-dev/ocp-release"
mirror-by-digest-only = false

[[registry.mirror]]
location = "%(url)s/ocp4"
location = "%(url)s/openshift/release-images"

[[registry]]
prefix = ""
location = "quay.io/openshift-release-dev/ocp-v4.0-art-dev"
mirror-by-digest-only = false

[[registry.mirror]]
location = "%(url)s/ocp4"
location = "%(url)s/openshift/release"

[[registry]]
prefix = ""
location = "registry.ci.openshift.org/ocp/release"
mirror-by-digest-only = false

[[registry.mirror]]
location = "%(url)s/ocp4"
location = "%(url)s/openshift/release-images"

0 comments on commit 0a55028

Please sign in to comment.