Skip to content
logo
Percona Monitoring and Management
Create a database cluster from a template
Initializing search
    percona/pmm-doc
    percona/pmm-doc
    • Welcome
        • Network
        • Docker
        • Podman
        • Helm
        • Virtual Appliance
        • AWS Marketplace
        • Easy-install script
        • MySQL
        • MongoDB
        • PostgreSQL
        • ProxySQL
        • Amazon RDS
        • Microsoft Azure
        • Google Cloud Platform
        • Linux
        • External Services
        • HAProxy
        • Remote instances
      • User Interface
      • Percona Alerting
        • Prepare a storage location
          • MongoDB backup prerequisites
          • Create MongoDB on-demand and scheduled backups
          • Create MongoDB PITR backups
          • Restore a MongoDB backup
          • MongoDB Backup and Restore support matrix
          • MySQL backup prerequisites
          • Create a MySQL backup
          • Restore a MySQL backup
        • Edit a scheduled backup
        • Delete a backup
        • Configure access control
        • Labels for access control
        • Create access roles
        • Manage access roles
        • Assign roles to users
        • Use Case
      • Query Analytics
      • Working with Advisors
      • Configure
      • Manage users
      • Upgrade
      • Secure
      • Optimize
      • Annotate
      • Share dashboards and panels
      • Extend Metrics
      • Resolve issues
        • Check Percona Portal account information
      • Architecture
      • UI components
      • PMM components and versions
      • Data handling in PMM
      • Develop Advisor checks
      • PMM Inventory
        • Manage dashboards
            • Advanced Data Exploration
            • VictoriaMetrics
            • VictoriaMetrics Agents Overview
            • Environment Summary
            • Kubernetes Pods Status
            • Kubernetes Volumes
          • DBaas
            • Disk Details
            • Network Details
            • Memory Details
            • Node Temperature Details
            • Nodes Compare
            • Nodes Overview
            • Node Summary
            • NUMA Details
            • Processes Details
            • Prometheus Exporters Overview
            • MySQL Command/Handler Counters Compare
            • MySQL InnoDB Compression Details
            • MySQL InnoDB Details
            • MySQL MyISAM/Aria Details
            • MySQL MyRocks Details
            • MySQL Instance Summary
            • MySQL Instances Compare
            • MySQL Instances Overview
            • MySQL Wait Event Analyses Details
            • MySQL Performance Schema Details
            • MySQL Query Response Time Details
            • MySQL Replication Summary
            • MySQL Group Replication Summary
            • MySQL Table Details
            • MySQL User Details
            • MySQL TokuDB Details
            • Experimental MongoDB Collection Details
            • Experimental MongoDB Oplog Details
            • MongoDB Cluster Summary
            • MongoDB Instance Summary
            • MongoDB Instances Overview
            • MongoDB Instances Compare
            • MongoDB ReplSet Summary
            • MongoDB InMemory Details
            • MongoDB MMAPv1 Details
            • MongoDB WiredTiger Details
            • PostgreSQL Instance Summary
            • PostgreSQL Instances Compare
            • Experimental PostgreSQL Vacuum Monitoring
          • ProxySQL Dashboards
            • PXC/Galera Cluster Summary
            • Experimental PXC/Galera Cluster Summary
            • PXC/Galera Nodes Compare
            • HAProxy Instance Summary
        • pmm-admin - PMM Administration Tool
        • pmm-agent - PMM Client agent
      • API
      • VictoriaMetrics
      • ClickHouse
      • PostgreSQL
      • Glossary
      • Introduction
      • DBaaS architecture
        • Setting up DBaaS
        • Create a Kubernetes Cluster
        • Deleting Kubernetes clusters
        • Activating DBaaS
        • Add a Kubernetes cluster automatically
        • Add a Kubernetes cluster manually
        • Manage allowed component versions
          • OLM installation
          • Operators installation
        • Add a DB Cluster
        • Manage a DB Cluster
        • Delete a DB Cluster
        • Create a database cluster from a template
      • Backup and restore
    • FAQ
      • PMM 2.39.0
      • PMM 2.38.1
      • PMM 2.38.0
      • PMM 2.37.1
      • PMM 2.37.0
      • PMM 2.36.0
      • PMM 2.35.0
      • PMM 2.34.0
      • PMM 2.33.0
      • PMM 2.32.0
      • PMM 2.31.0
      • PMM 2.30.0
      • PMM 2.29.1
      • PMM 2.29.0
      • PMM 2.28.0
      • PMM 2.27.0
      • PMM 2.26.0
      • PMM 2.25.0
      • PMM 2.24.0
      • PMM 2.23.0
      • PMM 2.22.0
      • PMM 2.21.0
      • PMM 2.20.0
      • PMM 2.19.0
      • PMM 2.18.0
      • PMM 2.17.0
      • PMM 2.16.0
      • PMM 2.15.1
      • PMM 2.15.0
      • PMM 2.14.0
      • PMM 2.13.0
      • PMM 2.12.0
      • PMM 2.11.1
      • PMM 2.11.0
      • PMM 2.10.1
      • PMM 2.10.0
      • PMM 2.9.1
      • PMM 2.9.0
      • PMM 2.8.0
      • PMM 2.7.0
      • PMM 2.6.1
      • PMM 2.6.0
      • PMM 2.5.0
      • PMM 2.4.0
      • PMM 2.3.0
      • PMM 2.2.2
      • PMM 2.2.1
      • PMM 2.2.0
      • PMM 2.1.0
      • PMM 2.0.1
      • PMM 2.0.0
      • Copyright and licensing information
      • Trademark policy

    Database cluster Templates¶

    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 DBaaS → Create DB Cluster.

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

      !

    3. Click Create.

    Contact us

    For free technical help, visit the Percona Community Forum.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.


    Last update: 2023-09-22
    Percona LLC, © 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better. Read more about Percona Cookie Policy.