Skip to content
logo
Percona Operator for MySQL
Install on OpenShift
Initializing search
    percona/k8spxc-docs
    percona/k8spxc-docs
    • Welcome
      • System Requirements
      • Design and architecture
      • Comparison with other solutions
      • Install with Helm
      • Install with kubectl
      • Install on Minikube
      • Install on Google Kubernetes Engine (GKE)
      • Install on Amazon Elastic Kubernetes Service (AWS EKS)
      • Install on Microsoft Azure Kubernetes Service (AKS)
      • Install on OpenShift
        • Install the Operator
          • Install the Operator via the Red Hat Marketplace
          • Install the Operator via the command-line interface
        • Install Percona XtraDB Cluster
      • Generic Kubernetes installation
      • Multi-cluster and multi-region deployment
      • Application and system users
      • Changing MySQL Options
      • Anti-affinity and tolerations
      • Labels and annotations
      • Local Storage support
      • Defining environment variables
      • Load Balancing with HAProxy
      • Load Balancing with ProxySQL
      • Transport Encryption (TLS/SSL)
      • Data at rest encryption
      • Telemetry
      • Backup and restore
      • Upgrade Database and Operator
      • Horizontal and vertical scaling
      • Monitor with Percona Monitoring and Management (PMM)
      • Add sidecar containers
      • Restart or pause the cluster
      • Crash recovery
      • Debug and troubleshoot
      • How to install Percona XtraDB Cluster in multi-namespace (cluster-wide) mode
      • How to upgrade Percona XtraDB Cluster manually
      • How to use private registry
      • Custom Resource options
      • Percona certified images
      • Operator API
      • Frequently Asked Questions
      • Old releases (documentation archive)
      • Release notes index
      • Percona Operator for MySQL based on Percona XtraDB Cluster 1.12.0 (2022-12-07)
      • Percona Operator for MySQL based on Percona XtraDB Cluster 1.11.0 (2022-06-03)
      • Percona Distribution for MySQL Operator 1.10.0 (2021-11-24)
      • Percona Distribution for MySQL Operator 1.9.0 (2021-08-09)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.8.0 (2021-05-26)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.7.0 (2021-02-02)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.6.0 (2020-09-09)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.5.0 (2020-07-21)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.4.0 (2020-04-29)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.3.0 (2020-01-06)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.2.0 (2019-09-20)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.1.0 (2019-07-15)
      • Percona Kubernetes Operator for Percona XtraDB Cluster 1.0.0 (2019-05-29)

    • Install the Operator
      • Install the Operator via the Red Hat Marketplace
      • Install the Operator via the command-line interface
    • Install Percona XtraDB Cluster

    Install Percona XtraDB Cluster on OpenShift¶

    Percona Operator for Percona XtrabDB Cluster is a Red Hat Certified Operator. This means that Percona Operator is portable across hybrid clouds and fully supports the Red Hat OpenShift lifecycle.

    Installing Percona XtraDB Cluster on OpenShift includes two steps:

    • Installing the Percona Operator for MySQL,

    • Install Percona XtraDB Cluster using the Operator.

    Install the Operator¶

    You can install Percona Operator for MySQL on OpenShift using the Red Hat Marketplace web interface or using the command line interface.

    Install the Operator via the Red Hat Marketplace¶

    1. login to the Red Hat Marketplace and register your cluster following the official instructions.

    2. Go to the Percona Operator for MySQL page and click the Free trial button:

      image

      Here you can “start trial” of the Operator for 0.0 USD.

    3. When finished, chose Workspace->Software in the system menu on the top and choose the Operator:

      image

      Click the Install Operator button.

    Install the Operator via the command-line interface¶

    1. Clone the percona-xtradb-cluster-operator repository:

      $ git clone -b v1.12.0 https://github.com/percona/percona-xtradb-cluster-operator
      $ cd percona-xtradb-cluster-operator
      

    Note

    It is crucial to specify the right branch with the -b option while cloning the code on this step. Please be careful.

    1. Now Custom Resource Definition for Percona XtraDB Cluster should be created from the deploy/crd.yaml file. Custom Resource Definition extends the standard set of resources which Kubernetes “knows” about with the new items (in our case ones which are the core of the operator).

      This step should be done only once; it does not need to be repeated with the next Operator deployments, etc.

      $ oc apply -f deploy/crd.yaml
      

      Note

      Setting Custom Resource Definition requires your user to have cluster-admin role privileges.

      If you want to manage your Percona XtraDB Cluster with a non-privileged user, necessary permissions can be granted by applying the next clusterrole:

      $ oc create clusterrole pxc-admin --verb="*" --resource=perconaxtradbclusters.pxc.percona.com,perconaxtradbclusters.pxc.percona.com/status,perconaxtradbclusterbackups.pxc.percona.com,perconaxtradbclusterbackups.pxc.percona.com/status,perconaxtradbclusterrestores.pxc.percona.com,perconaxtradbclusterrestores.pxc.percona.com/status
      $ oc adm policy add-cluster-role-to-user pxc-admin <some-user>
      

      If you have a cert-manager installed, then you have to execute two more commands to be able to manage certificates with a non-privileged user:

      $ oc create clusterrole cert-admin --verb="*" --resource=issuers.certmanager.k8s.io,certificates.certmanager.k8s.io
      $ oc adm policy add-cluster-role-to-user cert-admin <some-user>
      
    2. The next thing to do is to create a new pxc project:

      $ oc new-project pxc
      
    3. Now RBAC (role-based access control) for Percona XtraDB Cluster should be set up from the deploy/rbac.yaml file. Briefly speaking, role-based access is based on specifically defined roles and actions corresponding to them, allowed to be done on specific Kubernetes resources (details about users and roles can be found in OpenShift documentation).

      $ oc apply -f deploy/rbac.yaml
      

      Finally, it’s time to start the operator within OpenShift:

      $ oc apply -f deploy/operator.yaml
      

      Note

      You can simplify the Operator installation by applying a single deploy/bundle.yaml file instead of running commands from the steps 2 and 4:

      $ oc apply -f deploy/bundle.yaml
      

      This will automatically create Custom Resource Definition, set up role-based access control and install the Operator as one single action.

    Install Percona XtraDB Cluster¶

    1. Now that’s time to add the Percona XtraDB Cluster users Secrets with logins and passwords to Kubernetes. By default, the Operator generates users Secrets automatically, and no actions are required at this step.

      Still, you can generate and apply your Secrets by your own. In this case, place logins and plaintext passwords for the user accounts in the data section of the deploy/secrets.yaml file; after editing is finished, create users Secrets with the following command:

      $ oc create -f deploy/secrets.yaml
      

      More details about secrets can be found in Users.

    2. Now certificates should be generated. By default, the Operator generates certificates automatically, and no actions are required at this step. Still, you can generate and apply your own certificates as secrets according to the TLS instructions.

    3. After the operator is started and user secrets are added, Percona XtraDB Cluster can be created at any time with the following command:

      $ oc apply -f deploy/cr.yaml
      

      Creation process will take some time. The process is over when both operator and replica set pod have reached their Running status:

      NAME                                               READY   STATUS    RESTARTS   AGE
      cluster1-haproxy-0                                 2/2     Running   0          6m17s
      cluster1-haproxy-1                                 2/2     Running   0          4m59s
      cluster1-haproxy-2                                 2/2     Running   0          4m36s
      cluster1-pxc-0                                     3/3     Running   0          6m17s
      cluster1-pxc-1                                     3/3     Running   0          5m3s
      cluster1-pxc-2                                     3/3     Running   0          3m56s
      percona-xtradb-cluster-operator-79966668bd-rswbk   1/1     Running   0          9m54s
      
    4. Check connectivity to newly created cluster. Run a container with MySQL monitor and connect its console output to your terminal. The following command will do this, naming the new Pod percona-client:

      $ oc run -i --rm --tty percona-client --image=percona:8.0 --restart=Never -- bash -il
      percona-client:/$ mysql -h cluster1-haproxy -uroot -proot_password
      

      This command will connect you to the MySQL monitor.

      mysql: [Warning] Using a password on the command line interface can be insecure.
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 1976
      Server version: 8.0.19-10 Percona XtraDB Cluster (GPL), Release rel10, Revision 727f180, WSREP version 26.4.3
      
      Copyright (c) 2009-2020 Percona LLC and/or its affiliates
      Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
      
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      

    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-02-09
    Back to top
    Percona LLC and/or its affiliates, © 2009 - 2022
    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.