From cd87bbe4fa31a439e391f8d09a1b96f99810d375 Mon Sep 17 00:00:00 2001 From: Ayoub Nasr Date: Mon, 23 Dec 2024 10:30:26 +0100 Subject: [PATCH] salt: install operatorhubio catalog --- buildchain/buildchain/salt_tree.py | 3 +++ salt/_modules/metalk8s_olm.py | 17 +++++++++++++++++ .../olm/catalog/deployed/cluster-catalog.sls | 12 ++++++++++++ .../addons/olm/catalog/deployed/init.sls | 14 ++++++++++++++ salt/metalk8s/deployed/init.sls | 1 + 5 files changed, 47 insertions(+) create mode 100644 salt/_modules/metalk8s_olm.py create mode 100644 salt/metalk8s/addons/olm/catalog/deployed/cluster-catalog.sls create mode 100644 salt/metalk8s/addons/olm/catalog/deployed/init.sls diff --git a/buildchain/buildchain/salt_tree.py b/buildchain/buildchain/salt_tree.py index 93dadf5d44..f042fa074f 100644 --- a/buildchain/buildchain/salt_tree.py +++ b/buildchain/buildchain/salt_tree.py @@ -344,6 +344,8 @@ def task(self) -> types.TaskDict: file_dep=[METALK8S_OPERATOR_MANIFESTS], ), Path("salt/metalk8s/addons/metalk8s-operator/deployed/init.sls"), + Path("salt/metalk8s/addons/olm/catalog/deployed/cluster-catalog.sls"), + Path("salt/metalk8s/addons/olm/catalog/deployed/init.sls"), Path("salt/metalk8s/addons/olm/catalogd/deployed/catalogd.sls"), Path("salt/metalk8s/addons/olm/catalogd/deployed/cert.sls"), Path("salt/metalk8s/addons/olm/catalogd/deployed/crds.sls"), @@ -696,6 +698,7 @@ def task(self) -> types.TaskDict: Path("salt/_modules/metalk8s_kubernetes_utils.py"), Path("salt/_modules/metalk8s_monitoring.py"), Path("salt/_modules/metalk8s_network.py"), + Path("salt/_modules/metalk8s_olm.py"), Path("salt/_modules/metalk8s_os.py"), Path("salt/_modules/metalk8s_package_manager_yum.py"), Path("salt/_modules/metalk8s_service_configuration.py"), diff --git a/salt/_modules/metalk8s_olm.py b/salt/_modules/metalk8s_olm.py new file mode 100644 index 0000000000..5a17745c51 --- /dev/null +++ b/salt/_modules/metalk8s_olm.py @@ -0,0 +1,17 @@ +"""Interacts with OLMv1 CRs""" + +__virtualname__ = "metalk8s_olm" + + +def __virtual__(): + return __virtualname__ + + +def check_clustercatalog_serving(name: str): + catalog = __salt__["metalk8s_kubernetes.get_object"]( + kind="ClusterCatalog", apiVersion="olm.operatorframework.io/v1", name=name + ) + for cond in catalog["status"]["conditions"]: + if cond["type"] == "Serving": + return cond["status"] == "True" + return False diff --git a/salt/metalk8s/addons/olm/catalog/deployed/cluster-catalog.sls b/salt/metalk8s/addons/olm/catalog/deployed/cluster-catalog.sls new file mode 100644 index 0000000000..6cb3c925c5 --- /dev/null +++ b/salt/metalk8s/addons/olm/catalog/deployed/cluster-catalog.sls @@ -0,0 +1,12 @@ +#!jinja | metalk8s_kubernetes + +apiVersion: olm.operatorframework.io/v1 +kind: ClusterCatalog +metadata: + name: operatorhubio +spec: + source: + type: Image + image: + ref: quay.io/operatorhubio/catalog:latest + pollIntervalMinutes: 10 diff --git a/salt/metalk8s/addons/olm/catalog/deployed/init.sls b/salt/metalk8s/addons/olm/catalog/deployed/init.sls new file mode 100644 index 0000000000..bfe50aa903 --- /dev/null +++ b/salt/metalk8s/addons/olm/catalog/deployed/init.sls @@ -0,0 +1,14 @@ +include: + - ...operator-controller.deployed + - .cluster-catalog + +Wait for Cluster Catalog to be Serving: + test.configurable_test_state: + - changes: False + - result: __slot__:salt:metalk8s_olm.check_clustercatalog_serving("operatorhubio") + - comment: Wait for ClusterCatalog to be Ready + - retry: + attempts: 30 + - require: + - test: Wait for the Operator Controller Controller Manager Deployment to be Ready + - sls: metalk8s.addons.olm.catalog.deployed.cluster-catalog diff --git a/salt/metalk8s/deployed/init.sls b/salt/metalk8s/deployed/init.sls index a91c8a694d..230d968363 100644 --- a/salt/metalk8s/deployed/init.sls +++ b/salt/metalk8s/deployed/init.sls @@ -5,6 +5,7 @@ include: - metalk8s.addons.cert-manager.deployed - metalk8s.addons.olm.catalogd.deployed - metalk8s.addons.olm.operator-controller.deployed + - metalk8s.addons.olm.catalog.deployed - metalk8s.addons.nginx-ingress.deployed - metalk8s.addons.nginx-ingress-control-plane.deployed - metalk8s.addons.volumes.deployed