Пример #1
0
def initialize(log_kwargs=None, interactive=False):
    log_kwargs = log_kwargs or {}
    logs.info(f'Installing crds', **log_kwargs)
    crds_manager.install_crd(CRD_SINGULAR,
                             CRD_PLURAL,
                             CRD_KIND,
                             hash_names=True)
    ckan_infra = CkanInfra(required=False)
    if interactive:
        providers_manager.config_interactive_set(
            PROVIDER_SUBMODULE,
            default_values={
                'gcloud-storage-import-bucket':
                ckan_infra.GCLOUD_SQL_DEIS_IMPORT_BUCKET
            },
            suffix='deis-migration')
    else:
        if not providers_manager.config_get(PROVIDER_SUBMODULE,
                                            key='gcloud-storage-import-bucket',
                                            suffix='deis-migration',
                                            required=False):
            providers_manager.config_set(
                PROVIDER_SUBMODULE,
                values={
                    'gcloud-storage-import-bucket':
                    ckan_infra.GCLOUD_SQL_DEIS_IMPORT_BUCKET
                },
                suffix='deis-migration')
Пример #2
0
def initialize(default_provider=None, interactive=False):
    crds_manager.install_crd(CRD_SINGULAR, CRD_PLURAL, CRD_KIND)
    if not default_provider:
        default_provider = 'gcloud' if cluster_manager.get_provider_id(
        ) == 'gcloud' else 'rancher'
    providers_manager.get_provider(
        users_provider_submodule, required=False,
        default=default_provider).initialize(interactive=interactive)
Пример #3
0
def initialize(interactive=False):
    ckan_db_migration_manager.initialize(interactive=interactive)
    if config_manager.get('enable-deis-ckan',
                          configmap_name='global-ckan-config') == 'y':
        ckan_infra = CkanInfra(required=False)
        config_manager.interactive_set(
            {
                'deis-kubeconfig': ckan_infra.DEIS_KUBECONFIG,
            },
            from_file=True,
            secret_name='ckan-migration-secrets',
            interactive=interactive)
        config_manager.interactive_set(
            {
                'gitlab-token': ckan_infra.GITLAB_TOKEN_PASSWORD,
            },
            secret_name='ckan-migration-secrets',
            interactive=interactive)
        config_manager.interactive_set(
            {
                'docker-server': ckan_infra.DOCKER_REGISTRY_SERVER,
                'docker-username': ckan_infra.DOCKER_REGISTRY_USERNAME,
                'docker-password': ckan_infra.DOCKER_REGISTRY_PASSWORD,
                'docker-email': ckan_infra.DOCKER_REGISTRY_EMAIL,
            },
            secret_name='ckan-docker-registry',
            interactive=interactive)
    crds_manager.install_crd(INSTANCE_CRD_SINGULAR, INSTANCE_CRD_PLURAL_SUFFIX,
                             INSTANCE_CRD_KIND_SUFFIX)
    crds_manager.install_crd(INSTANCE_NAME_CRD_SINGULAR,
                             INSTANCE_NAME_CRD_PLURAL_SUFFIX,
                             INSTANCE_NAME_CRD_KIND_SUFFIX)

    if config_manager.get('disable-centralized-datapushers',
                          configmap_name='global-ckan-config',
                          required=False) != 'yes':
        from ckan_cloud_operator.datapushers import initialize as datapusher_initialize
        datapusher_initialize()

    from ckan_cloud_operator.routers import manager as routers_manager
    router_name = get_default_instances_router_name()
    wildcard_ssl_domain = routers_manager.get_default_root_domain()
    print(f'wildcard_ssl_domain={wildcard_ssl_domain}')
    allow_wildcard_ssl = routers_manager.get_env_id() == 'p'
    router = routers_manager.get(router_name, required=False)
    if router:
        assert ((allow_wildcard_ssl and router.get(
            'spec', {}).get('wildcard-ssl-domain') == wildcard_ssl_domain)
                or (not allow_wildcard_ssl and not router.get('spec', {}))
                ), f'invalid router wildcard ssl config: {router}'
    else:
        routers_manager.create(
            router_name,
            routers_manager.get_traefik_router_spec(
                wildcard_ssl_domain=wildcard_ssl_domain))

    from .storage.manager import initialize as ckan_storage_initialize
    ckan_storage_initialize(interactive=interactive)
Пример #4
0
def persist(cluster_id):
    cluster = get_cluster(cluster_id)
    cluster_secrets = {'servers': {}}
    for server in cluster['servers']:
        cluster_secrets['servers'][server['name']] = server_secrets = {}
        with open(server['passwordfile']) as f:
            server_secrets['password'] = f.read()
        with open(server['keyfile']) as f:
            server_secrets['private_key'] = f.read()
        with open(server['keyfile'] + '.pub') as f:
            server_secrets['public_key'] = f.read()
    crds_manager.install_crd('kamateracluster', 'kamateraclusters',
                             'KamateraCluster')
    crds_manager.install_crd('kamateraserver', 'kamateraservers',
                             'KamateraServer')
    kubectl.apply(
        crds_manager.
        get_resource('kamateracluster',
                     cluster['id'],
                     spec={
                         **{
                             k: v
                             for k, v in cluster.items() if k != 'servers'
                         }, 'server_names':
                         [server['name'] for server in cluster['servers']]
                     }))
    for server in cluster['servers']:
        kubectl.apply(
            crds_manager.get_resource('kamateraserver',
                                      f'{server["name"]}',
                                      spec=server))
        crds_manager.config_set(
            'kamateraserver',
            server["name"],
            values=cluster_secrets['servers'][server['name']],
            is_secret=True)
    with open(f'{get_cluster_path(cluster_id)}/kube_config_rke-cluster.yml'
              ) as f:
        crds_manager.config_set(
            'kamateracluster',
            cluster_id,
            values={'kube_config_rke-cluster.yml': f.read()},
            is_secret=True)
Пример #5
0
def initialize(interactive=False):
    crds_manager.install_crd(APP_CRD_SINGULAR, APP_CRD_PLURAL_SUFFIX,
                             APP_CRD_KIND_SUFFIX)
    crds_manager.install_crd(APP_NAME_CRD_SINGULAR, APP_NAME_CRD_PLURAL_SUFFIX,
                             APP_NAME_CRD_KIND_SUFFIX)
Пример #6
0
def initialize(interactive=False):
    ckan_db_migration_manager.initialize(interactive=interactive)
    if config_manager.get('enable-deis-ckan',
                          configmap_name='global-ckan-config') == 'y':
        ckan_infra = CkanInfra(required=False)
        config_manager.interactive_set(
            {
                'deis-kubeconfig': ckan_infra.DEIS_KUBECONFIG,
            },
            from_file=True,
            secret_name='ckan-migration-secrets',
            interactive=interactive)
        config_manager.interactive_set(
            {
                'gitlab-token': ckan_infra.GITLAB_TOKEN_PASSWORD,
            },
            secret_name='ckan-migration-secrets',
            interactive=interactive)
        config_manager.interactive_set(
            {
                'docker-server': ckan_infra.DOCKER_REGISTRY_SERVER,
                'docker-username': ckan_infra.DOCKER_REGISTRY_USERNAME,
                'docker-password': ckan_infra.DOCKER_REGISTRY_PASSWORD,
                'docker-email': ckan_infra.DOCKER_REGISTRY_EMAIL,
            },
            secret_name='ckan-docker-registry',
            interactive=interactive)
    crds_manager.install_crd(INSTANCE_CRD_SINGULAR, INSTANCE_CRD_PLURAL_SUFFIX,
                             INSTANCE_CRD_KIND_SUFFIX)
    crds_manager.install_crd(INSTANCE_NAME_CRD_SINGULAR,
                             INSTANCE_NAME_CRD_PLURAL_SUFFIX,
                             INSTANCE_NAME_CRD_KIND_SUFFIX)

    from ckan_cloud_operator.providers.solr.manager import zk_list_configs, zk_put_configs
    print('Checking CKAN Solr config in ZooKeeper')
    if 'ckan_default' in zk_list_configs():
        print('Found ckan_default Solr config')
    else:
        print(
            'No default Solr config found. Putting CKAN 2.8 config for Solr to ZooKeeper as ckan_default...'
        )
        file_path = os.path.dirname(os.path.abspath(__file__))
        root_path = Path(file_path).parent.parent
        configs_dir = os.path.join(root_path, 'data', 'solr')
        zk_put_configs(configs_dir)

    if config_manager.get('disable-centralized-datapushers',
                          configmap_name='global-ckan-config',
                          required=False) != 'yes':
        from ckan_cloud_operator.datapushers import initialize as datapusher_initialize
        datapusher_initialize()

    from ckan_cloud_operator.routers import manager as routers_manager
    router_name = get_default_instances_router_name()
    wildcard_ssl_domain = routers_manager.get_default_root_domain()
    print(f'wildcard_ssl_domain={wildcard_ssl_domain}')
    allow_wildcard_ssl = routers_manager.get_env_id() == 'p'
    router = routers_manager.get(router_name, required=False)
    if router:
        assert ((allow_wildcard_ssl and router.get(
            'spec', {}).get('wildcard-ssl-domain') == wildcard_ssl_domain)
                or (not allow_wildcard_ssl and not router.get('spec', {}))
                ), f'invalid router wildcard ssl config: {router}'
    else:
        routers_manager.create(
            router_name,
            routers_manager.get_traefik_router_spec(
                wildcard_ssl_domain=wildcard_ssl_domain))

    from .storage.manager import initialize as ckan_storage_initialize
    ckan_storage_initialize(interactive=interactive)

    from .deployment.manager import initialize as ckan_deployment_initialize
    ckan_deployment_initialize(interactive=interactive)
Пример #7
0
def initialize(default_provider='gcloud'):
    crds_manager.install_crd(CRD_SINGULAR, CRD_PLURAL, CRD_KIND)
    providers_manager.get_provider(users_provider_submodule, required=False, default=default_provider).initialize()