k8s: Clean up cert-manager installer
The various helper methods are all called in exactly the same way in both places that they're used. This change consolidates the installation behind CertManager#maybe_install(), which create_cert_manager_ca() invokes before trying to create cert. Change-Id: I37262a22f532962d78b9f1cc0df2b0ee293603f9
This commit is contained in:
parent
959fdc36e4
commit
60ca79a81f
@ -36,6 +36,16 @@ class CertManager:
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def maybe_install(self):
|
||||||
|
if self.is_installed():
|
||||||
|
return
|
||||||
|
|
||||||
|
self.log.info("Installing Cert-Manager")
|
||||||
|
self.install()
|
||||||
|
|
||||||
|
self.log.info("Waiting for Cert-Manager")
|
||||||
|
self.wait_for_webhook()
|
||||||
|
|
||||||
def install(self):
|
def install(self):
|
||||||
utils.apply_file(self.api, 'cert-manager.yaml', _adopt=False)
|
utils.apply_file(self.api, 'cert-manager.yaml', _adopt=False)
|
||||||
|
|
||||||
|
@ -118,11 +118,9 @@ def create_fn(spec, name, namespace, logger, memo, **kwargs):
|
|||||||
# dependencies.
|
# dependencies.
|
||||||
zuul.install_db(install_pxc=memo.operator_config['install_pxc'])
|
zuul.install_db(install_pxc=memo.operator_config['install_pxc'])
|
||||||
|
|
||||||
# Install Cert-Manager and request the CA cert before installing
|
# Request the CA cert before installing ZK
|
||||||
# ZK because the CRDs must exist.
|
|
||||||
zuul.install_cert_manager()
|
|
||||||
zuul.wait_for_cert_manager()
|
|
||||||
zuul.create_cert_manager_ca()
|
zuul.create_cert_manager_ca()
|
||||||
|
|
||||||
# Now we can install ZK
|
# Now we can install ZK
|
||||||
zuul.install_zk()
|
zuul.install_zk()
|
||||||
# Wait for both to finish
|
# Wait for both to finish
|
||||||
@ -158,12 +156,12 @@ def update_fn(name, namespace, logger, old, new, memo, **kwargs):
|
|||||||
logger.info("ZooKeeper changed")
|
logger.info("ZooKeeper changed")
|
||||||
conf_changed = True
|
conf_changed = True
|
||||||
# redo zk
|
# redo zk
|
||||||
zuul.install_cert_manager()
|
|
||||||
zuul.wait_for_cert_manager()
|
|
||||||
zuul.create_cert_manager_ca()
|
zuul.create_cert_manager_ca()
|
||||||
|
|
||||||
# Now we can install ZK
|
# Now we can install ZK
|
||||||
zuul.install_zk()
|
zuul.install_zk()
|
||||||
zuul.wait_for_zk()
|
zuul.wait_for_zk()
|
||||||
|
|
||||||
if new.get('connections') != old.get('connections'):
|
if new.get('connections') != old.get('connections'):
|
||||||
logger.info("Connections changed")
|
logger.info("Connections changed")
|
||||||
conf_changed = True
|
conf_changed = True
|
||||||
|
@ -109,21 +109,9 @@ class Zuul:
|
|||||||
|
|
||||||
self.cert_manager = certmanager.CertManager(
|
self.cert_manager = certmanager.CertManager(
|
||||||
self.api, self.namespace, self.log)
|
self.api, self.namespace, self.log)
|
||||||
self.installing_cert_manager = False
|
|
||||||
|
|
||||||
def install_cert_manager(self):
|
|
||||||
if self.cert_manager.is_installed():
|
|
||||||
return
|
|
||||||
self.installing_cert_manager = True
|
|
||||||
self.cert_manager.install()
|
|
||||||
|
|
||||||
def wait_for_cert_manager(self):
|
|
||||||
if not self.installing_cert_manager:
|
|
||||||
return
|
|
||||||
self.log.info("Waiting for Cert-Manager")
|
|
||||||
self.cert_manager.wait_for_webhook()
|
|
||||||
|
|
||||||
def create_cert_manager_ca(self):
|
def create_cert_manager_ca(self):
|
||||||
|
self.cert_manager.maybe_install()
|
||||||
self.cert_manager.create_ca(instance_name=self.name)
|
self.cert_manager.create_ca(instance_name=self.name)
|
||||||
|
|
||||||
def install_zk(self):
|
def install_zk(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user