Install via kubectl

Describes the detailed steps to install the cloud-native cluster optimization platform (Cluster Optimizer) through kubectl.

This page describes the detailed steps to install the one-stop cloud native cluster optimization platform (Cluster Optimizer).

Preconditions

  • MySQL database, version 5.7 or higher
  • Kubernetes cluster, version 1.22 or higher
  • Kubernetes cluster with the necessary permissions to create the wiseinf-system namespace and deploy resources such as Deployments, ConfigMaps, and Services within this namespace

Preparing installation script

To clone the installation script to your local computer, follow these steps:

  1. Open the command line console.

  2. Navigate to the directory where you want to save the script:

    cd /path/to/your/directory
    
  3. Clone the repository containing the installation script using the following command:

        git clone https://github.com/wiseinf/setup.git
    

    After executing the git clone command, the repository will be cloned to your local machine in a new directory with the same name as the repository.

    Note: The following instructions are predicated on the assumption that the setup library has been successfully cloned into the user’s home directory. Should the setup library reside elsewhere, please adjust the file path in the subsequent commands to reflect its actual location.

Deploy Cluster Optimizer

  1. Create wiseinf-system namespace using the following command:

        kubectl apply -f ~/setup/cluster-optimizer/yaml/namespace.yaml
    
  2. Create optimizer-mysql database using the following command, its service name is optimizer-mysql, and can be accessed through the user name root and the password Optimizer~:

        kubectl apply -f ~/setup/cluster-optimizer/yaml/mysql.yaml
    

    If you need to bind the database to the specified node, please edit the ~/setup/cluster-optimizer/yaml/mysql.yaml file, remove the comments in the affinity field, and modify the value of the value field to Specify the node name as shown below.

      ...
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - ip-10-16-121-100.us-west-1.compute.internal
      ...
    
  3. Create optimizer deployment using the following command:

        kubectl apply -f ~/setup/cluster-optimizer/yaml/optimizer.yaml
    

    Note: For instructions on utilizing a deployed database, please refer to the section Using a Deployed Database.

  4. Check whether optimizer is running normally using the following command:

        kubectl get pods -n wiseinf-system
    

    If it runs normally, you can get output similar to the following, in which the currently running Pod Name is optimizer-5b956655df-gspq6:

        NAME READY STATUS RESTARTS AGE
        optimizer-5b956655df-gspq6 2/2 Running 0 1m
    
  5. Create a port-forward to access the optimizer service using the following command:

        kubectl port-forward svc/optimizer 8000:80 -n wiseinf-system
    
  6. Open your web browser and navigate to the address http://localhost:8000/.

  7. If the Cluster Optimizer homepage is displayed, this indicates that the Cluster Optimizer application has been deployed successfully.

  8. To delete the Cluster Optimizer, execute the following command:

        kubectl delete -f ~/setup/cluster-optimizer/yaml/optimizer.yaml
    

Using a deployed database

If you want to use the deployed user database with a new username and password for accessing from the Cluster Optimizer, follow these steps:

  1. Open your command line interface and use the mysql command to connect to the MySQL database. Replace 127.0.0.1 with your actual MySQL database host address.

        mysql -h127.0.0.1 -uroot
    

    Note: Ensure that the database is accessible from the Kubernetes cluster if you are using a remote database.

  2. Create the optconf and optdata database schema.

         mysql> source ~/setup/cluster-optimizer/sql/create_database.sql
    

    Note: This script will delete the existing user database if it exists and create a new one. Proceed with caution to avoid data loss.

  3. Create a new username and password, and assign the appropriate permissions. The default username and password in the script are optimizer and Optimizer~, respectively. Adjust these as needed.

       mysql> source ~/setup/cluster-optimizer/sql/create_user.sql
    
  4. Update the Cluster Optimizer configuration file with the new database details. Edit the ConfigMap optimizer-conf within ~/setup/cluster-optimizer/yaml/optimizer.yaml, and modify the dataSource.name value under the user configuration item with the new username, password, database address, and port.

  5. Restart the application and review the log output of Cluster Optimizer to verify that the database configuration matches your expectations.

    {
        ...
        "optconf": {
            "dataSource": {
                "name": "optimizer:Optimizer~@tcp(127.0.0.1:3306)/optconf?createDatabaseIfNotExist=true\u0026charset=utf8mb4\u0026parseTime=true\u0026loc=Local",
                "maxOpenConns": 10
            }
        },
        "optdata": {
            "dataSource": {
                "name": "optimizer:Optimizer~@tcp(127.0.0.1:3306)/optdata?createDatabaseIfNotExist=true\u0026charset=utf8mb4\u0026parseTime=true\u0026loc=Local",
                "maxOpenConns": 10
            }
        },
        ...
    }
    

    Additionally, check for any database-related errors in the logs. The absence of errors indicates that the new database configuration is successfully applied.

Next step: Import the cluster

Next, you can add a cluster and view its related optimization recommendations. For details, see: