Install via Helm
Categories:
This document provides detailed instructions for installing the Cluster Optimizer with Helm.
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-systemnamespace and deploy resources such as Deployments, ConfigMaps, and Services within this namespace - Helm, version 3.0.0 or higher
 
Deploy application
- 
Add the
cluster-optimizerHelm repository using the following command:helm repo add cluster-optimizer https://wiseinf.github.io/cluster-optimizer/ - 
Update the repository using the following command:
helm repo update - 
View the charts available in the
cluster-optimizerrepository using the following command:helm search repo cluster-optimizerThe output is as follows:
NAME CHART VERSION APP VERSION DESCRIPTION cluster-optimizer/cluster-optimizer 0.1.0 1.1.0 A Helm chart for cluster optimizerThe repository includes a chart named
cluster-optimizer/cluster-optimizer. - 
Install the
demochart using the following command:helm install demo cluster-optimizer/cluster-optimizer -n wiseinf-system --create-namespaceIn this command,
-n wiseinf-systemspecifies that thedemochart will be installed in thewiseinf-systemnamespace, while the--create-namespaceflag ensures that the namespace is created if it does not already exist. The output is as follows:NAME: demo LAST DEPLOYED: Thu Mar 28 15:54:42 2024 NAMESPACE: default STATUS: deployed REVISION: 1 ...It indicates that Helm has successfully deployed the
demochart. - 
Check whether the
optimizerpod is running normally through the following command:kubectl get pods -n wiseinf-systemThe output is as follows:
NAME READY STATUS RESTARTS AGE cluster-optimizer-demo-7bfdfdf954-2cgqb 2/2 Running 0 108s cluster-optimizer-demo-optimizerdb-5d6cdb6b9f-94lc7 1/1 Running 0 108sAs the output indicates, Helm has successfully deployed two pods. The first is the
cluster-optimizer-demo-7bfdfdf954-2cgqbpod, which represents the Cluster Optimizer service. The second is thecluster-optimizer-demo-optimizerdb-5d6cdb6b9f-94lc7pod, which serves as the MySQL database upon which the first pod depends.Note: For instructions on utilizing a deployed database, please refer to the section Using a Deployed Database.
 - 
Create a port-forward to access the
optimizerservice using the following command:kubectl port-forward svc/optimizer 8000:80 -n wiseinf-system - 
Open your web browser and navigate to the address
http://localhost:8000/. - 
If the Cluster Optimizer homepage is displayed, this indicates that the Cluster Optimizer application has been deployed successfully.
 - 
To delete the
demochart, execute the following command:helm uninstall demo 
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:
- 
Open your command line interface and use the
mysqlcommand to connect to the MySQL database. Replace127.0.0.1with your actual MySQL database host address.mysql -h127.0.0.1 -urootNote: Ensure that the database is accessible from the Kubernetes cluster if you are using a remote database.
 - 
Create the
optconfandoptdatadatabase schema.mysql> source ~/setup/cluster-optimizer/sql/create_database.sqlNote: This script will delete the existing user database if it exists and create a new one. Proceed with caution to avoid data loss.
 - 
Create a new username and password, and assign the appropriate permissions. The default username and password in the script are
optimizerandOptimizer~, respectively. Adjust these as needed.mysql> source ~/setup/cluster-optimizer/sql/create_user.sql - 
Create the file
values.yamland edit its content as follows:optimizedb: conf: dbHost: 127.0.0.1 # Database address for configuration schema schema: optconf # Database schema for configuration port: 3306 # Database port user: optimizer # Username for database access password: Optimizer~ # Password for database access data: dbHost: 127.0.0.1 schema: optdata port: 3306 user: optimizer password: Optimizer~In the configuration,
dbHostis the database address,schemais the database schema,portis the database port,userandpasswordare the username and password respectively. - 
Install the
demochart using the following command:helm install demo cluster-optimizer/cluster-optimizer -f values.yaml --namespace wiseinf-systemYou can also modify the database settings by performing an upgrade on the existing deployment with the following command:
helm upgrade demo cluster-optimizer/cluster-optimizer -f values.yaml --namespace wiseinf-system - 
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: