Skip to main content
Version: Preview

Configure cluster parameters

This guide shows how to configure cluster parameters.

From v0.9.0, KubeBlocks supports dynamic configuration. When the specification of a database instance changes (e.g. a user vertically scales a cluster), KubeBlocks automatically matches the appropriate configuration template based on the new specification. This is because different specifications of a database instance may require different optimal configurations to optimize performance and resource utilization. When you choose a different database instance specification, KubeBlocks automatically detects it and determines the best database configuration for the new specification, ensuring optimal performance and configuration of the database under the new specifications.

This feature simplifies the process of configuring parameters, which saves you from manually configuring database parameters as KubeBlocks handles the updates and configurations automatically to adapt to the new specifications. This saves time and effort and reduces performance issues caused by incorrect configuration.

But it's also important to note that the dynamic parameter configuration doesn't apply to all parameters. Some parameters may require manual configuration. Additionally, if you have manually modified database parameters before, KubeBlocks may overwrite your customized configurations when updating the database configuration template. Therefore, when using the dynamic configuration feature, it is recommended to back up and record your custom configuration so that you can restore them if needed.

KubeBlocks supports configuring cluster parameters by editing its configuration file.

  1. Get the configuration file of this cluster.

    kubectl edit configurations.apps.kubeblocks.io mycluster-mysql -n demo
  2. Configure parameters according to your needs. The example below adds the spec.configFileParams part to configure max_connections.

    spec:
    clusterRef: mycluster
    componentName: mysql
    configItemDetails:
    - configFileParams:
    my.cnf:
    parameters:
    max_connections: "600"
    configSpec:
    constraintRef: oracle-mysql8.0-config-constraints
    name: mysql-replication-config
    namespace: kb-system
    templateRef: oracle-mysql8.0-config-template
    volumeName: mysql-config
    name: mysql-replication-config
    - configSpec:
    defaultMode: 292
  3. Connect to this cluster to verify whether the configuration takes effect.

    1. Get the username and password.

      kubectl get secrets -n demo mycluster-conn-credential -o jsonpath='{.data.username}' | base64 -d
      >
      root

      kubectl get secrets -n demo mycluster-conn-credential -o jsonpath='{.data.password}' | base64 -d
      >
      2gvztbvz
    2. Connect to this cluster and verify whether the parameters are configured as expected.

      kubectl exec -ti -n demo mycluster-mysql-0 -- bash

      mysql -uroot -p2gvztbvz
      >
      mysql> show variables like 'max_connections';
      +-----------------+-------+
      | Variable_name | Value |
      +-----------------+-------+
      | max_connections | 600 |
      +-----------------+-------+
      1 row in set (0.00 sec)
note

Just in case you cannot find the configuration file of your cluster, you can switch to the kbcli tab to view the current configuration file of a cluster.