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-system
namespace and deploy resources such as Deployments, ConfigMaps, and Services within this namespace - Helm, version 3.0.0 or higher
Deploy application
-
Add the
cluster-optimizer
Helm 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-optimizer
repository using the following command:helm search repo cluster-optimizer
The 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 optimizer
The repository includes a chart named
cluster-optimizer/cluster-optimizer
. -
Install the
demo
chart using the following command:helm install demo cluster-optimizer/cluster-optimizer -n wiseinf-system --create-namespace
In this command,
-n wiseinf-system
specifies that thedemo
chart will be installed in thewiseinf-system
namespace, while the--create-namespace
flag 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
demo
chart. -
Check whether the
optimizer
pod is running normally through the following command:kubectl get pods -n wiseinf-system
The 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 108s
As the output indicates, Helm has successfully deployed two pods. The first is the
cluster-optimizer-demo-7bfdfdf954-2cgqb
pod, which represents the Cluster Optimizer service. The second is thecluster-optimizer-demo-optimizerdb-5d6cdb6b9f-94lc7
pod, 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
optimizer
service 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
demo
chart, 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
mysql
command to connect to the MySQL database. Replace127.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.
-
Create the
optconf
andoptdata
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.
-
Create a new username and password, and assign the appropriate permissions. The default username and password in the script are
optimizer
andOptimizer~
, respectively. Adjust these as needed.mysql> source ~/setup/cluster-optimizer/sql/create_user.sql
-
Create the file
values.yaml
and 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,
dbHost
is the database address,schema
is the database schema,port
is the database port,user
andpassword
are the username and password respectively. -
Install the
demo
chart using the following command:helm install demo cluster-optimizer/cluster-optimizer -f values.yaml --namespace wiseinf-system
You 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: