-
Notifications
You must be signed in to change notification settings - Fork 0
AiMLops Project 3.2 Automation Script
This document describes a set of shell scripts designed to automate the setup of a local development environment for the MLOps platform, primarily focusing on creating a Kubernetes cluster using Kind, configuring networking, and setting up automated SSL/TLS certificate management using cert-manager.
These scripts handle user configuration, hostname detection, cluster creation, and SSL provider setup (Let's Encrypt or ZeroSSL).
Before running these scripts, ensure the following tools are installed on your system:
- Docker: Required by Kind to run Kubernetes nodes as containers.
- Kind (Kubernetes in Docker): The tool used to create the local Kubernetes cluster.
- kubectl: The Kubernetes command-line tool for interacting with the cluster.
-
curl: Used by
Finding_Hostname.shto detect the public IP address. -
dig: Used by
Finding_Hostname.shfor reverse DNS lookups. (Installed automatically by the script if missing and usingaptoryum).
Several scripts read from and write to configuration files, primarily config.env located in the root directory relative to the scripts, and component-specific config.env files within the deployment directories. Key variables include:
-
INSTALL_TYPE: Set tolocalorcloud. Determines if cloud-specific SSL configuration is needed. -
SSL_PROVIDER: Set toletsencryptorzerossl. Specifies the certificate authority. -
EMAIL: The email address used for SSL certificate registration and notifications. -
ZEROSSL_EAB_HMAC_KEY: ZeroSSL External Account Binding (EAB) HMAC Key (if using ZeroSSL). -
ZEROSSL_ACCESS_KEY_ID: ZeroSSL EAB Key ID (if using ZeroSSL). -
DOMAIN: The detected public hostname or IP address, used for accessing services and configuring SSL certificates. -
HOST_IP: (Environment Variable forcreate_cluster.sh) The IP address the Kind API server should bind to. -
CLUSTER_NAME: (Environment Variable forcreate_cluster.sh) The name for the Kind cluster. -
INSTALL_LOCAL_REGISTRY: (Environment Variable forcreate_cluster.sh, booleantrue/false) Whether to configure the Kind cluster to use a local registry mirror.
- Purpose: Gathers essential configuration details from the user regarding the installation environment and SSL preferences. Orchestrates configuration file updates and triggers hostname detection.
-
Functionality:
- Prompts the user for
INSTALL_TYPE(localorcloud). - If
local, updatesconfig.envand exits. - If
cloud:- Prompts for
SSL_PROVIDER(Let's Encrypt [default] or ZeroSSL). - If ZeroSSL, prompts for EAB credentials (
ZEROSSL_EAB_HMAC_KEY,ZEROSSL_ACCESS_KEY_ID). - Prompts for a valid
EMAILaddress. - Uses the
update_config_varfunction to create/update variables in the mainconfig.envand component-specificconfig.envfiles (Cert-manager, MLflow, Kubeflow Pipelines, Grafana, Prometheus). - Executes
Finding_Hostname.shto detect the domain/IP and propagate it.
- Prompts for
- Prompts the user for
-
Key Function:
update_config_var: Safely adds or updates key-value pairs in specified configuration files, creating directories and files if they don't exist.
- Purpose: Automatically detects the public IP address and corresponding hostname (if available) of the machine where the script is run and updates configuration files.
-
Functionality:
- Ensures
curlanddigcommands are available, installing them viaaptoryumif necessary (ensure_tool_installedfunction). - Uses
curl -s ifconfig.meto retrieve the public IP address. - Performs a reverse DNS lookup (
dig +short -x <IP_ADDRESS>) to find the hostname. - If no hostname is found via reverse DNS, it defaults to using the detected IP address as the
DOMAIN. - Reads
SSL_PROVIDERfromconfig.envto determine the correct path for the cert-manager overlay configuration. - Uses the
update_config_varfunction (defined within this script) to update theDOMAINvariable in various component configuration files.
- Ensures
-
Purpose: Installs and configures
cert-managerwithin the created Kubernetes cluster to handle automated SSL certificate provisioning based on the choices made duringSSL_Details.sh. -
Functionality:
- Sources configuration from
.platform/.config(expected to be a copy ofconfig.env). - Validates that
INSTALL_TYPE(andSSL_PROVIDERifcloud) are set. - Performs a cleanup of any existing
cert-managerresources (Deployments, Services, Secrets, Namespace, CRDs, Webhooks) usingkubectl delete. - Installs
cert-managerv1.12.0 CRDs. - Applies
cert-managerbase manifests usingkubectl apply -k. - Temporarily deletes the
cert-managervalidating and mutating webhooks to allowClusterIssuerresources to be created before the webhook service is fully ready. - Waits for the
cert-manager-webhookdeployment to become available. - If
INSTALL_TYPEiscloud:- Applies the appropriate
ClusterIssuerand related resources based on the selectedSSL_PROVIDER(Let's Encrypt or ZeroSSL) usingkubectl apply -kon the corresponding overlay directory (deployment/kubeflow/manifests/common/cert-manager/cert-manager/overlay/$SSL_PROVIDER). It includes logic to apply individual files first and retry the kustomization apply if needed. - Re-applies the base manifests to ensure webhooks are correctly configured.
- Waits and re-applies the overlay manifests again to ensure resources are reconciled with webhooks fully active.
- Prints the status of
ClusterIssuersandCertificates.
- Applies the appropriate
- If
INSTALL_TYPEislocal, it skips the SSL provider-specific configuration steps.
- Sources configuration from
A typical execution flow would involve running SSL_Details.sh first.
-
SSL_Details.sh: Gathers user input, updates config files. Ifcloudis selected, it calls: -
Finding_Hostname.sh: Detects public address, updates config files with theDOMAIN. -
create_cluster.sh: (Run separately, likely requiresHOST_IPandCLUSTER_NAMEenv vars) Creates the Kind cluster. -
SSL_Creation.sh: (Run after cluster creation) Installs cert-manager and configures the SSL issuer based on previously saved settings.
The result is a Kind cluster ready with automated HTTPS certificate management for deployed services accessible via the determined DOMAIN.