Skip to content

Database cluster Templates

Do not use for mission-critical workloads

DBaaS feature is deprecated. We encourage you to use Percona Everest instead. Check our Migration guide.

Database clusters can be created from templates using PMM. Database cluster Template allows operators to customize Database Clusters based on their requirements, environments, or infrastructure.

Examples

  • Data clusters: Different load patterns, such as simple reads, heavy writes, 50%/50% read/write, and the number of connections.

  • Infrastructure - Different parameters and tuning for the resulting cluster: such as network configuration (load balancing, exposure), storage classes/types, etc.

  • Environment: Combination of database cluster and infrastructure that will affect the database cluster configuration.

Customize PXC DB configuration

The following example shows how DBaaS users can create PXC DB clusters from a template that sets a custom MySQL configuration. The default MySQL configuration is the following:

[mysqld]
wsrep_provider_options="gcache.size=600M"

Note

PXC DB configuration can be customized based on your needs. This can be accomplished by creating a template and changing that field.

Create Custom Resource Definition (CRD) template

To create a template, do the following:

  1. Identify the field(s) of interest by reading the PXC operator documentation and the PXC CRD. In this case, you have to change the spec.pxc.configuration field.

  2. Create a template CRD pxctpl-crd-pxc-configuration.yaml with just those small subset of fields.

        apiVersion: apiextensions.k8s.io/v1
        kind: CustomResourceDefinition
        metadata:
        annotations:
            controller-gen.kubebuilder.io/version: v0.8.0
        creationTimestamp: null
        name: pxctemplatepxcconfiguration.dbaas.percona.com
        labels:
            dbaas.percona.com/template: "yes"
            dbaas.percona.com/engine: "pxc"
        spec:
        group: dbaas.percona.com
        names:
            kind: PXCTemplatePXCConfiguration
            listKind: PXCTemplatePXCConfigurationList
            plural: pxctemplatepxcconfiguration
            singular: pxctemplatepxcconfiguration
        scope: Namespaced
        versions:
        - name: v1
            schema:
            openAPIV3Schema:
                properties:
                apiVersion:
                    type: string
                kind:
                    type: string
                metadata:
                    type: object
                spec:
                    properties:
                    pxc:
                        properties:
                        configuration:
                            type: string
                        type: object
                    type: object
                status:
                    type: object
                type: object
            served: true
            storage: true
    
  3. Run the following command.

kubectl apply -f pxctpl-crd-upgrade-options.yaml

For more information, see DatabaseCluster templates.

Add read permissions for dbaas-operator

In order for the dbaas-operator to apply the template it needs access to the template CRs:

DBAAS_OPERATOR_MANAGER_ROLE=$(kubectl get clusterroles | grep dbaas-operator | grep -v metrics | grep -v proxy | cut -f 1 -d ' '); kubectl get clusterroles/"$DBAAS_OPERATOR_MANAGER_ROLE" -o yaml > dbaas-operator-manager-role.yaml
cat <<EOF >>dbaas-operator-manager-role.yaml
- apiGroups:
  - dbaas.percona.com
  resources:
  - pxctemplatepxcconfiguration
  verbs:
  - get
  - list
EOF

Run the following command:

kubectl apply -f dbaas-operator-manager-role.yaml

Create PXCTemplatePXCConfiguration Template CR

  1. Create a corresponding CR pxctpl-pxc-config-max-connection-789.yaml with the required values.

    apiVersion: dbaas.percona.com/v1
    kind: PXCTemplatePXCConfiguration
    metadata:
    name: pxc-config-max-connections-789
    labels:
        dbaas.percona.com/template: "yes"
        dbaas.percona.com/engine: "pxc"
    spec:
    pxc:
        configuration: |
        [mysqld]
        max_connections = 789
    
    2. Run the following command:

    kubectl apply -f pxctpl-pxc-config-max-connection-789.yaml
    

Create a DB cluster from template

To create a DB cluster from a template, do the following:

  1. From the main menu navigate to DBaaSCreate DB Cluster.

  2. On the Advanced Settings panel, select the template from the Templates drop-down.

    !

  3. Click Create.

Get expert help

If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services.


Last update: 2024-04-18