Install Percona XtraDB Cluster cluster-wide

By default, Percona XtraDB Cluster Operator functions in a specific Kubernetes namespace. You can create one during installation (like it is shown in the installation instructions) or just use the default namespace. This approach allows several Operators to co-exist in one Kubernetes-based environment, being separated in different namespaces.

Still, sometimes it is more convenient to have one Operator watching for Percona XtraDB Cluster custom resources in several namespaces.

We recommend running Percona XtraDB Cluster Operator in a traditional way, limited to a specific namespace. But it is possible to run it in so-called cluster-wide mode, one Operator watching several namespaces, if needed.

Note

Please take into account that if several Operators are configured to watch the same namespace, it is entirely unpredictable which one will get ownership of the Custom Resource in it, so this situation should be avoided.

To use the Operator in such cluster-wide mode, you should install it with a different set of configuration YAML files, which are available in the deploy folder and have filenames with a special cw- prefix: e.g. deploy/cw-bundle.yaml.

The following simple example shows how to install Operator cluster-wide on Kubernetes.

  1. First of all, clone the percona-xtradb-cluster-operator repository:

    git clone -b v1.6.0 https://github.com/percona/percona-xtradb-cluster-operator
    cd percona-xtradb-cluster-operator
    
  2. Let’s suppose that Operator’s namespace should be the pxc-operator one. Create it as follows:

    $ kubectl create namespace pxc-operator
    

    Namespaces to be watched by the Operator should be created in the same way if not exist. Let’s say the Operator should watch the pxc namespace:

    $ kubectl create namespace pxc
    
  3. Apply the deploy/cw-bundle.yaml file with the following command:

    $ kubectl apply -f deploy/cw-bundle.yaml -n pxc-operator
    
  4. After the Operator is started, Percona XtraDB Cluster can be created at any time by applying the deploy/cr.yaml configuration file, like in the case of normal installation:

    $ kubectl apply -f deploy/cr.yaml -n pxc
    

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

    $ kubectl get pods -n pxc
    NAME                                              READY   STATUS    RESTARTS   AGE
    cluster1-pxc-0                                    1/1     Running   0          5m
    cluster1-pxc-1                                    1/1     Running   0          4m
    cluster1-pxc-2                                    1/1     Running   0          2m
    cluster1-proxysql-0                               1/1     Running   0          5m
    
  5. Check connectivity to newly created cluster

    $ kubectl run -i --rm --tty percona-client --image=percona:5.7 --restart=Never --env="POD_NAMESPACE=pxc" -- bash -il
    percona-client:/$ mysql -h cluster1-proxysql -uroot -proot_password
    

Previous topic

Install Percona XtraDB Cluster using Helm

Next topic

Users

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 professional services, contact Percona Sales.