MAIA.maia_admin module#

MAIA.maia_admin.create_filebrowser_values(namespace_config, cluster_config, config_folder, mlflow_configs=None, mount_cifs=True)[source]#

Create and write configuration values for deploying the MAIA Filebrowser Helm chart. This function generates a dictionary of configuration values required to deploy the MAIA Filebrowser application in a Kubernetes namespace. It handles image configuration, environment variables, volume mounts, CIFS volume setup, and ingress settings for both NGINX and Traefik ingress controllers. The resulting configuration is written to a YAML file in the specified config folder.

Parameters:
  • namespace_config (dict) – Dictionary containing namespace-specific configuration, including group ID, subdomain, and users.

  • cluster_config (dict) – Dictionary containing cluster-specific configuration, such as docker server, image pull secrets, domain, and optional ingress settings.

  • config_folder (str or Path) – Path to the folder where the generated configuration YAML file will be saved.

  • mlflow_configs (dict, optional) – Optional dictionary containing MLflow configuration, specifically the base64-encoded ‘mlflow_password’. If not provided, a new human-memorable password is generated.

Returns:

dict

A dictionary containing:
  • ’namespace’: The Kubernetes namespace for deployment.

  • ’release’: The Helm release name.

  • ’chart’: The Helm chart name.

  • ’repo’: The Helm chart repository URL.

  • ’version’: The Helm chart version.

  • ’values’: Path to the generated YAML values file.

Notes

  • The function expects certain helper functions and environment variables to be available, such as generate_human_memorable_password, convert_username_to_jupyterhub_username, and OmegaConf.

  • The CIFS server address is read from the ‘CIFS_SERVER’ environment variable.

MAIA.maia_admin.create_harbor_values(config_folder, project_id, cluster_config_dict)[source]#

Create and save Harbor values configuration for a given project and cluster configuration.

Parameters:
  • config_folder (str) – The path to the configuration folder where the Harbor values file will be saved.

  • project_id (str) – The unique identifier for the project.

  • cluster_config_dict (dict) –

    A dictionary containing cluster configuration details, including:
    • domain (str): The domain name for the Harbor registry.

    • ingress_class (str): The ingress class to be used (e.g., “maia-core-traefik”, “nginx”).

    • traefik_resolver (str, optional): The Traefik resolver to be used if ingress_class is “maia-core-traefik”.

Returns:

dict – A dictionary containing the following keys: - namespace (str): The Kubernetes namespace for Harbor. - release (str): The release name for the Harbor Helm chart. - chart (str): The name of the Harbor Helm chart. - repo (str): The URL of the Harbor Helm chart repository. - version (str): The version of the Harbor Helm chart. - values (str): The path to the generated Harbor values YAML file.

MAIA.maia_admin.create_keycloak_values(config_folder, project_id, cluster_config_dict)[source]#

Generates Keycloak Helm chart values and writes them to a YAML file.

Parameters:
  • config_folder (str) – The path to the configuration folder where the YAML file will be saved.

  • project_id (str) – The project identifier used to create a unique namespace and release name.

  • cluster_config_dict (dict) – A dictionary containing cluster configuration details such as domain, ingress class, and traefik resolver.

Returns:

dict – A dictionary containing the namespace, release name, chart name, repository URL, chart version, and the path to the generated values YAML file.

MAIA.maia_admin.create_loginapp_values(config_folder, project_id, cluster_config_dict)[source]#

Creates and writes the loginapp values configuration file for a given project and cluster configuration.

Parameters:
  • config_folder (str) – The base directory where the configuration files will be stored.

  • project_id (str) – The unique identifier for the project.

  • cluster_config_dict (dict) –

    A dictionary containing cluster configuration details, including:
    • keycloak.client_secret (str): The client secret for Keycloak.

    • domain (str): The domain name for the cluster.

    • ingress_class (str): The ingress class to be used (e.g., “maia-core-traefik” or “nginx”).

    • traefik_resolver (str, optional): The Traefik resolver to be used if ingress_class is “maia-core-traefik”.

Returns:

dict – A dictionary containing the namespace, release name, chart name, repository URL, chart version, and the path to the generated values file.

Raises:
  • KeyError – If required keys are missing from the cluster_config_dict.

  • OSError – If there is an error creating directories or writing the configuration file.

MAIA.maia_admin.create_maia_admin_toolkit_values(config_folder, project_id, cluster_config_dict)[source]#

Creates and writes the MAIA admin toolkit values to a YAML file.

Parameters:
  • config_folder (str) – The path to the configuration folder.

  • project_id (str) – The project identifier.

  • cluster_config_dict (dict) – Dictionary containing cluster configuration values.

Returns:

dict – A dictionary containing the namespace, release name, chart name, repository URL, chart version, and the path to the generated values YAML file.

MAIA.maia_admin.create_maia_dashboard_values(config_folder, project_id, cluster_config_dict)[source]#

Create MAIA dashboard values for Helm chart deployment.

Parameters:
  • config_folder (str) – The path to the configuration folder.

  • project_id (str) – The project identifier.

  • cluster_config_dict (dict) – Dictionary containing cluster configuration details.

Returns:

dict – A dictionary containing the namespace, release name, chart name, repository URL, chart version, and the path to the generated values YAML file.

MAIA.maia_admin.create_maia_namespace_values(namespace_config, cluster_config, config_folder, minio_configs=None, mlflow_configs=None)[source]#

Create MAIA namespace values for deployment.

Parameters:
  • namespace_config (dict) – Configuration for the namespace, including group ID and users.

  • cluster_config (dict) – Configuration for the cluster, including SSH port type, port range, and storage class.

  • config_folder (str) – Path to the folder where configuration files will be saved.

  • minio_configs (dict, optional) – Configuration for MinIO, including access keys and console keys. Defaults to None.

  • mlflow_configs (dict, optional) – Configuration for MLflow, including user and password. Defaults to None.

Returns:

dict – A dictionary containing the namespace, release name, chart name, repository URL, chart version, and the path to the generated values file.

MAIA.maia_admin.create_minio_operator_values(config_folder, project_id)[source]#

Creates and writes MinIO operator values to a YAML file and returns a dictionary with deployment details.

Parameters:
  • config_folder (str) – The path to the configuration folder.

  • project_id (str) – The unique identifier for the project.

Returns:

dict – A dictionary containing the namespace, release name, chart name, repository URL, chart version, and the path to the generated YAML values file.

MAIA.maia_admin.generate_minio_configs(namespace)[source]#

Generate configuration settings for MinIO.

Parameters:

namespace (int or str) – The unique identifier for the project.

Returns:

dict – A dictionary with the following keys: - access_key (str): The access key for MinIO. - secret_key (str): A randomly generated secret key for MinIO. - console_access_key (str): A base64 encoded access key for console access. - console_secret_key (str): A base64 encoded secret key for console access.

MAIA.maia_admin.generate_mlflow_configs(namespace)[source]#

Generate MLflow configuration dictionary with encoded user and password.

Parameters:

namespace (str) – The namespace to be encoded as the MLflow user.

Returns:

dict – A dictionary containing the encoded MLflow user and password.

MAIA.maia_admin.generate_mysql_configs(namespace)[source]#

Generate MySQL configuration dictionary.

Parameters:

namespace (str) – The namespace to be used as the MySQL user.

Returns:

dict – A dictionary containing MySQL user and password.

MAIA.maia_admin.get_maia_toolkit_apps(group_id, password, argo_cd_host)[source]#

Retrieve and print information about a specific project and its associated applications from Argo CD.

Parameters:
  • group_id (str) – The group identifier used to construct project and application names.

  • password (str) – The authorization token for accessing the Argo CD API.

  • argo_cd_host (str) – The host URL of the Argo CD server.

Returns:

list – A list of dictionaries containing the name and version of each application. Each dictionary has the following keys: - name (str): The name of the application. - version (str): The version of the application.

Example

apps = get_maia_toolkit_apps(“maia-core”, “password”, “http://localhost:8080”) logger.info(f”Apps: {apps}”)

MAIA.maia_admin.get_minio_config_if_exists(project_id)[source]#

Retrieves MinIO configuration if it exists for the given project ID. This function loads the Kubernetes configuration from the environment, accesses the Kubernetes API to list secrets in the specified namespace, and extracts MinIO-related configuration from the secrets.

Parameters:

project_id (str) – The ID of the project for which to retrieve the MinIO configuration.

Returns:

dict – A dictionary containing MinIO configuration keys and their corresponding values. The dictionary may contain the following keys: - “access_key”: The default access key (always “admin”). - “console_access_key”: The console access key, if found. - “console_secret_key”: The console secret key, if found. - “secret_key”: The MinIO root password, if found.

MAIA.maia_admin.get_mlflow_config_if_exists(project_id)[source]#

Retrieve MLflow configuration from Kubernetes secrets if they exist.

Parameters:

project_id (str) – The ID of the project for which to retrieve the MLflow configuration. This ID is used to locate the corresponding Kubernetes namespace and secrets.

Returns:

dict – A dictionary containing the MLflow configuration with keys “mlflow_user” and “mlflow_password” if they exist in the Kubernetes secrets. If the secrets are not found, an empty dictionary is returned.

Raises:
  • KeyError – If the “KUBECONFIG” environment variable is not set.

  • yaml.YAMLError – If there is an error parsing the Kubernetes configuration file.

  • kubernetes.client.exceptions.ApiException – If there is an error communicating with the Kubernetes API.

MAIA.maia_admin.get_mysql_config_if_exists(project_id)[source]#

Retrieves MySQL configuration from Kubernetes environment variables if they exist.

Parameters:

project_id (str) – The ID of the project for which to retrieve the MySQL configuration. This ID is used to identify the namespace and the MySQL deployment within the Kubernetes cluster.

Returns:

dict – A dictionary containing the MySQL user and password if they exist in the environment variables of the MySQL deployment. The dictionary keys are: - “mysql_user”: The MySQL user. - “mysql_password”: The MySQL password.

Notes

This function assumes that the Kubernetes configuration file is specified in the environment variable “KUBECONFIG” and that the MySQL deployment name starts with the project ID followed by “-mysql-mkg”.

async MAIA.maia_admin.install_maia_project(group_id, values_file, argo_cd_namespace, project_chart, project_repo=None, project_version=None, json_key_path=None)[source]#

Installs or upgrades a MAIA project using the specified Helm chart and values file.

Parameters:
  • group_id (str) – The group ID for the project. This will be used as the release name.

  • values_file (str) – Path to the YAML file containing the values for the Helm chart.

  • argo_cd_namespace (str) – The namespace in which to install the project.

  • project_chart (str) – The name of the Helm chart to use for the project.

  • project_repo (str, optional) – The repository URL where the Helm chart is located. Defaults to None.

  • project_version (str, optional) – The version of the Helm chart to use. Defaults to None.

  • json_key_path (str, optional) – Path to the JSON key file for authentication with the Helm registry. Defaults to None.

Returns:

None

Raises:
  • FileNotFoundError – If the values file does not exist.

  • yaml.YAMLError – If there is an error parsing the values file.

  • Exception – If there is an error during the installation or upgrade process.