Exemple #1
0
def setup_ord(opts, upgrade=False, verbose=False):
    ord_namespace = get_namespace(opts, opts['orderers']['msp'])
    # Kafka
    if 'kafka' in opts['orderers']:
        # Kafka upgrade is risky, so we disallow it by default
        helm_install('incubator',
                     'kafka',
                     'kafka-hlf',
                     ord_namespace,
                     config_yaml='{dir}/kafka/kafka-hlf.yaml'.format(
                         dir=opts['core']['dir_values']),
                     pod_num=opts['orderers']['kafka']['pod_num'],
                     verbose=verbose)

    for release in opts['orderers']['names']:
        # HL-Ord
        if not upgrade:
            helm_install(opts['core']['chart_repo'],
                         'hlf-ord',
                         release,
                         ord_namespace,
                         config_yaml='{dir}/hlf-ord/{name}.yaml'.format(
                             dir=opts['core']['dir_values'], name=release),
                         verbose=verbose)
        else:
            helm_upgrade(opts['core']['chart_repo'],
                         'hlf-ord',
                         release,
                         ord_namespace,
                         config_yaml='{dir}/hlf-ord/{name}.yaml'.format(
                             dir=opts['core']['dir_values'], name=release),
                         verbose=verbose)
        # Check that Orderer is running
        check_ord(ord_namespace, release, verbose=verbose)
Exemple #2
0
def deploy_composer(opts, upgrade=False, verbose=False):
    """Deploy Hyperledger Composer on K8S.

    We use the hl-composer Helm chart as a basis to deploying Composer
    on K8S. Please note that Composer is unmaintained and may eventually
    be deprecated from this repository as we migrate to raw Fabric.

    Args:
        opts (dict): Nephos options dict.
        upgrade (bool): Do we upgrade the deployment? False by default.
        verbose (bool): Verbosity. False by default.
    """
    peer_namespace = get_namespace(opts, opts["peers"]["msp"])
    # Ensure BNA exists
    secret_from_file(
        secret=opts["composer"]["secret_bna"], namespace=peer_namespace, verbose=verbose
    )
    composer_connection(opts, verbose=verbose)

    # Start Composer
    if not upgrade:
        helm_install(
            opts["core"]["chart_repo"],
            "hl-composer",
            opts["composer"]["name"],
            peer_namespace,
            pod_num=3,
            config_yaml="{dir}/hl-composer/{release}.yaml".format(
                dir=opts["core"]["dir_values"], release=opts["composer"]["name"]
            ),
            verbose=verbose,
        )
    else:
        # TODO: Implement upgrade: set $CA_USERNAME and $CA_PASSWORD
        pass
Exemple #3
0
 def test_helm_install_envvars(
     self, mock_execute, mock_helm_check, mock_helm_env_vars
 ):
     mock_helm_env_vars.side_effect = [" --set foo=bar"]
     mock_execute.side_effect = [
         (None, "error"),  # Helm list
         ("Helm install", None),  # Helm install
     ]
     helm_install(
         "a_repo",
         "an_app",
         "a-release",
         "a-namespace",
         env_vars="env-vars",
         verbose=True,
     )
     mock_helm_env_vars.assert_called_once_with("env-vars")
     mock_execute.assert_has_calls(
         [
             call("helm status a-release"),
             call(
                 "helm install a_repo/an_app -n a-release --namespace a-namespace "
                 + "--set foo=bar",
                 verbose=True,
             ),
         ]
     )
     mock_helm_check.assert_called_once_with("an_app", "a-release", "a-namespace", 1)
Exemple #4
0
 def test_helm_install_config(
     self, mock_execute, mock_helm_check, mock_helm_env_vars
 ):
     mock_helm_env_vars.side_effect = [""]
     mock_execute.side_effect = [
         (None, "error"),  # Helm list
         ("Helm install", None),  # Helm install
     ]
     helm_install(
         "a_repo",
         "an_app",
         "a-release",
         "a-namespace",
         config_yaml="some_config.yaml",
     )
     mock_helm_env_vars.assert_called_once_with(None)
     mock_execute.assert_has_calls(
         [
             call("helm status a-release"),
             call(
                 "helm install a_repo/an_app -n a-release --namespace a-namespace -f some_config.yaml",
                 verbose=False,
             ),
         ]
     )
     mock_helm_check.assert_called_once_with("an_app", "a-release", "a-namespace", 1)
Exemple #5
0
 def test_helm_install_envvars(self, mock_execute, mock_helm_check,
                               mock_helm_env_vars):
     mock_helm_env_vars.side_effect = [' --set foo=bar']
     mock_execute.side_effect = [
         None,  # Helm list
         None,  # Helm install
     ]
     helm_install('a_repo',
                  'an_app',
                  'a-release',
                  'a-namespace',
                  env_vars='env-vars',
                  verbose=True)
     mock_helm_env_vars.assert_called_once_with('a-namespace',
                                                'env-vars',
                                                verbose=True)
     mock_execute.assert_has_calls([
         call('helm status a-release'),
         call(
             'helm install a_repo/an_app -n a-release --namespace a-namespace '
             + '--set foo=bar',
             verbose=True)
     ])
     mock_helm_check.assert_called_once_with('an_app', 'a-release',
                                             'a-namespace', 1)
Exemple #6
0
def ca_chart(opts, release, upgrade=False, verbose=False):
    values_dir = opts['core']['dir_values']
    repository = opts['core']['chart_repo']
    ca_namespace = get_namespace(opts, ca=release)
    # PostgreSQL (Upgrades here are dangerous, deactivated by default)
    helm_install('stable',
                 'postgresql',
                 '{}-pg'.format(release),
                 ca_namespace,
                 config_yaml='{dir}/postgres-ca/{name}-pg.yaml'.format(
                     dir=values_dir, name=release),
                 verbose=verbose)
    psql_secret = secret_read('{}-pg-postgresql'.format(release),
                              ca_namespace,
                              verbose=verbose)
    # Different key depending of PostgreSQL version
    psql_password = psql_secret.get(
        'postgres-password') or psql_secret['postgresql-password']
    env_vars = [('externalDatabase.password', psql_password)]
    # Fabric CA
    if not upgrade:
        helm_install(repository,
                     'hlf-ca',
                     release,
                     ca_namespace,
                     config_yaml='{dir}/hlf-ca/{name}.yaml'.format(
                         dir=values_dir, name=release),
                     env_vars=env_vars,
                     verbose=verbose)
    else:
        # TODO: Remove this try/catch once all CAs are updated
        try:
            preserve = (HelmPreserve('{}-hlf-ca'.format(release), 'CA_ADMIN',
                                     'adminUsername'),
                        HelmPreserve('{}-hlf-ca'.format(release),
                                     'CA_PASSWORD', 'adminPassword'))
            helm_upgrade(repository,
                         'hlf-ca',
                         release,
                         ca_namespace,
                         config_yaml='{dir}/hlf-ca/{name}.yaml'.format(
                             dir=values_dir, name=release),
                         env_vars=env_vars,
                         preserve=preserve,
                         verbose=verbose)
        except:
            preserve = (HelmPreserve('{}-hlf-ca--ca'.format(release),
                                     'CA_ADMIN', 'adminUsername'),
                        HelmPreserve('{}-hlf-ca--ca'.format(release),
                                     'CA_PASSWORD', 'adminPassword'))
            helm_upgrade(repository,
                         'hlf-ca',
                         release,
                         ca_namespace,
                         config_yaml='{dir}/hlf-ca/{name}.yaml'.format(
                             dir=values_dir, name=release),
                         env_vars=env_vars,
                         preserve=preserve,
                         verbose=verbose)
Exemple #7
0
def setup_ord(opts, upgrade=False, verbose=False):
    """Setup Orderer on K8S.

    Args:
        opts (dict): Nephos options dict.
        upgrade (bool): Do we upgrade the deployment? False by default.
        verbose (bool): Verbosity. False by default.
    """
    ord_namespace = get_namespace(opts, opts["orderers"]["msp"])
    # Kafka
    if "kafka" in opts["orderers"]:
        # Kafka upgrade is risky, so we disallow it by default
        version = get_version(opts, "kafka")
        config_yaml = "{dir}/kafka/{release}.yaml".format(
            dir=opts["core"]["dir_values"],
            release=opts["orderers"]["kafka"]["name"])
        extra_vars = helm_extra_vars(version=version, config_yaml=config_yaml)
        helm_install(
            "incubator",
            "kafka",
            opts["orderers"]["kafka"]["name"],
            ord_namespace,
            extra_vars=extra_vars,
            verbose=verbose,
        )
        helm_check(
            "kafka",
            opts["orderers"]["kafka"]["name"],
            ord_namespace,
            pod_num=opts["orderers"]["kafka"]["pod_num"],
        )

    for release in opts["orderers"]["names"]:
        # HL-Ord
        version = get_version(opts, "hlf-ord")
        config_yaml = "{dir}/hlf-ord/{name}.yaml".format(
            dir=opts["core"]["dir_values"], name=release)
        extra_vars = helm_extra_vars(version=version, config_yaml=config_yaml)
        if not upgrade:
            helm_install(
                opts["core"]["chart_repo"],
                "hlf-ord",
                release,
                ord_namespace,
                extra_vars=extra_vars,
                verbose=verbose,
            )
        else:
            helm_upgrade(
                opts["core"]["chart_repo"],
                "hlf-ord",
                release,
                extra_vars=extra_vars,
                verbose=verbose,
            )
        helm_check("hlf-ord", release, ord_namespace)
        # Check that Orderer is running
        check_ord(ord_namespace, release, verbose=verbose)
Exemple #8
0
 def test_helm_install_again(
     self, mock_execute, mock_helm_check, mock_helm_env_vars
 ):
     mock_helm_env_vars.side_effect = [""]
     mock_execute.side_effect = [("a-release", None)]  # Helm list
     helm_install("a_repo", "an_app", "a-release", "a-namespace")
     mock_helm_env_vars.assert_called_once_with(None)
     mock_execute.assert_called_once_with("helm status a-release")
     mock_helm_check.assert_called_once_with("an_app", "a-release", "a-namespace", 1)
Exemple #9
0
def setup_ord(opts, upgrade=False):
    """Setup Orderer on K8S.

    Args:
        opts (dict): Nephos options dict.
        upgrade (bool): Do we upgrade the deployment? False by default.
    """
    # Kafka
    if "kafka" in opts["ordering"]:
        # Kafka upgrade is risky, so we disallow it by default
        version = get_version(opts, "kafka")
        kafka_config = get_kafka_configs(opts=opts)
        ord_namespace = get_namespace(opts, msp=kafka_config["msp"])
        config_yaml = f"{opts['core']['dir_values']}/{kafka_config['msp']}/kafka/{kafka_config['name']}.yaml"
        extra_vars = helm_extra_vars(version=version, config_yaml=config_yaml)
        helm_install(
            "incubator",
            "kafka",
            kafka_config["name"],
            ord_namespace,
            extra_vars=extra_vars,
        )
        helm_check(
            "kafka",
            kafka_config["name"],
            ord_namespace,
            pod_num=kafka_config["pod_num"],
        )

    for msp in get_msps(opts=opts):
        if not is_orderer_msp(opts=opts, msp=msp):
            continue
        ord_namespace = get_namespace(opts, msp=msp)
        version = get_version(opts, "hlf-ord")
        for release in get_orderers(opts=opts, msp=msp):
            # HL-Ord
            config_yaml = f'{opts["core"]["dir_values"]}/{msp}/hlf-ord/{release}.yaml'
            extra_vars = helm_extra_vars(version=version, config_yaml=config_yaml)
            if not upgrade:
                helm_install(
                    opts["core"]["chart_repo"],
                    "hlf-ord",
                    release,
                    ord_namespace,
                    extra_vars=extra_vars,
                )
            else:
                helm_upgrade(
                    opts["core"]["chart_repo"],
                    "hlf-ord",
                    release,
                    extra_vars=extra_vars,
                )
            helm_check("hlf-ord", release, ord_namespace)
            # Check that Orderer is running
            check_ord(ord_namespace, release)
Exemple #10
0
def ca_chart(opts, release, upgrade=False):
    """Deploy CA Helm chart to K8S.

    Args:
        opts (dict): Nephos options dict.
        release (str): Name of the Helm Chart release.
        upgrade (bool): Do we upgrade the deployment? False by default.
        
    """
    values_dir = opts["core"]["dir_values"]
    repository = opts["core"]["chart_repo"]
    ca_namespace = get_namespace(opts, ca=release)
    # PostgreSQL (Upgrades here are dangerous, deactivated by default)
    # Upgrading database is risky, so we disallow it by default
    if not upgrade:
        version = get_version(opts, "postgresql")
        config_yaml = f"{values_dir}/postgres-ca/{release}-pg.yaml"
        extra_vars = helm_extra_vars(version=version, config_yaml=config_yaml)
        helm_install("stable",
                     "postgresql",
                     f"{release}-pg",
                     ca_namespace,
                     extra_vars=extra_vars)
        helm_check("postgresql", f"{release}-pg", ca_namespace)
    psql_secret = secret_read(f"{release}-pg-postgresql", ca_namespace)
    # Different key depending of PostgreSQL version
    psql_password = (psql_secret.get("postgres-password")
                     or psql_secret["postgresql-password"])
    # Fabric CA
    version = get_version(opts, "hlf-ca")
    env_vars = [("externalDatabase.password", psql_password)]
    config_yaml = f"{values_dir}/hlf-ca/{release}.yaml"
    if not upgrade:
        extra_vars = helm_extra_vars(version=version,
                                     config_yaml=config_yaml,
                                     env_vars=env_vars)
        helm_install(repository,
                     "hlf-ca",
                     release,
                     ca_namespace,
                     extra_vars=extra_vars)
    else:
        preserve = (
            HelmPreserve(ca_namespace, f"{release}-hlf-ca--ca", "CA_ADMIN",
                         "adminUsername"),
            HelmPreserve(ca_namespace, f"{release}-hlf-ca--ca", "CA_PASSWORD",
                         "adminPassword"),
        )
        extra_vars = helm_extra_vars(
            version=version,
            config_yaml=config_yaml,
            env_vars=env_vars,
            preserve=preserve,
        )
        helm_upgrade(repository, "hlf-ca", release, extra_vars=extra_vars)
    helm_check("hlf-ca", release, ca_namespace)
Exemple #11
0
def deploy_composer(opts, upgrade=False, verbose=False):
    """Deploy Hyperledger Composer on K8S.

    We use the hl-composer Helm chart as a basis to deploying Composer
    on K8S. Please note that Composer is unmaintained and may eventually
    be deprecated from this repository as we migrate to raw Fabric.

    Args:
        opts (dict): Nephos options dict.
        upgrade (bool): Do we upgrade the deployment? False by default.
        verbose (bool): Verbosity. False by default.
    """
    peer_namespace = get_namespace(opts, opts["peers"]["msp"])
    # Ensure BNA exists
    secret_from_file(secret=opts["composer"]["secret_bna"],
                     namespace=peer_namespace,
                     verbose=verbose)
    composer_connection(opts, verbose=verbose)

    # Start Composer
    version = get_version(opts, "hl-composer")
    config_yaml = "{dir}/hl-composer/{release}.yaml".format(
        dir=opts["core"]["dir_values"], release=opts["composer"]["name"])
    if not upgrade:
        extra_vars = helm_extra_vars(version=version, config_yaml=config_yaml)
        helm_install(
            opts["core"]["chart_repo"],
            "hl-composer",
            opts["composer"]["name"],
            peer_namespace,
            extra_vars=extra_vars,
            verbose=verbose,
        )
    else:
        preserve = (HelmPreserve(
            peer_namespace,
            "{}-hl-composer-rest".format(opts["composer"]["name"]),
            "COMPOSER_APIKEY",
            "rest.config.apiKey",
        ), )
        extra_vars = helm_extra_vars(version=version,
                                     config_yaml=config_yaml,
                                     preserve=preserve)
        helm_upgrade(
            opts["core"]["chart_repo"],
            "hl-composer",
            opts["composer"]["name"],
            extra_vars=extra_vars,
            verbose=verbose,
        )
    helm_check("hl-composer",
               opts["composer"]["name"],
               peer_namespace,
               pod_num=3)
Exemple #12
0
 def test_helm_install(self, mock_execute):
     mock_execute.side_effect = [
         (None, "error"),  # Helm list
         ("Helm install", None),  # Helm install
     ]
     helm_install("a_repo", "an_app", "a-release", "a-namespace")
     mock_execute.assert_has_calls([
         call("helm status a-release"),
         call(
             "helm install a_repo/an_app -n a-release --namespace a-namespace"
         ),
     ])
Exemple #13
0
 def test_helm_install_again(self, mock_execute, mock_helm_check,
                             mock_helm_env_vars):
     mock_helm_env_vars.side_effect = ['']
     mock_execute.side_effect = [
         'a-release',  # Helm list
     ]
     helm_install('a_repo', 'an_app', 'a-release', 'a-namespace')
     mock_helm_env_vars.assert_called_once_with('a-namespace',
                                                None,
                                                verbose=False)
     mock_execute.assert_called_once_with('helm status a-release')
     mock_helm_check.assert_called_once_with('an_app', 'a-release',
                                             'a-namespace', 1)
Exemple #14
0
 def test_helm_install_extra(self, mock_execute):
     mock_execute.side_effect = [
         (None, "error"),  # Helm list
         ("Helm install", None),  # Helm install
     ]
     helm_install(
         "a_repo", "an_app", "a-release", "a-namespace", extra_vars=" EXTRA-VARS"
     )
     mock_execute.assert_has_calls(
         [
             call("helm status a-release"),
             call(
                 "helm install a_repo/an_app -n a-release "
                 + "--namespace a-namespace EXTRA-VARS",
                 verbose=False,
             ),
         ]
     )
Exemple #15
0
 def test_helm_install(self, mock_execute, mock_helm_check,
                       mock_helm_env_vars):
     mock_helm_env_vars.side_effect = ['']
     mock_execute.side_effect = [
         None,  # Helm list
         None,  # Helm install
     ]
     helm_install('a_repo', 'an_app', 'a-release', 'a-namespace')
     mock_helm_env_vars.assert_called_once_with('a-namespace',
                                                None,
                                                verbose=False)
     mock_execute.assert_has_calls([
         call('helm status a-release'),
         call(
             'helm install a_repo/an_app -n a-release --namespace a-namespace',
             verbose=False)
     ])
     mock_helm_check.assert_called_once_with('an_app', 'a-release',
                                             'a-namespace', 1)
Exemple #16
0
def deploy_composer(opts, upgrade=False, verbose=False):
    peer_namespace = get_namespace(opts, opts['peers']['msp'])
    # Ensure BNA exists
    secret_from_file(secret=opts['composer']['secret_bna'],
                     namespace=peer_namespace,
                     verbose=verbose)
    composer_connection(opts, verbose=verbose)

    # Start Composer
    if not upgrade:
        helm_install(opts['core']['chart_repo'],
                     'hl-composer',
                     opts['composer']['name'],
                     peer_namespace,
                     pod_num=3,
                     config_yaml='{dir}/hl-composer/{release}.yaml'.format(
                         dir=opts['core']['dir_values'],
                         release=opts['composer']['name']),
                     verbose=verbose)
    else:
        # TODO: Implement upgrade: set $CA_USERNAME and $CA_PASSWORD
        pass
Exemple #17
0
def ca_chart(opts, release, upgrade=False, verbose=False):
    """Deploy CA Helm chart to K8S.

    Args:
        opts (dict): Nephos options dict.
        release (str): Name of the Helm Chart release.
        upgrade (bool): Do we upgrade the deployment? False by default.
        verbose (bool): Verbosity. False by default.
    """
    values_dir = opts["core"]["dir_values"]
    repository = opts["core"]["chart_repo"]
    ca_namespace = get_namespace(opts, ca=release)
    # PostgreSQL (Upgrades here are dangerous, deactivated by default)
    helm_install(
        "stable",
        "postgresql",
        "{}-pg".format(release),
        ca_namespace,
        config_yaml="{dir}/postgres-ca/{name}-pg.yaml".format(dir=values_dir,
                                                              name=release),
        verbose=verbose,
    )
    psql_secret = secret_read("{}-pg-postgresql".format(release),
                              ca_namespace,
                              verbose=verbose)
    # Different key depending of PostgreSQL version
    psql_password = (psql_secret.get("postgres-password")
                     or psql_secret["postgresql-password"])
    env_vars = [("externalDatabase.password", psql_password)]
    # Fabric CA
    if not upgrade:
        helm_install(
            repository,
            "hlf-ca",
            release,
            ca_namespace,
            config_yaml="{dir}/hlf-ca/{name}.yaml".format(dir=values_dir,
                                                          name=release),
            env_vars=env_vars,
            verbose=verbose,
        )
    else:
        # TODO: Remove this try/catch once all CAs are updated
        try:
            preserve = (
                HelmPreserve("{}-hlf-ca".format(release), "CA_ADMIN",
                             "adminUsername"),
                HelmPreserve("{}-hlf-ca".format(release), "CA_PASSWORD",
                             "adminPassword"),
            )
            helm_upgrade(
                repository,
                "hlf-ca",
                release,
                ca_namespace,
                config_yaml="{dir}/hlf-ca/{name}.yaml".format(dir=values_dir,
                                                              name=release),
                env_vars=env_vars,
                preserve=preserve,
                verbose=verbose,
            )
        except:
            preserve = (
                HelmPreserve("{}-hlf-ca--ca".format(release), "CA_ADMIN",
                             "adminUsername"),
                HelmPreserve("{}-hlf-ca--ca".format(release), "CA_PASSWORD",
                             "adminPassword"),
            )
            helm_upgrade(
                repository,
                "hlf-ca",
                release,
                ca_namespace,
                config_yaml="{dir}/hlf-ca/{name}.yaml".format(dir=values_dir,
                                                              name=release),
                env_vars=env_vars,
                preserve=preserve,
                verbose=verbose,
            )
Exemple #18
0
def setup_peer(opts, upgrade=False, verbose=False):
    """Setup Peer on K8S.

    Args:
        opts (dict): Nephos options dict.
        upgrade (bool): Do we upgrade the deployment? False by default.
        verbose (bool): Verbosity. False by default.
    """
    peer_namespace = get_namespace(opts, opts["peers"]["msp"])
    for release in opts["peers"]["names"]:
        # Deploy the CouchDB instances
        version = get_version(opts, "hlf-couchdb")
        config_yaml = "{dir}/hlf-couchdb/cdb-{name}.yaml".format(
            dir=opts["core"]["dir_values"], name=release)
        if not upgrade:
            extra_vars = helm_extra_vars(version=version,
                                         config_yaml=config_yaml)
            helm_install(
                opts["core"]["chart_repo"],
                "hlf-couchdb",
                "cdb-{}".format(release),
                peer_namespace,
                extra_vars=extra_vars,
                verbose=verbose,
            )
        else:
            preserve = (
                HelmPreserve(
                    peer_namespace,
                    "cdb-{}-hlf-couchdb".format(release),
                    "COUCHDB_USERNAME",
                    "couchdbUsername",
                ),
                HelmPreserve(
                    peer_namespace,
                    "cdb-{}-hlf-couchdb".format(release),
                    "COUCHDB_PASSWORD",
                    "couchdbPassword",
                ),
            )
            extra_vars = helm_extra_vars(version=version,
                                         config_yaml=config_yaml,
                                         preserve=preserve)
            helm_upgrade(
                opts["core"]["chart_repo"],
                "hlf-couchdb",
                "cdb-{}".format(release),
                extra_vars=extra_vars,
                verbose=verbose,
            )
        helm_check("hlf-couchdb", "cdb-{}".format(release), peer_namespace)

        # Deploy the HL-Peer charts
        version = get_version(opts, "hlf-peer")
        config_yaml = "{dir}/hlf-peer/{name}.yaml".format(
            dir=opts["core"]["dir_values"], name=release)
        extra_vars = helm_extra_vars(version=version, config_yaml=config_yaml)
        if not upgrade:
            helm_install(
                opts["core"]["chart_repo"],
                "hlf-peer",
                release,
                peer_namespace,
                extra_vars=extra_vars,
                verbose=verbose,
            )
        else:
            helm_upgrade(
                opts["core"]["chart_repo"],
                "hlf-peer",
                release,
                extra_vars=extra_vars,
                verbose=verbose,
            )
        helm_check("hlf-peer", release, peer_namespace)
        # Check that peer is running
        check_peer(peer_namespace, release, verbose=verbose)
Exemple #19
0
def setup_peer(opts, upgrade=False):
    """Setup Peer on K8S.

    Args:
        opts (dict): Nephos options dict.
        upgrade (bool): Do we upgrade the deployment? False by default.
        
    """
    for msp in get_msps(opts=opts):
        peer_namespace = get_namespace(opts, msp=msp)
        for release in get_peers(opts=opts, msp=msp):
            # Deploy the CouchDB instances
            version = get_version(opts, "hlf-couchdb")
            config_yaml = (
                f'{opts["core"]["dir_values"]}/{msp}/hlf-couchdb/cdb-{release}.yaml'
            )
            if not upgrade:
                extra_vars = helm_extra_vars(version=version,
                                             config_yaml=config_yaml)
                helm_install(
                    opts["core"]["chart_repo"],
                    "hlf-couchdb",
                    f"cdb-{release}",
                    peer_namespace,
                    extra_vars=extra_vars,
                )
            else:
                preserve = (
                    HelmPreserve(
                        peer_namespace,
                        f"cdb-{release}-hlf-couchdb",
                        "COUCHDB_USERNAME",
                        "couchdbUsername",
                    ),
                    HelmPreserve(
                        peer_namespace,
                        f"cdb-{release}-hlf-couchdb",
                        "COUCHDB_PASSWORD",
                        "couchdbPassword",
                    ),
                )
                extra_vars = helm_extra_vars(version=version,
                                             config_yaml=config_yaml,
                                             preserve=preserve)
                helm_upgrade(
                    opts["core"]["chart_repo"],
                    "hlf-couchdb",
                    f"cdb-{release}",
                    extra_vars=extra_vars,
                )
            helm_check("hlf-couchdb", f"cdb-{release}", peer_namespace)

            # Deploy the HL-Peer charts
            version = get_version(opts, "hlf-peer")
            config_yaml = f"{opts['core']['dir_values']}/{msp}/hlf-peer/{release}.yaml"
            extra_vars = helm_extra_vars(version=version,
                                         config_yaml=config_yaml)
            if not upgrade:
                helm_install(
                    opts["core"]["chart_repo"],
                    "hlf-peer",
                    release,
                    peer_namespace,
                    extra_vars=extra_vars,
                )
            else:
                helm_upgrade(
                    opts["core"]["chart_repo"],
                    "hlf-peer",
                    release,
                    extra_vars=extra_vars,
                )
            helm_check("hlf-peer", release, peer_namespace)
            # Check that peer is running
            check_peer(peer_namespace, release)